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
54226db0
Commit
54226db0
authored
Jun 16, 2007
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use kernel_route(MODIFY) when updating routes.
parent
f474c8fa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
66 deletions
+34
-66
kernel.c
kernel.c
+1
-1
route.c
route.c
+32
-63
route.h
route.h
+1
-2
No files found.
kernel.c
View file @
54226db0
...
@@ -566,7 +566,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
...
@@ -566,7 +566,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
return
rc
;
return
rc
;
}
}
debugf
(
"kernel_route: %s %s/%d metric %d
via
%d nexthop %s
\n
"
,
debugf
(
"kernel_route: %s %s/%d metric %d
dev
%d nexthop %s
\n
"
,
operation
==
ROUTE_ADD
?
"add"
:
operation
==
ROUTE_ADD
?
"add"
:
operation
==
ROUTE_FLUSH
?
"flush"
:
"???"
,
operation
==
ROUTE_FLUSH
?
"flush"
:
"???"
,
format_address
(
dest
),
plen
,
metric
,
ifindex
,
format_address
(
dest
),
plen
,
metric
,
ifindex
,
...
...
route.c
View file @
54226db0
...
@@ -125,34 +125,6 @@ flush_neighbour_routes(struct neighbour *neigh)
...
@@ -125,34 +125,6 @@ flush_neighbour_routes(struct neighbour *neigh)
}
}
}
}
static
struct
route
*
reinstall_route
(
struct
route
*
route
)
{
if
(
route
->
metric
<
INFINITY
&&
route_feasible
(
route
))
{
install_route
(
route
);
return
route
;
}
else
{
struct
route
*
new_route
;
new_route
=
find_best_route
(
route
->
dest
);
if
(
new_route
)
{
install_route
(
new_route
);
return
new_route
;
}
else
{
/* We just lost a destination due to loop avoidance. */
if
(
route
->
dest
->
metric
<
INFINITY
)
{
/* Update seqno to make sure our predecessors accept
our retraction... */
route
->
dest
->
seqno
++
;
route
->
dest
->
metric
=
INFINITY
;
}
/* ...and hope we get a new seqno soon. */
send_update
(
route
->
dest
,
NULL
);
send_request
(
NULL
,
route
->
dest
);
return
NULL
;
}
}
}
unsigned
int
unsigned
int
metric_to_kernel
(
int
metric
)
metric_to_kernel
(
int
metric
)
{
{
...
@@ -288,19 +260,12 @@ update_neighbour_metric(struct neighbour *neigh)
...
@@ -288,19 +260,12 @@ update_neighbour_metric(struct neighbour *neigh)
void
void
update_route_metric
(
struct
route
*
route
)
update_route_metric
(
struct
route
*
route
)
{
{
int
metric
,
oldmetric
,
install
=
0
;
int
oldmetric
;
metric
=
MIN
(
route
->
refmetric
+
neighbour_cost
(
route
->
nexthop
),
INFINITY
);
if
(
route
->
installed
&&
metric_to_kernel
(
route
->
metric
)
!=
metric_to_kernel
(
metric
))
{
uninstall_route
(
route
);
install
=
1
;
}
oldmetric
=
route
->
metric
;
oldmetric
=
route
->
metric
;
route
->
metric
=
metric
;
change_route_metric
(
route
,
if
(
install
)
MIN
(
route
->
refmetric
+
neighbour_cost
(
route
->
nexthop
),
route
=
reinstall_route
(
route
);
INFINITY
));
if
(
route
)
{
if
(
route
->
installed
)
{
if
(
route
->
installed
)
{
struct
route
*
better_route
;
struct
route
*
better_route
;
better_route
=
find_best_route
(
route
->
dest
);
better_route
=
find_best_route
(
route
->
dest
);
...
@@ -311,7 +276,6 @@ update_route_metric(struct route *route)
...
@@ -311,7 +276,6 @@ update_route_metric(struct route *route)
}
else
{
}
else
{
consider_route
(
route
);
consider_route
(
route
);
}
}
}
}
}
struct
route
*
struct
route
*
...
@@ -354,7 +318,9 @@ update_route(const unsigned char *d, int seqno, int refmetric,
...
@@ -354,7 +318,9 @@ update_route(const unsigned char *d, int seqno, int refmetric,
oldseqno
=
route
->
seqno
;
oldseqno
=
route
->
seqno
;
oldmetric
=
route
->
metric
;
oldmetric
=
route
->
metric
;
route
->
time
=
now
.
tv_sec
;
route
->
time
=
now
.
tv_sec
;
tweak_route
(
route
,
seqno
,
refmetric
,
metric
);
route
->
seqno
=
seqno
;
route
->
refmetric
=
refmetric
;
change_route_metric
(
route
,
metric
);
if
(
seqno_compare
(
oldseqno
,
seqno
)
<=
0
)
{
if
(
seqno_compare
(
oldseqno
,
seqno
)
<=
0
)
{
if
(
seqno_compare
(
oldseqno
,
seqno
)
<
0
)
{
if
(
seqno_compare
(
oldseqno
,
seqno
)
<
0
)
{
/* Flush retracted xroutes */
/* Flush retracted xroutes */
...
@@ -435,21 +401,24 @@ consider_route(struct route *route)
...
@@ -435,21 +401,24 @@ consider_route(struct route *route)
}
}
void
void
tweak_route
(
struct
route
*
route
,
int
newseqno
,
int
newrefmetric
,
int
newmetric
)
change_route_metric
(
struct
route
*
route
,
int
newmetric
)
{
{
int
install
=
0
;
int
rc
;
if
(
route
->
installed
&&
if
(
route
->
installed
)
{
(
newmetric
>=
INFINITY
||
rc
=
kernel_route
(
newmetric
>=
INFINITY
?
ROUTE_FLUSH
:
ROUTE_MODIFY
,
metric_to_kernel
(
route
->
metric
)
!=
metric_to_kernel
(
newmetric
)))
{
route
->
dest
->
address
,
128
,
uninstall_route
(
route
);
route
->
nexthop
->
address
,
install
=
1
;
route
->
nexthop
->
network
->
ifindex
,
metric_to_kernel
(
route
->
metric
),
metric_to_kernel
(
newmetric
));
if
(
rc
<
0
)
{
perror
(
"kernel_route(MODIFY)"
);
return
;
}
if
(
newmetric
>=
INFINITY
)
route
->
installed
=
0
;
}
}
route
->
seqno
=
newseqno
;
route
->
metric
=
newmetric
;
route
->
metric
=
newmetric
;
route
->
refmetric
=
newrefmetric
;
if
(
install
)
reinstall_route
(
route
);
}
}
void
void
...
...
route.h
View file @
54226db0
...
@@ -54,6 +54,5 @@ struct route *update_route(const unsigned char *d, int seqno, int refmetric,
...
@@ -54,6 +54,5 @@ struct route *update_route(const unsigned char *d, int seqno, int refmetric,
struct
neighbour
*
nexthop
,
struct
neighbour
*
nexthop
,
struct
xroute
*
pxroutes
,
int
numpxroutes
);
struct
xroute
*
pxroutes
,
int
numpxroutes
);
void
consider_route
(
struct
route
*
route
);
void
consider_route
(
struct
route
*
route
);
void
tweak_route
(
struct
route
*
route
,
void
change_route_metric
(
struct
route
*
route
,
int
newmetric
);
int
newseqno
,
int
newrefmetric
,
int
newmetric
);
void
send_triggered_update
(
struct
route
*
route
,
int
oldmetric
);
void
send_triggered_update
(
struct
route
*
route
,
int
oldmetric
);
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