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
de5d2c0f
Commit
de5d2c0f
authored
Apr 26, 2010
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Go through route_metric for reading route metrics.
parent
7d9aa84d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
26 deletions
+27
-26
babeld.c
babeld.c
+1
-1
local.c
local.c
+1
-1
message.c
message.c
+4
-4
route.c
route.c
+21
-20
No files found.
babeld.c
View file @
de5d2c0f
...
@@ -949,7 +949,7 @@ dump_tables(FILE *out)
...
@@ -949,7 +949,7 @@ dump_tables(FILE *out)
fprintf
(
out
,
"%s metric %d refmetric %d id %s seqno %d age %d "
fprintf
(
out
,
"%s metric %d refmetric %d id %s seqno %d age %d "
"via %s neigh %s%s%s%s
\n
"
,
"via %s neigh %s%s%s%s
\n
"
,
format_prefix
(
routes
[
i
].
src
->
prefix
,
routes
[
i
].
src
->
plen
),
format_prefix
(
routes
[
i
].
src
->
prefix
,
routes
[
i
].
src
->
plen
),
route
s
[
i
].
metric
,
routes
[
i
].
refmetric
,
route
_metric
(
&
routes
[
i
])
,
routes
[
i
].
refmetric
,
format_eui64
(
routes
[
i
].
src
->
id
),
format_eui64
(
routes
[
i
].
src
->
id
),
(
int
)
routes
[
i
].
seqno
,
(
int
)
routes
[
i
].
seqno
,
(
int
)(
now
.
tv_sec
-
routes
[
i
].
time
),
(
int
)(
now
.
tv_sec
-
routes
[
i
].
time
),
...
...
local.c
View file @
de5d2c0f
...
@@ -206,7 +206,7 @@ local_notify_route(struct route *route, int kind)
...
@@ -206,7 +206,7 @@ local_notify_route(struct route *route, int kind)
format_prefix
(
route
->
src
->
prefix
,
route
->
src
->
plen
),
format_prefix
(
route
->
src
->
prefix
,
route
->
src
->
plen
),
route
->
installed
?
"yes"
:
"no"
,
route
->
installed
?
"yes"
:
"no"
,
format_eui64
(
route
->
src
->
id
),
format_eui64
(
route
->
src
->
id
),
route
->
metric
,
route
->
refmetric
,
route
_metric
(
route
)
,
route
->
refmetric
,
format_address
(
route
->
neigh
->
address
),
format_address
(
route
->
neigh
->
address
),
route
->
neigh
->
network
->
ifname
);
route
->
neigh
->
network
->
ifname
);
...
...
message.c
View file @
de5d2c0f
...
@@ -888,7 +888,7 @@ flushupdates(struct network *net)
...
@@ -888,7 +888,7 @@ flushupdates(struct network *net)
last_plen
=
xroute
->
plen
;
last_plen
=
xroute
->
plen
;
}
else
if
(
route
)
{
}
else
if
(
route
)
{
seqno
=
route
->
seqno
;
seqno
=
route
->
seqno
;
metric
=
route
->
metric
;
metric
=
route
_metric
(
route
)
;
if
(
metric
<
INFINITY
)
if
(
metric
<
INFINITY
)
satisfy_request
(
route
->
src
->
prefix
,
route
->
src
->
plen
,
satisfy_request
(
route
->
src
->
prefix
,
route
->
src
->
plen
,
seqno
,
route
->
src
->
id
,
net
);
seqno
,
route
->
src
->
id
,
net
);
...
@@ -975,7 +975,7 @@ send_update(struct network *net, int urgent,
...
@@ -975,7 +975,7 @@ send_update(struct network *net, int urgent,
/* Since flushupdates only deals with non-wildcard interfaces, we
/* Since flushupdates only deals with non-wildcard interfaces, we
need to do this now. */
need to do this now. */
route
=
find_installed_route
(
prefix
,
plen
);
route
=
find_installed_route
(
prefix
,
plen
);
if
(
route
&&
route
->
metric
<
INFINITY
)
if
(
route
&&
route
_metric
(
route
)
<
INFINITY
)
satisfy_request
(
prefix
,
plen
,
route
->
src
->
seqno
,
route
->
src
->
id
,
satisfy_request
(
prefix
,
plen
,
route
->
src
->
seqno
,
route
->
src
->
id
,
NULL
);
NULL
);
}
}
...
@@ -1382,7 +1382,7 @@ handle_request(struct neighbour *neigh, const unsigned char *prefix,
...
@@ -1382,7 +1382,7 @@ handle_request(struct neighbour *neigh, const unsigned char *prefix,
return
;
return
;
/* Let's try to forward this request. */
/* Let's try to forward this request. */
if
(
route
&&
route
->
metric
<
INFINITY
)
if
(
route
&&
route
_metric
(
route
)
<
INFINITY
)
successor
=
route
->
neigh
;
successor
=
route
->
neigh
;
if
(
!
successor
||
successor
==
neigh
)
{
if
(
!
successor
||
successor
==
neigh
)
{
...
@@ -1391,7 +1391,7 @@ handle_request(struct neighbour *neigh, const unsigned char *prefix,
...
@@ -1391,7 +1391,7 @@ handle_request(struct neighbour *neigh, const unsigned char *prefix,
struct
route
*
other_route
;
struct
route
*
other_route
;
other_route
=
find_best_route
(
prefix
,
plen
,
0
,
neigh
);
other_route
=
find_best_route
(
prefix
,
plen
,
0
,
neigh
);
if
(
other_route
&&
other_route
->
metric
<
INFINITY
)
if
(
other_route
&&
route_metric
(
other_route
)
<
INFINITY
)
successor
=
other_route
->
neigh
;
successor
=
other_route
->
neigh
;
}
}
...
...
route.c
View file @
de5d2c0f
...
@@ -80,7 +80,7 @@ flush_route(struct route *route)
...
@@ -80,7 +80,7 @@ flush_route(struct route *route)
i
=
route
-
routes
;
i
=
route
-
routes
;
assert
(
i
>=
0
&&
i
<
numroutes
);
assert
(
i
>=
0
&&
i
<
numroutes
);
oldmetric
=
route
->
metric
;
oldmetric
=
route
_metric
(
route
)
;
if
(
route
->
installed
)
{
if
(
route
->
installed
)
{
uninstall_route
(
route
);
uninstall_route
(
route
);
...
@@ -166,7 +166,7 @@ install_route(struct route *route)
...
@@ -166,7 +166,7 @@ install_route(struct route *route)
rc
=
kernel_route
(
ROUTE_ADD
,
route
->
src
->
prefix
,
route
->
src
->
plen
,
rc
=
kernel_route
(
ROUTE_ADD
,
route
->
src
->
prefix
,
route
->
src
->
plen
,
route
->
nexthop
,
route
->
nexthop
,
route
->
neigh
->
network
->
ifindex
,
route
->
neigh
->
network
->
ifindex
,
metric_to_kernel
(
route
->
metric
),
NULL
,
0
,
0
);
metric_to_kernel
(
route
_metric
(
route
)
),
NULL
,
0
,
0
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
int
save
=
errno
;
int
save
=
errno
;
perror
(
"kernel_route(ADD)"
);
perror
(
"kernel_route(ADD)"
);
...
@@ -188,7 +188,7 @@ uninstall_route(struct route *route)
...
@@ -188,7 +188,7 @@ uninstall_route(struct route *route)
rc
=
kernel_route
(
ROUTE_FLUSH
,
route
->
src
->
prefix
,
route
->
src
->
plen
,
rc
=
kernel_route
(
ROUTE_FLUSH
,
route
->
src
->
prefix
,
route
->
src
->
plen
,
route
->
nexthop
,
route
->
nexthop
,
route
->
neigh
->
network
->
ifindex
,
route
->
neigh
->
network
->
ifindex
,
metric_to_kernel
(
route
->
metric
),
NULL
,
0
,
0
);
metric_to_kernel
(
route
_metric
(
route
)
),
NULL
,
0
,
0
);
if
(
rc
<
0
)
if
(
rc
<
0
)
perror
(
"kernel_route(FLUSH)"
);
perror
(
"kernel_route(FLUSH)"
);
...
@@ -219,9 +219,9 @@ switch_routes(struct route *old, struct route *new)
...
@@ -219,9 +219,9 @@ switch_routes(struct route *old, struct route *new)
rc
=
kernel_route
(
ROUTE_MODIFY
,
old
->
src
->
prefix
,
old
->
src
->
plen
,
rc
=
kernel_route
(
ROUTE_MODIFY
,
old
->
src
->
prefix
,
old
->
src
->
plen
,
old
->
nexthop
,
old
->
neigh
->
network
->
ifindex
,
old
->
nexthop
,
old
->
neigh
->
network
->
ifindex
,
metric_to_kernel
(
old
->
metric
),
metric_to_kernel
(
route_metric
(
old
)
),
new
->
nexthop
,
new
->
neigh
->
network
->
ifindex
,
new
->
nexthop
,
new
->
neigh
->
network
->
ifindex
,
metric_to_kernel
(
new
->
metric
));
metric_to_kernel
(
route_metric
(
new
)
));
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
perror
(
"kernel_route(MODIFY)"
);
perror
(
"kernel_route(MODIFY)"
);
return
;
return
;
...
@@ -239,10 +239,10 @@ change_route_metric(struct route *route, unsigned newmetric)
...
@@ -239,10 +239,10 @@ change_route_metric(struct route *route, unsigned newmetric)
{
{
int
old
,
new
;
int
old
,
new
;
if
(
route
->
metric
==
newmetric
)
if
(
route
_metric
(
route
)
==
newmetric
)
return
;
return
;
old
=
metric_to_kernel
(
route
->
metric
);
old
=
metric_to_kernel
(
route
_metric
(
route
)
);
new
=
metric_to_kernel
(
newmetric
);
new
=
metric_to_kernel
(
newmetric
);
if
(
route
->
installed
&&
old
!=
new
)
{
if
(
route
->
installed
&&
old
!=
new
)
{
...
@@ -316,7 +316,7 @@ find_best_route(const unsigned char *prefix, unsigned char plen, int feasible,
...
@@ -316,7 +316,7 @@ find_best_route(const unsigned char *prefix, unsigned char plen, int feasible,
continue
;
continue
;
if
(
exclude
&&
routes
[
i
].
neigh
==
exclude
)
if
(
exclude
&&
routes
[
i
].
neigh
==
exclude
)
continue
;
continue
;
if
(
route
&&
route
->
metric
<=
routes
[
i
].
metric
)
if
(
route
&&
route
_metric
(
route
)
<=
route_metric
(
&
routes
[
i
])
)
continue
;
continue
;
route
=
&
routes
[
i
];
route
=
&
routes
[
i
];
}
}
...
@@ -329,7 +329,7 @@ update_route_metric(struct route *route)
...
@@ -329,7 +329,7 @@ update_route_metric(struct route *route)
int
oldmetric
;
int
oldmetric
;
int
newmetric
;
int
newmetric
;
oldmetric
=
route
->
metric
;
oldmetric
=
route
_metric
(
route
)
;
if
(
route_expired
(
route
))
{
if
(
route_expired
(
route
))
{
if
(
route
->
refmetric
<
INFINITY
)
{
if
(
route
->
refmetric
<
INFINITY
)
{
route
->
seqno
=
seqno_plus
(
route
->
src
->
seqno
,
1
);
route
->
seqno
=
seqno_plus
(
route
->
src
->
seqno
,
1
);
...
@@ -414,7 +414,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
...
@@ -414,7 +414,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
int
lost
=
0
;
int
lost
=
0
;
oldsrc
=
route
->
src
;
oldsrc
=
route
->
src
;
oldmetric
=
route
->
metric
;
oldmetric
=
route
_metric
(
route
)
;
/* If a successor switches sources, we must accept his update even
/* If a successor switches sources, we must accept his update even
if it makes a route unfeasible in order to break any routing loops
if it makes a route unfeasible in order to break any routing loops
...
@@ -498,7 +498,7 @@ send_unfeasible_request(struct neighbour *neigh, int force,
...
@@ -498,7 +498,7 @@ send_unfeasible_request(struct neighbour *neigh, int force,
return
;
return
;
}
}
if
(
force
||
!
route
||
route
->
metric
>=
metric
+
512
)
{
if
(
force
||
!
route
||
route
_metric
(
route
)
>=
metric
+
512
)
{
send_unicast_multihop_request
(
neigh
,
src
->
prefix
,
src
->
plen
,
send_unicast_multihop_request
(
neigh
,
src
->
prefix
,
src
->
plen
,
src
->
metric
>=
INFINITY
?
src
->
metric
>=
INFINITY
?
src
->
seqno
:
src
->
seqno
:
...
@@ -530,20 +530,20 @@ consider_route(struct route *route)
...
@@ -530,20 +530,20 @@ consider_route(struct route *route)
if
(
installed
==
NULL
)
if
(
installed
==
NULL
)
goto
install
;
goto
install
;
if
(
route
->
metric
>=
INFINITY
)
if
(
route
_metric
(
route
)
>=
INFINITY
)
return
;
return
;
if
(
installed
->
metric
>=
INFINITY
)
if
(
route_metric
(
installed
)
>=
INFINITY
)
goto
install
;
goto
install
;
if
(
installed
->
metric
>=
route
->
metric
+
192
)
if
(
route_metric
(
installed
)
>=
route_metric
(
route
)
+
192
)
goto
install
;
goto
install
;
/* Avoid switching sources */
/* Avoid switching sources */
if
(
installed
->
src
!=
route
->
src
)
if
(
installed
->
src
!=
route
->
src
)
return
;
return
;
if
(
installed
->
metric
>=
route
->
metric
+
64
)
if
(
route_metric
(
installed
)
>=
route_metric
(
route
)
+
64
)
goto
install
;
goto
install
;
return
;
return
;
...
@@ -551,7 +551,7 @@ consider_route(struct route *route)
...
@@ -551,7 +551,7 @@ consider_route(struct route *route)
install:
install:
switch_routes
(
installed
,
route
);
switch_routes
(
installed
,
route
);
if
(
installed
&&
route
->
installed
)
if
(
installed
&&
route
->
installed
)
send_triggered_update
(
route
,
installed
->
src
,
installed
->
metric
);
send_triggered_update
(
route
,
installed
->
src
,
route_metric
(
installed
)
);
else
else
send_update
(
NULL
,
1
,
route
->
src
->
prefix
,
route
->
src
->
plen
);
send_update
(
NULL
,
1
,
route
->
src
->
prefix
,
route
->
src
->
plen
);
return
;
return
;
...
@@ -565,7 +565,7 @@ retract_neighbour_routes(struct neighbour *neigh)
...
@@ -565,7 +565,7 @@ retract_neighbour_routes(struct neighbour *neigh)
i
=
0
;
i
=
0
;
while
(
i
<
numroutes
)
{
while
(
i
<
numroutes
)
{
if
(
routes
[
i
].
neigh
==
neigh
)
{
if
(
routes
[
i
].
neigh
==
neigh
)
{
unsigned
short
oldmetric
=
route
s
[
i
].
metric
;
unsigned
short
oldmetric
=
route
_metric
(
&
routes
[
i
])
;
if
(
oldmetric
!=
INFINITY
)
{
if
(
oldmetric
!=
INFINITY
)
{
change_route_metric
(
&
routes
[
i
],
INFINITY
);
change_route_metric
(
&
routes
[
i
],
INFINITY
);
route_changed
(
&
routes
[
i
],
routes
[
i
].
src
,
oldmetric
);
route_changed
(
&
routes
[
i
],
routes
[
i
].
src
,
oldmetric
);
...
@@ -586,7 +586,7 @@ send_triggered_update(struct route *route, struct source *oldsrc,
...
@@ -586,7 +586,7 @@ send_triggered_update(struct route *route, struct source *oldsrc,
if
(
!
route
->
installed
)
if
(
!
route
->
installed
)
return
;
return
;
newmetric
=
route
->
metric
;
newmetric
=
route
_metric
(
route
)
;
diff
=
diff
=
newmetric
>=
oldmetric
?
newmetric
-
oldmetric
:
oldmetric
-
newmetric
;
newmetric
>=
oldmetric
?
newmetric
-
oldmetric
:
oldmetric
-
newmetric
;
...
@@ -639,11 +639,12 @@ route_changed(struct route *route,
...
@@ -639,11 +639,12 @@ route_changed(struct route *route,
struct
source
*
oldsrc
,
unsigned
short
oldmetric
)
struct
source
*
oldsrc
,
unsigned
short
oldmetric
)
{
{
if
(
route
->
installed
)
{
if
(
route
->
installed
)
{
if
(
route
->
metric
>
oldmetric
)
{
if
(
route
_metric
(
route
)
>
oldmetric
)
{
struct
route
*
better_route
;
struct
route
*
better_route
;
better_route
=
better_route
=
find_best_route
(
route
->
src
->
prefix
,
route
->
src
->
plen
,
1
,
NULL
);
find_best_route
(
route
->
src
->
prefix
,
route
->
src
->
plen
,
1
,
NULL
);
if
(
better_route
&&
better_route
->
metric
<=
route
->
metric
-
96
)
if
(
better_route
&&
route_metric
(
better_route
)
<=
route_metric
(
route
)
-
96
)
consider_route
(
better_route
);
consider_route
(
better_route
);
}
}
...
...
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