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
7f82d0e1
Commit
7f82d0e1
authored
Mar 09, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for local xroutes.
parent
17fae294
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
10 deletions
+26
-10
babel.c
babel.c
+2
-2
xroute.c
xroute.c
+15
-7
xroute.h
xroute.h
+9
-1
No files found.
babel.c
View file @
7f82d0e1
...
@@ -154,7 +154,7 @@ main(int argc, char **argv)
...
@@ -154,7 +154,7 @@ main(int argc, char **argv)
goto
syntax
;
goto
syntax
;
xroutes
[
numxroutes
].
metric
=
metric
;
xroutes
[
numxroutes
].
metric
=
metric
;
}
}
xroutes
[
numxroutes
].
forced
=
1
;
xroutes
[
numxroutes
].
kind
=
XROUTE_FORCED
;
xroutes
[
numxroutes
].
ifindex
=
0
;
xroutes
[
numxroutes
].
ifindex
=
0
;
numxroutes
++
;
numxroutes
++
;
}
else
if
(
strcmp
(
*
arg
,
"-h"
)
==
0
)
{
}
else
if
(
strcmp
(
*
arg
,
"-h"
)
==
0
)
{
...
@@ -731,7 +731,7 @@ dump_tables(FILE *out)
...
@@ -731,7 +731,7 @@ dump_tables(FILE *out)
fprintf
(
out
,
"%s metric %d (%s)
\n
"
,
fprintf
(
out
,
"%s metric %d (%s)
\n
"
,
format_prefix
(
xroutes
[
i
].
prefix
,
xroutes
[
i
].
plen
),
format_prefix
(
xroutes
[
i
].
prefix
,
xroutes
[
i
].
plen
),
xroutes
[
i
].
metric
,
xroutes
[
i
].
metric
,
xroutes
[
i
].
forced
?
"forced"
:
"exported"
);
xroutes
[
i
].
kind
==
XROUTE_FORCED
?
"forced"
:
"exported"
);
}
}
for
(
i
=
0
;
i
<
numroutes
;
i
++
)
{
for
(
i
=
0
;
i
<
numroutes
;
i
++
)
{
int
id
=
int
id
=
...
...
xroute.c
View file @
7f82d0e1
...
@@ -67,14 +67,20 @@ flush_xroute(struct xroute *xroute)
...
@@ -67,14 +67,20 @@ flush_xroute(struct xroute *xroute)
}
}
int
int
add_xroute
(
unsigned
char
prefix
[
16
],
unsigned
char
plen
,
add_xroute
(
int
kind
,
unsigned
char
prefix
[
16
],
unsigned
char
plen
,
unsigned
short
metric
,
unsigned
int
ifindex
,
int
proto
)
unsigned
short
metric
,
unsigned
int
ifindex
,
int
proto
)
{
{
struct
xroute
*
xroute
=
find_xroute
(
prefix
,
plen
);
struct
xroute
*
xroute
=
find_xroute
(
prefix
,
plen
);
if
(
xroute
)
{
if
(
xroute
)
{
if
(
xroute
->
metric
<=
metric
)
if
(
xroute
->
kind
<
kind
)
return
0
;
return
0
;
if
(
xroute
->
forced
)
else
if
(
xroute
->
kind
>
kind
)
{
flush_xroute
(
xroute
);
return
add_xroute
(
kind
,
prefix
,
plen
,
metric
,
ifindex
,
proto
);
}
if
(
xroute
->
metric
<=
metric
)
return
0
;
return
0
;
xroute
->
metric
=
metric
;
xroute
->
metric
=
metric
;
return
1
;
return
1
;
...
@@ -83,9 +89,9 @@ add_xroute(unsigned char prefix[16], unsigned char plen,
...
@@ -83,9 +89,9 @@ add_xroute(unsigned char prefix[16], unsigned char plen,
if
(
numxroutes
>=
MAXXROUTES
)
if
(
numxroutes
>=
MAXXROUTES
)
return
-
1
;
return
-
1
;
xroutes
[
numxroutes
].
kind
=
kind
;
memcpy
(
xroutes
[
numxroutes
].
prefix
,
prefix
,
16
);
memcpy
(
xroutes
[
numxroutes
].
prefix
,
prefix
,
16
);
xroutes
[
numxroutes
].
plen
=
plen
;
xroutes
[
numxroutes
].
plen
=
plen
;
xroutes
[
numxroutes
].
forced
=
0
;
xroutes
[
numxroutes
].
metric
=
metric
;
xroutes
[
numxroutes
].
metric
=
metric
;
xroutes
[
numxroutes
].
ifindex
=
ifindex
;
xroutes
[
numxroutes
].
ifindex
=
ifindex
;
xroutes
[
numxroutes
].
proto
=
proto
;
xroutes
[
numxroutes
].
proto
=
proto
;
...
@@ -107,7 +113,7 @@ check_xroutes()
...
@@ -107,7 +113,7 @@ check_xroutes()
i
=
0
;
i
=
0
;
while
(
i
<
numxroutes
)
{
while
(
i
<
numxroutes
)
{
if
(
xroutes
[
i
].
forced
)
{
if
(
xroutes
[
i
].
kind
!=
XROUTE_REDISTRIBUTED
)
{
i
++
;
i
++
;
continue
;
continue
;
}
}
...
@@ -146,7 +152,8 @@ check_xroutes()
...
@@ -146,7 +152,8 @@ check_xroutes()
if
(
metric
==
METRIC_INHERIT
)
if
(
metric
==
METRIC_INHERIT
)
metric
=
routes
[
i
].
metric
;
metric
=
routes
[
i
].
metric
;
if
(
metric
<
INFINITY
)
{
if
(
metric
<
INFINITY
)
{
rc
=
add_xroute
(
routes
[
i
].
prefix
,
routes
[
i
].
plen
,
rc
=
add_xroute
(
XROUTE_REDISTRIBUTED
,
routes
[
i
].
prefix
,
routes
[
i
].
plen
,
metric
,
routes
[
i
].
ifindex
,
routes
[
i
].
proto
);
metric
,
routes
[
i
].
ifindex
,
routes
[
i
].
proto
);
if
(
rc
)
if
(
rc
)
change
=
1
;
change
=
1
;
...
@@ -169,7 +176,8 @@ check_addresses()
...
@@ -169,7 +176,8 @@ check_addresses()
if
(
rc
<
0
)
if
(
rc
<
0
)
break
;
break
;
for
(
i
=
0
;
i
<
rc
&&
numxroutes
<
MAXXROUTES
;
i
++
)
{
for
(
i
=
0
;
i
<
rc
&&
numxroutes
<
MAXXROUTES
;
i
++
)
{
rc
=
add_xroute
(
addresses
[
i
].
s6_addr
,
128
,
0
,
nets
[
i
].
ifindex
,
rc
=
add_xroute
(
XROUTE_LOCAL
,
addresses
[
i
].
s6_addr
,
128
,
0
,
nets
[
i
].
ifindex
,
RTPROTO_BABEL_LOCAL
);
RTPROTO_BABEL_LOCAL
);
if
(
rc
<
0
)
if
(
rc
<
0
)
break
;
break
;
...
...
xroute.h
View file @
7f82d0e1
...
@@ -23,10 +23,16 @@ THE SOFTWARE.
...
@@ -23,10 +23,16 @@ THE SOFTWARE.
int
check_xroutes
(
void
);
int
check_xroutes
(
void
);
int
check_addresses
(
void
);
int
check_addresses
(
void
);
/* These should come in decreasing order of priority. */
#define XROUTE_FORCED 1
#define XROUTE_LOCAL 2
#define XROUTE_REDISTRIBUTED 3
struct
xroute
{
struct
xroute
{
unsigned
char
prefix
[
16
];
unsigned
char
prefix
[
16
];
unsigned
char
plen
;
unsigned
char
plen
;
char
force
d
;
char
kin
d
;
unsigned
short
metric
;
unsigned
short
metric
;
unsigned
int
ifindex
;
unsigned
int
ifindex
;
int
proto
;
int
proto
;
...
@@ -36,4 +42,6 @@ extern struct xroute xroutes[MAXXROUTES];
...
@@ -36,4 +42,6 @@ extern struct xroute xroutes[MAXXROUTES];
extern
int
numxroutes
;
extern
int
numxroutes
;
struct
xroute
*
find_xroute
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
);
struct
xroute
*
find_xroute
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
);
int
add_xroute
(
int
kind
,
unsigned
char
prefix
[
16
],
unsigned
char
plen
,
unsigned
short
metric
,
unsigned
int
ifindex
,
int
proto
);
int
check_xroutes
(
void
);
int
check_xroutes
(
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