Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
7fd93b09
Commit
7fd93b09
authored
Jun 30, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect bridged interfaces, disable wired optimisations on them.
parent
ec101080
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
kernel_netlink.c
kernel_netlink.c
+51
-0
No files found.
kernel_netlink.c
View file @
7fd93b09
...
...
@@ -39,6 +39,7 @@ THE SOFTWARE.
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/if_bridge.h>
#if (__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 5)
#define RTA_TABLE 15
...
...
@@ -596,6 +597,51 @@ kernel_interface_mtu(const char *ifname, int ifindex)
return
req
.
ifr_mtu
;
}
static
int
isbridge
(
const
char
*
ifname
,
int
ifindex
)
{
char
buf
[
256
];
int
rc
,
i
;
unsigned
long
args
[
3
];
int
indices
[
256
];
rc
=
snprintf
(
buf
,
256
,
"/sys/class/net/%s"
,
ifname
);
if
(
rc
<
0
||
rc
>=
256
)
goto
fallback
;
if
(
access
(
buf
,
R_OK
)
<
0
)
goto
fallback
;
rc
=
snprintf
(
buf
,
256
,
"/sys/class/net/%s/bridge"
,
ifname
);
if
(
rc
<
0
||
rc
>=
256
)
goto
fallback
;
if
(
access
(
buf
,
F_OK
)
>=
0
)
return
1
;
else
if
(
errno
==
ENOENT
)
return
0
;
fallback:
args
[
0
]
=
BRCTL_GET_BRIDGES
;
args
[
1
]
=
(
unsigned
long
)
indices
;
args
[
2
]
=
256
;
rc
=
ioctl
(
dgram_socket
,
SIOCGIFBR
,
args
);
if
(
rc
<
0
)
{
if
(
errno
==
ENOPKG
)
return
0
;
else
return
-
1
;
}
for
(
i
=
0
;
i
<
rc
;
i
++
)
{
if
(
indices
[
i
]
==
ifindex
)
return
1
;
}
return
0
;
}
int
kernel_interface_wireless
(
const
char
*
ifname
,
int
ifindex
)
{
...
...
@@ -605,6 +651,11 @@ kernel_interface_wireless(const char *ifname, int ifindex)
struct
ifreq
req
;
int
rc
;
if
(
isbridge
(
ifname
,
ifindex
)
!=
0
)
{
/* Give up. */
return
-
1
;
}
memset
(
&
req
,
0
,
sizeof
(
req
));
strncpy
(
req
.
ifr_name
,
ifname
,
sizeof
(
req
.
ifr_name
));
rc
=
ioctl
(
dgram_socket
,
SIOCGIWNAME
,
&
req
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment