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
eb1ac22c
Commit
eb1ac22c
authored
Oct 13, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Derive hold time from interval given in Update message.
parent
b66abbb2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
12 deletions
+17
-12
message.c
message.c
+3
-2
route.c
route.c
+11
-6
route.h
route.h
+3
-4
No files found.
message.c
View file @
eb1ac22c
...
@@ -362,7 +362,8 @@ parse_packet(const unsigned char *from, struct network *net,
...
@@ -362,7 +362,8 @@ parse_packet(const unsigned char *from, struct network *net,
nh
=
neigh
->
address
;
nh
=
neigh
->
address
;
}
}
update_route
(
router_id
,
prefix
,
plen
,
seqno
,
metric
,
neigh
,
nh
);
update_route
(
router_id
,
prefix
,
plen
,
seqno
,
metric
,
interval
,
neigh
,
nh
);
}
else
if
(
type
==
MESSAGE_REQUEST
)
{
}
else
if
(
type
==
MESSAGE_REQUEST
)
{
unsigned
char
prefix
[
16
];
unsigned
char
prefix
[
16
];
int
rc
;
int
rc
;
...
@@ -372,7 +373,7 @@ parse_packet(const unsigned char *from, struct network *net,
...
@@ -372,7 +373,7 @@ parse_packet(const unsigned char *from, struct network *net,
message
+
4
,
NULL
,
len
-
2
,
prefix
);
message
+
4
,
NULL
,
len
-
2
,
prefix
);
if
(
rc
<
0
)
goto
fail
;
if
(
rc
<
0
)
goto
fail
;
debugf
(
"Received request for %s from %s on %s.
\n
"
,
debugf
(
"Received request for %s from %s on %s.
\n
"
,
format_prefix
(
prefix
,
message
[
3
]),
message
[
2
]
==
0
?
"any"
:
format_prefix
(
prefix
,
message
[
3
]),
format_address
(
from
),
net
->
ifname
);
format_address
(
from
),
net
->
ifname
);
if
(
message
[
2
]
==
0
)
{
if
(
message
[
2
]
==
0
)
{
/* If a neighbour is requesting a full route dump from us,
/* If a neighbour is requesting a full route dump from us,
...
...
route.c
View file @
eb1ac22c
...
@@ -42,8 +42,6 @@ THE SOFTWARE.
...
@@ -42,8 +42,6 @@ THE SOFTWARE.
struct
route
*
routes
=
NULL
;
struct
route
*
routes
=
NULL
;
int
numroutes
=
0
,
maxroutes
=
0
;
int
numroutes
=
0
,
maxroutes
=
0
;
unsigned
kernel_metric
=
0
;
unsigned
kernel_metric
=
0
;
int
route_timeout_delay
=
160
;
int
route_gc_delay
=
180
;
struct
route
*
struct
route
*
find_route
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
find_route
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
...
@@ -267,7 +265,7 @@ find_best_route(const unsigned char *prefix, unsigned char plen, int feasible,
...
@@ -267,7 +265,7 @@ find_best_route(const unsigned char *prefix, unsigned char plen, int feasible,
for
(
i
=
0
;
i
<
numroutes
;
i
++
)
{
for
(
i
=
0
;
i
<
numroutes
;
i
++
)
{
if
(
!
source_match
(
routes
[
i
].
src
,
prefix
,
plen
))
if
(
!
source_match
(
routes
[
i
].
src
,
prefix
,
plen
))
continue
;
continue
;
if
(
routes
[
i
].
time
<
now
.
tv_sec
-
route
_timeout_delay
)
if
(
routes
[
i
].
time
<
now
.
tv_sec
-
route
s
[
i
].
hold_time
)
continue
;
continue
;
if
(
feasible
&&
!
route_feasible
(
&
routes
[
i
]))
if
(
feasible
&&
!
route_feasible
(
&
routes
[
i
]))
continue
;
continue
;
...
@@ -287,7 +285,7 @@ update_route_metric(struct route *route)
...
@@ -287,7 +285,7 @@ update_route_metric(struct route *route)
int
newmetric
;
int
newmetric
;
oldmetric
=
route
->
metric
;
oldmetric
=
route
->
metric
;
if
(
route
->
time
<
now
.
tv_sec
-
route
_timeout_delay
)
{
if
(
route
->
time
<
now
.
tv_sec
-
route
->
hold_time
)
{
if
(
route
->
refmetric
<
INFINITY
)
{
if
(
route
->
refmetric
<
INFINITY
)
{
route
->
seqno
=
seqno_plus
(
route
->
src
->
seqno
,
1
);
route
->
seqno
=
seqno_plus
(
route
->
src
->
seqno
,
1
);
route
->
refmetric
=
INFINITY
;
route
->
refmetric
=
INFINITY
;
...
@@ -334,12 +332,17 @@ update_network_metric(struct network *net)
...
@@ -334,12 +332,17 @@ update_network_metric(struct network *net)
struct
route
*
struct
route
*
update_route
(
const
unsigned
char
*
a
,
const
unsigned
char
*
p
,
unsigned
char
plen
,
update_route
(
const
unsigned
char
*
a
,
const
unsigned
char
*
p
,
unsigned
char
plen
,
unsigned
short
seqno
,
unsigned
short
refmetric
,
unsigned
short
seqno
,
unsigned
short
refmetric
,
unsigned
short
interval
,
struct
neighbour
*
neigh
,
const
unsigned
char
*
nexthop
)
struct
neighbour
*
neigh
,
const
unsigned
char
*
nexthop
)
{
{
struct
route
*
route
;
struct
route
*
route
;
struct
source
*
src
;
struct
source
*
src
;
int
metric
,
feasible
;
int
metric
,
feasible
;
int
add_metric
;
int
add_metric
;
int
hold_time
=
MAX
((
4
*
interval
)
/
100
+
interval
/
50
,
15
);
if
(
memcmp
(
a
,
myid
,
8
)
==
0
)
return
NULL
;
if
(
martian_prefix
(
p
,
plen
))
{
if
(
martian_prefix
(
p
,
plen
))
{
fprintf
(
stderr
,
"Rejecting martian route to %s through %s.
\n
"
,
fprintf
(
stderr
,
"Rejecting martian route to %s through %s.
\n
"
,
...
@@ -395,6 +398,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
...
@@ -395,6 +398,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
route
->
seqno
=
seqno
;
route
->
seqno
=
seqno
;
route
->
refmetric
=
refmetric
;
route
->
refmetric
=
refmetric
;
change_route_metric
(
route
,
metric
);
change_route_metric
(
route
,
metric
);
route
->
hold_time
=
hold_time
;
if
(
feasible
)
if
(
feasible
)
route_changed
(
route
,
oldsrc
,
oldmetric
);
route_changed
(
route
,
oldsrc
,
oldmetric
);
...
@@ -430,6 +434,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
...
@@ -430,6 +434,7 @@ update_route(const unsigned char *a, const unsigned char *p, unsigned char plen,
route
->
neigh
=
neigh
;
route
->
neigh
=
neigh
;
memcpy
(
route
->
nexthop
,
nexthop
,
16
);
memcpy
(
route
->
nexthop
,
nexthop
,
16
);
route
->
time
=
now
.
tv_sec
;
route
->
time
=
now
.
tv_sec
;
route
->
hold_time
=
hold_time
;
route
->
installed
=
0
;
route
->
installed
=
0
;
numroutes
++
;
numroutes
++
;
local_notify_route
(
route
,
LOCAL_ADD
);
local_notify_route
(
route
,
LOCAL_ADD
);
...
@@ -638,7 +643,7 @@ expire_routes(void)
...
@@ -638,7 +643,7 @@ expire_routes(void)
struct
route
*
route
=
&
routes
[
i
];
struct
route
*
route
=
&
routes
[
i
];
if
(
route
->
time
>
now
.
tv_sec
||
/* clock stepped */
if
(
route
->
time
>
now
.
tv_sec
||
/* clock stepped */
route
->
time
<
now
.
tv_sec
-
route
_gc_delay
)
{
route
->
time
<
now
.
tv_sec
-
route
->
hold_time
-
20
)
{
flush_route
(
route
);
flush_route
(
route
);
continue
;
continue
;
}
}
...
@@ -646,7 +651,7 @@ expire_routes(void)
...
@@ -646,7 +651,7 @@ expire_routes(void)
update_route_metric
(
route
);
update_route_metric
(
route
);
if
(
route
->
installed
&&
route
->
refmetric
<
INFINITY
)
{
if
(
route
->
installed
&&
route
->
refmetric
<
INFINITY
)
{
if
(
route
->
time
<
now
.
tv_sec
-
MAX
(
10
,
route_timeout_delay
*
7
/
8
)
)
if
(
route
->
time
<
now
.
tv_sec
-
route
->
hold_time
*
7
/
8
)
send_unicast_request
(
route
->
neigh
,
send_unicast_request
(
route
->
neigh
,
route
->
src
->
prefix
,
route
->
src
->
plen
);
route
->
src
->
prefix
,
route
->
src
->
plen
);
}
}
...
...
route.h
View file @
eb1ac22c
...
@@ -28,14 +28,13 @@ struct route {
...
@@ -28,14 +28,13 @@ struct route {
struct
neighbour
*
neigh
;
struct
neighbour
*
neigh
;
unsigned
char
nexthop
[
16
];
unsigned
char
nexthop
[
16
];
time_t
time
;
time_t
time
;
int
installed
;
unsigned
short
hold_time
;
/* in seconds */
short
installed
;
};
};
extern
struct
route
*
routes
;
extern
struct
route
*
routes
;
extern
int
numroutes
,
maxroutes
;
extern
int
numroutes
,
maxroutes
;
extern
unsigned
kernel_metric
;
extern
unsigned
kernel_metric
;
extern
int
route_timeout_delay
;
extern
int
route_gc_delay
;
struct
route
*
find_route
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
struct
route
*
find_route
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
struct
neighbour
*
neigh
,
const
unsigned
char
*
nexthop
);
struct
neighbour
*
neigh
,
const
unsigned
char
*
nexthop
);
...
@@ -61,7 +60,7 @@ void update_route_metric(struct route *route);
...
@@ -61,7 +60,7 @@ void update_route_metric(struct route *route);
struct
route
*
update_route
(
const
unsigned
char
*
a
,
struct
route
*
update_route
(
const
unsigned
char
*
a
,
const
unsigned
char
*
p
,
unsigned
char
plen
,
const
unsigned
char
*
p
,
unsigned
char
plen
,
unsigned
short
seqno
,
unsigned
short
refmetric
,
unsigned
short
seqno
,
unsigned
short
refmetric
,
struct
neighbour
*
neigh
,
unsigned
short
interval
,
struct
neighbour
*
neigh
,
const
unsigned
char
*
nexthop
);
const
unsigned
char
*
nexthop
);
void
retract_neighbour_routes
(
struct
neighbour
*
neigh
);
void
retract_neighbour_routes
(
struct
neighbour
*
neigh
);
void
send_unfeasible_request
(
struct
neighbour
*
neigh
,
int
force
,
void
send_unfeasible_request
(
struct
neighbour
*
neigh
,
int
force
,
...
...
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