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
83476045
Commit
83476045
authored
Mar 17, 2020
by
Théophile Bastian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle v4-over-v6 routes in Netlink backend.
parent
6f4a505a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
kernel_netlink.c
kernel_netlink.c
+23
-14
No files found.
kernel_netlink.c
View file @
83476045
...
...
@@ -953,7 +953,7 @@ kernel_route(int operation, int table,
struct
rtmsg
*
rtm
;
struct
rtattr
*
rta
;
int
len
=
sizeof
(
buf
.
raw
);
int
rc
,
ipv4
,
use_src
=
0
;
int
rc
,
ipv4
,
is_v4_over_v6
,
use_src
=
0
;
if
(
!
nl_setup
)
{
fprintf
(
stderr
,
"kernel_route: netlink not initialized.
\n
"
);
...
...
@@ -975,8 +975,7 @@ kernel_route(int operation, int table,
/* Check that the protocol family is consistent. */
if
(
plen
>=
96
&&
v4mapped
(
dest
))
{
if
(
!
v4mapped
(
gate
)
||
!
v4mapped
(
src
))
{
if
(
!
v4mapped
(
src
))
{
errno
=
EINVAL
;
return
-
1
;
}
...
...
@@ -1015,7 +1014,8 @@ kernel_route(int operation, int table,
}
ipv4
=
v4mapped
(
gate
);
ipv4
=
v4mapped
(
dest
);
is_v4_over_v6
=
ipv4
&&
!
v4mapped
(
gate
);
use_src
=
(
!
is_default
(
src
,
src_plen
)
&&
kernel_disambiguate
(
ipv4
));
kdebugf
(
"kernel_route: %s %s from %s "
...
...
@@ -1086,22 +1086,31 @@ kernel_route(int operation, int table,
*
(
int
*
)
RTA_DATA
(
rta
)
=
ifindex
;
#define ADD_IPARG(type, addr) \
do
if(ipv4)
{ \
do { \
rta = RTA_NEXT(rta, len); \
rta->rta_len = RTA_LENGTH(sizeof(struct in_addr)); \
rta->rta_type = type; \
memcpy(RTA_DATA(rta), addr + 12, sizeof(struct in_addr)); \
} else { \
rta = RTA_NEXT(rta, len); \
rta->rta_len = RTA_LENGTH(sizeof(struct in6_addr)); \
rta->rta_type = type; \
memcpy(RTA_DATA(rta), addr, sizeof(struct in6_addr)); \
if(v4mapped(addr)) { \
rta->rta_len = RTA_LENGTH(sizeof(struct in_addr)); \
memcpy(RTA_DATA(rta), addr + 12, sizeof(struct in_addr)); \
} else { \
if(type == RTA_VIA) { \
rta->rta_len = RTA_LENGTH(sizeof(struct in6_addr) + 2); \
*((sa_family_t*) RTA_DATA(rta)) = AF_INET6; \
memcpy(RTA_DATA(rta) + 2, addr, sizeof(struct in6_addr)); \
} else { \
rta->rta_len = RTA_LENGTH(sizeof(struct in6_addr)); \
memcpy(RTA_DATA(rta), addr, sizeof(struct in6_addr)); \
} \
} \
} while (0)
ADD_IPARG
(
RTA_GATEWAY
,
gate
);
if
(
is_v4_over_v6
)
ADD_IPARG
(
RTA_VIA
,
gate
);
else
ADD_IPARG
(
RTA_GATEWAY
,
gate
);
if
(
pref_src
)
ADD_IPARG
(
RTA_PREFSRC
,
pref_src
);
#undef ADD_IPARG
}
else
{
*
(
int
*
)
RTA_DATA
(
rta
)
=
-
1
;
...
...
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