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
9450e4d3
Commit
9450e4d3
authored
Jun 04, 2007
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement -x and -X.
parent
a12be898
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
6 deletions
+73
-6
babel.c
babel.c
+12
-3
message.c
message.c
+2
-0
xroute.c
xroute.c
+58
-3
xroute.h
xroute.h
+1
-0
No files found.
babel.c
View file @
9450e4d3
...
@@ -125,7 +125,8 @@ main(int argc, char **argv)
...
@@ -125,7 +125,8 @@ main(int argc, char **argv)
}
else
if
(
strcmp
(
*
arg
,
"-p"
)
==
0
)
{
}
else
if
(
strcmp
(
*
arg
,
"-p"
)
==
0
)
{
SHIFTE
();
SHIFTE
();
protocol_port
=
atoi
(
*
arg
);
protocol_port
=
atoi
(
*
arg
);
}
else
if
(
strcmp
(
*
arg
,
"-n"
)
==
0
)
{
}
else
if
(
strcmp
(
*
arg
,
"-x"
)
==
0
||
strcmp
(
*
arg
,
"-X"
)
==
0
)
{
int
force
=
(
strcmp
(
*
arg
,
"-X"
)
==
0
);
if
(
nummyxroutes
>=
MAXMYXROUTES
)
{
if
(
nummyxroutes
>=
MAXMYXROUTES
)
{
fprintf
(
stderr
,
"Too many network routes.
\n
"
);
fprintf
(
stderr
,
"Too many network routes.
\n
"
);
exit
(
1
);
exit
(
1
);
...
@@ -144,6 +145,7 @@ main(int argc, char **argv)
...
@@ -144,6 +145,7 @@ main(int argc, char **argv)
if
(
myxroutes
[
nummyxroutes
].
cost
<
0
||
if
(
myxroutes
[
nummyxroutes
].
cost
<
0
||
myxroutes
[
nummyxroutes
].
cost
>
INFINITY
)
myxroutes
[
nummyxroutes
].
cost
>
INFINITY
)
goto
syntax
;
goto
syntax
;
myxroutes
[
nummyxroutes
].
installed
=
force
?
0
:
2
;
nummyxroutes
++
;
nummyxroutes
++
;
}
else
if
(
strcmp
(
*
arg
,
"-h"
)
==
0
)
{
}
else
if
(
strcmp
(
*
arg
,
"-h"
)
==
0
)
{
SHIFTE
();
SHIFTE
();
...
@@ -346,6 +348,7 @@ main(int argc, char **argv)
...
@@ -346,6 +348,7 @@ main(int argc, char **argv)
}
}
init_signals
();
init_signals
();
check_myxroutes
();
for
(
i
=
0
;
i
<
numnets
;
i
++
)
{
for
(
i
=
0
;
i
<
numnets
;
i
++
)
{
send_hello
(
&
nets
[
i
]);
send_hello
(
&
nets
[
i
]);
...
@@ -493,7 +496,7 @@ main(int argc, char **argv)
...
@@ -493,7 +496,7 @@ main(int argc, char **argv)
" "
" "
"[-u update_interval] [-k metric] [-s] [-P] [-c cost]
\n
"
"[-u update_interval] [-k metric] [-s] [-P] [-c cost]
\n
"
" "
" "
"[-d level] [-
n
net cost]... address interface...
\n
"
,
"[-d level] [-
x net cost] [-X
net cost]... address interface...
\n
"
,
argv
[
0
]);
argv
[
0
]);
exit
(
1
);
exit
(
1
);
...
@@ -625,7 +628,13 @@ add_network(char *ifname, int ifindex, int mtu,
...
@@ -625,7 +628,13 @@ add_network(char *ifname, int ifindex, int mtu,
void
void
expire_routes
(
void
)
expire_routes
(
void
)
{
{
int
i
;
int
rc
,
i
;
rc
=
check_myxroutes
();
if
(
rc
>
0
)
send_self_update
(
NULL
);
else
if
(
rc
<
0
)
fprintf
(
stderr
,
"Warning: couldn't check installed routes.
\n
"
);
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
for
(
i
=
0
;
i
<
numneighs
;
i
++
)
{
if
(
neighs
[
i
].
id
[
0
]
==
0
)
if
(
neighs
[
i
].
id
[
0
]
==
0
)
...
...
message.c
View file @
9450e4d3
...
@@ -359,6 +359,8 @@ flushupdates(void)
...
@@ -359,6 +359,8 @@ flushupdates(void)
if
(
buffered_updates
[
i
]
==
NULL
)
{
if
(
buffered_updates
[
i
]
==
NULL
)
{
start_message
(
net
,
MIN
(
20
+
20
*
nummyxroutes
,
1000
));
start_message
(
net
,
MIN
(
20
+
20
*
nummyxroutes
,
1000
));
for
(
j
=
0
;
j
<
nummyxroutes
;
j
++
)
{
for
(
j
=
0
;
j
<
nummyxroutes
;
j
++
)
{
if
(
!
myxroutes
[
j
].
installed
)
continue
;
if
(
net
->
bufsize
-
net
->
buffered
<
40
)
if
(
net
->
bufsize
-
net
->
buffered
<
40
)
/* We cannot just call start_message, as this would
/* We cannot just call start_message, as this would
split the xroutes from the update. Bail out
split the xroutes from the update. Bail out
...
...
xroute.c
View file @
9450e4d3
...
@@ -52,6 +52,20 @@ find_installed_xroute(unsigned char *prefix, unsigned short plen)
...
@@ -52,6 +52,20 @@ find_installed_xroute(unsigned char *prefix, unsigned short plen)
return
NULL
;
return
NULL
;
}
}
static
struct
xroute
*
find_installed_myxroute
(
unsigned
char
*
prefix
,
unsigned
short
plen
)
{
int
i
;
for
(
i
=
0
;
i
<
nummyxroutes
;
i
++
)
{
if
(
myxroutes
[
i
].
installed
&&
myxroutes
[
i
].
plen
==
plen
&&
memcmp
(
myxroutes
[
i
].
prefix
,
prefix
,
16
)
==
0
)
{
return
&
xroutes
[
i
];
}
}
return
NULL
;
}
static
struct
xroute
*
static
struct
xroute
*
find_best_xroute
(
unsigned
char
*
prefix
,
unsigned
short
plen
)
find_best_xroute
(
unsigned
char
*
prefix
,
unsigned
short
plen
)
{
{
...
@@ -146,9 +160,12 @@ consider_xroute(struct xroute *xroute)
...
@@ -146,9 +160,12 @@ consider_xroute(struct xroute *xroute)
if
(
find_installed_route
(
xroute
->
gateway
)
==
NULL
)
if
(
find_installed_route
(
xroute
->
gateway
)
==
NULL
)
return
;
return
;
installed
=
find_installed_myxroute
(
xroute
->
prefix
,
xroute
->
plen
);
if
(
!
installed
)
{
installed
=
find_installed_xroute
(
xroute
->
prefix
,
xroute
->
plen
);
installed
=
find_installed_xroute
(
xroute
->
prefix
,
xroute
->
plen
);
if
(
!
installed
||
installed
->
metric
>=
xroute
->
metric
)
if
(
!
installed
||
installed
->
metric
>=
xroute
->
metric
)
install_xroute
(
xroute
);
install_xroute
(
xroute
);
}
}
}
void
void
...
@@ -283,3 +300,41 @@ update_xroute_metric(struct xroute *xroute, int cost)
...
@@ -283,3 +300,41 @@ update_xroute_metric(struct xroute *xroute, int cost)
}
}
}
}
}
}
int
check_myxroutes
()
{
int
i
,
j
,
n
,
change
;
struct
kernel_route
routes
[
120
];
n
=
-
1
;
for
(
i
=
0
;
i
<
nummyxroutes
;
i
++
)
if
(
myxroutes
[
i
].
installed
<
2
)
n
=
MAX
(
n
,
myxroutes
[
i
].
plen
);
if
(
n
<
0
)
return
0
;
n
=
kernel_routes
(
n
,
routes
,
120
);
if
(
n
<
0
)
return
-
1
;
change
=
0
;
for
(
i
=
0
;
i
<
nummyxroutes
;
i
++
)
{
int
installed
;
if
(
myxroutes
[
i
].
installed
==
2
)
continue
;
installed
=
0
;
for
(
j
=
0
;
j
<
n
;
j
++
)
{
if
(
routes
[
j
].
plen
==
myxroutes
[
i
].
plen
&&
memcmp
(
routes
[
j
].
prefix
,
myxroutes
[
i
].
prefix
,
16
)
==
0
)
{
installed
=
1
;
break
;
}
}
if
(
myxroutes
[
i
].
installed
!=
installed
)
{
myxroutes
[
i
].
installed
=
installed
;
change
=
1
;
}
}
return
change
;
}
xroute.h
View file @
9450e4d3
...
@@ -47,3 +47,4 @@ void flush_xroutes(struct destination *gateway,
...
@@ -47,3 +47,4 @@ void flush_xroutes(struct destination *gateway,
struct
xroute
*
update_xroute
(
const
unsigned
char
*
prefix
,
unsigned
short
plen
,
struct
xroute
*
update_xroute
(
const
unsigned
char
*
prefix
,
unsigned
short
plen
,
struct
destination
*
gateway
,
int
cost
);
struct
destination
*
gateway
,
int
cost
);
void
update_xroute_metric
(
struct
xroute
*
xroute
,
int
cost
);
void
update_xroute_metric
(
struct
xroute
*
xroute
,
int
cost
);
int
check_myxroutes
(
void
);
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