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
fd51cbf6
Commit
fd51cbf6
authored
Apr 18, 2009
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix kernel_ll_addresses.
It was completely broken, but compensated with another bug. No kidding.
parent
d275c6aa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
36 deletions
+24
-36
kernel.c
kernel.c
+0
-29
kernel.h
kernel.h
+1
-1
kernel_netlink.c
kernel_netlink.c
+23
-6
No files found.
kernel.c
View file @
fd51cbf6
...
@@ -31,35 +31,6 @@ THE SOFTWARE.
...
@@ -31,35 +31,6 @@ THE SOFTWARE.
#include "kernel_netlink.c"
#include "kernel_netlink.c"
#endif
#endif
/* Return an interface's link-local addresses */
int
kernel_ll_addresses
(
char
*
ifname
,
int
ifindex
,
unsigned
char
(
*
addresses
)[
16
],
int
maxaddr
)
{
struct
kernel_route
routes
[
64
];
int
rc
,
i
,
j
;
rc
=
kernel_addresses
(
ifname
,
ifindex
,
routes
,
64
);
if
(
rc
<
0
)
return
-
1
;
j
=
0
;
for
(
i
=
0
;
i
<
rc
;
i
++
)
{
unsigned
char
*
prefix
;
if
(
j
>=
maxaddr
)
break
;
if
(
routes
[
i
].
ifindex
!=
ifindex
)
continue
;
prefix
=
routes
[
i
].
prefix
;
if
(
prefix
[
0
]
==
0xFE
&&
prefix
[
1
]
==
0x80
&&
memcmp
(
prefix
+
2
,
zeroes
,
6
)
==
0
)
{
memcpy
(
addresses
[
j
],
prefix
,
16
);
j
++
;
}
}
return
j
;
}
/* Like gettimeofday, but returns monotonic time. If POSIX clocks are not
/* Like gettimeofday, but returns monotonic time. If POSIX clocks are not
available, falls back to gettimeofday but enforces monotonicity. */
available, falls back to gettimeofday but enforces monotonicity. */
int
int
...
...
kernel.h
View file @
fd51cbf6
...
@@ -61,6 +61,6 @@ int kernel_callback(int (*fn)(int, void*), void *closure);
...
@@ -61,6 +61,6 @@ int kernel_callback(int (*fn)(int, void*), void *closure);
int
kernel_addresses
(
char
*
ifname
,
int
ifindex
,
int
kernel_addresses
(
char
*
ifname
,
int
ifindex
,
struct
kernel_route
*
routes
,
int
maxroutes
);
struct
kernel_route
*
routes
,
int
maxroutes
);
int
kernel_ll_addresses
(
char
*
ifname
,
int
ifindex
,
int
kernel_ll_addresses
(
char
*
ifname
,
int
ifindex
,
unsigned
char
(
*
addresses
)[
16
],
int
maxaddr
);
struct
kernel_route
*
routes
,
int
maxroutes
);
int
if_eui64
(
char
*
ifname
,
int
ifindex
,
unsigned
char
*
eui
);
int
if_eui64
(
char
*
ifname
,
int
ifindex
,
unsigned
char
*
eui
);
int
gettime
(
struct
timeval
*
tv
);
int
gettime
(
struct
timeval
*
tv
);
kernel_netlink.c
View file @
fd51cbf6
...
@@ -1182,13 +1182,15 @@ filter_addresses(struct nlmsghdr *nh, void *data)
...
@@ -1182,13 +1182,15 @@ filter_addresses(struct nlmsghdr *nh, void *data)
struct
ifaddrmsg
*
ifa
;
struct
ifaddrmsg
*
ifa
;
char
ifname
[
IFNAMSIZ
];
char
ifname
[
IFNAMSIZ
];
int
ifindex
=
0
;
int
ifindex
=
0
;
int
ll
=
0
;
if
(
data
)
{
if
(
data
)
{
void
**
args
=
(
void
**
)
data
;
void
**
args
=
(
void
**
)
data
;
maxroutes
=
*
(
int
*
)
args
[
0
];
maxroutes
=
*
(
int
*
)
args
[
0
];
routes
=
(
struct
kernel_route
*
)
args
[
1
];
routes
=
(
struct
kernel_route
*
)
args
[
1
];
found
=
(
int
*
)
args
[
2
];
found
=
(
int
*
)
args
[
2
];
ifindex
=
args
[
3
]
?
0
:
*
(
int
*
)
args
[
3
];
ifindex
=
args
[
3
]
?
*
(
int
*
)
args
[
3
]
:
0
;
ll
=
args
[
4
]
?
!!*
(
int
*
)
args
[
4
]
:
0
;
}
}
len
=
nh
->
nlmsg_len
;
len
=
nh
->
nlmsg_len
;
...
@@ -1207,7 +1209,7 @@ filter_addresses(struct nlmsghdr *nh, void *data)
...
@@ -1207,7 +1209,7 @@ filter_addresses(struct nlmsghdr *nh, void *data)
if
(
rc
<
0
)
if
(
rc
<
0
)
return
0
;
return
0
;
if
(
IN6_IS_ADDR_LINKLOCAL
(
&
addr
))
if
(
ll
==
!
IN6_IS_ADDR_LINKLOCAL
(
&
addr
))
return
0
;
return
0
;
if
(
ifindex
&&
ifa
->
ifa_index
!=
ifindex
)
if
(
ifindex
&&
ifa
->
ifa_index
!=
ifindex
)
...
@@ -1264,13 +1266,14 @@ filter_netlink(struct nlmsghdr *nh, void *data)
...
@@ -1264,13 +1266,14 @@ filter_netlink(struct nlmsghdr *nh, void *data)
return
0
;
return
0
;
}
}
int
static
int
kernel_addresses
(
char
*
ifname
,
int
ifindex
,
kernel_addresses_internal
(
char
*
ifname
,
int
ifindex
,
struct
kernel_route
*
routes
,
int
maxroutes
)
struct
kernel_route
*
routes
,
int
maxroutes
,
int
ll
)
{
{
int
maxr
=
maxroutes
;
int
maxr
=
maxroutes
;
int
found
=
0
;
int
found
=
0
;
void
*
data
[]
=
{
&
maxr
,
routes
,
&
found
,
&
ifindex
,
NULL
};
void
*
data
[]
=
{
&
maxr
,
routes
,
&
found
,
&
ifindex
,
&
ll
,
NULL
};
struct
rtgenmsg
g
;
struct
rtgenmsg
g
;
int
rc
;
int
rc
;
...
@@ -1304,6 +1307,20 @@ kernel_addresses(char *ifname, int ifindex,
...
@@ -1304,6 +1307,20 @@ kernel_addresses(char *ifname, int ifindex,
return
found
;
return
found
;
}
}
int
kernel_addresses
(
char
*
ifname
,
int
ifindex
,
struct
kernel_route
*
routes
,
int
maxroutes
)
{
return
kernel_addresses_internal
(
ifname
,
ifindex
,
routes
,
maxroutes
,
0
);
}
int
kernel_ll_addresses
(
char
*
ifname
,
int
ifindex
,
struct
kernel_route
*
routes
,
int
maxroutes
)
{
return
kernel_addresses_internal
(
ifname
,
ifindex
,
routes
,
maxroutes
,
1
);
}
int
int
kernel_callback
(
int
(
*
fn
)(
int
,
void
*
),
void
*
closure
)
kernel_callback
(
int
(
*
fn
)(
int
,
void
*
),
void
*
closure
)
{
{
...
...
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