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
1b87d5c7
Commit
1b87d5c7
authored
Jul 14, 2011
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorder flush/install when changing a route over netlink.
As suggested by Dave Taht and Julien Cristau.
parent
bb33004f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
17 deletions
+27
-17
kernel_netlink.c
kernel_netlink.c
+27
-17
No files found.
kernel_netlink.c
View file @
1b87d5c7
...
...
@@ -861,33 +861,43 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
ipv4
=
v4mapped
(
gate
);
if
(
operation
==
ROUTE_MODIFY
)
{
int
added
;
if
(
newmetric
==
metric
&&
memcmp
(
newgate
,
gate
,
16
)
==
0
&&
newifindex
==
ifindex
)
return
0
;
/* It is better to add the new route before removing the old
one, to avoid losing packets. However, this only appears
to work if the metrics are different. */
if
(
newmetric
!=
metric
)
{
rc
=
kernel_route
(
ROUTE_ADD
,
dest
,
plen
,
newgate
,
newifindex
,
newmetric
,
NULL
,
0
,
0
);
if
(
rc
<
0
&&
errno
!=
EEXIST
)
one, to avoid losing packets. However, if the old and new
priorities are equal, this only works if the kernel supports
ECMP. So we first try the "right" order, and fall back on
the "wrong" order if it fails with EEXIST. */
rc
=
kernel_route
(
ROUTE_ADD
,
dest
,
plen
,
newgate
,
newifindex
,
newmetric
,
NULL
,
0
,
0
);
if
(
rc
<
0
)
{
if
(
errno
!=
EEXIST
)
return
rc
;
rc
=
kernel_route
(
ROUTE_FLUSH
,
dest
,
plen
,
gate
,
ifindex
,
metric
,
NULL
,
0
,
0
);
if
(
rc
<
0
&&
(
errno
==
ENOENT
||
errno
==
ESRCH
))
rc
=
1
;
added
=
0
;
}
else
{
rc
=
kernel_route
(
ROUTE_FLUSH
,
dest
,
plen
,
gate
,
ifindex
,
metric
,
NULL
,
0
,
0
);
added
=
1
;
}
kernel_route
(
ROUTE_FLUSH
,
dest
,
plen
,
gate
,
ifindex
,
metric
,
NULL
,
0
,
0
);
if
(
!
added
)
{
rc
=
kernel_route
(
ROUTE_ADD
,
dest
,
plen
,
newgate
,
newifindex
,
newmetric
,
NULL
,
0
,
0
);
if
(
rc
<
0
&&
errno
==
EEXIST
)
rc
=
1
;
if
(
rc
<
0
)
{
if
(
errno
==
EEXIST
)
rc
=
1
;
/* In principle, we should try to re-install the flushed
route on failure to preserve. However, this should
hopefully not matter much in practice. */
}
}
return
rc
;
}
...
...
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