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
a28b52a5
Commit
a28b52a5
authored
Mar 09, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor check_xroutes to treat redistributed and local routes identically.
parent
33318259
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
49 deletions
+15
-49
xroute.c
xroute.c
+14
-47
xroute.h
xroute.h
+1
-2
No files found.
xroute.c
View file @
a28b52a5
...
...
@@ -103,25 +103,27 @@ check_xroutes()
{
int
i
,
j
,
metric
,
export
,
change
=
0
,
rc
;
struct
kernel_route
routes
[
240
];
struct
kernel_route
addresses
[
240
];
int
numroutes
,
numaddr
;
int
numroutes
;
debugf
(
"
\n
Checking kernel routes.
\n
"
);
rc
=
kernel_addresses
(
address
es
,
240
);
rc
=
kernel_addresses
(
rout
es
,
240
);
if
(
rc
<
0
)
{
fprintf
(
stderr
,
"Couldn't get local addresses.
\n
"
);
num
addr
=
0
;
num
routes
=
0
;
}
else
{
num
addr
=
rc
;
num
routes
=
rc
;
}
rc
=
kernel_routes
(
routes
,
240
);
if
(
numroutes
<=
240
)
{
rc
=
kernel_routes
(
routes
+
numroutes
,
240
-
numroutes
);
if
(
rc
<
0
)
{
fprintf
(
stderr
,
"Couldn't get kernel routes.
\n
"
);
numroutes
=
0
;
}
else
{
numroutes
=
rc
;
numroutes
+=
rc
;
}
}
else
{
fprintf
(
stderr
,
"Too many local ddresses -- ignoring kernel routes.
\n
"
);
}
/* Check for any routes that need to be flushed */
...
...
@@ -131,25 +133,6 @@ check_xroutes()
export
=
0
;
if
(
xroutes
[
i
].
kind
==
XROUTE_FORCED
)
{
export
=
1
;
}
else
if
(
xroutes
[
i
].
kind
==
XROUTE_LOCAL
)
{
metric
=
redistribute_filter
(
xroutes
[
i
].
prefix
,
xroutes
[
i
].
plen
,
xroutes
[
i
].
ifindex
,
RTPROT_BABEL_LOCAL
);
if
(
metric
==
METRIC_INHERIT
)
metric
=
0
;
if
(
metric
<
INFINITY
&&
metric
==
xroutes
[
i
].
metric
)
{
for
(
j
=
0
;
j
<
numaddr
;
j
++
)
{
if
(
xroutes
[
i
].
plen
==
addresses
[
j
].
plen
&&
memcmp
(
xroutes
[
i
].
prefix
,
addresses
[
j
].
prefix
,
128
)
==
0
&&
xroutes
[
i
].
ifindex
==
addresses
[
j
].
ifindex
)
{
if
(
metric
<
INFINITY
)
{
export
=
1
;
break
;
}
}
}
}
}
else
if
(
xroutes
[
i
].
kind
==
XROUTE_REDISTRIBUTED
)
{
metric
=
redistribute_filter
(
xroutes
[
i
].
prefix
,
xroutes
[
i
].
plen
,
xroutes
[
i
].
ifindex
,
xroutes
[
i
].
proto
);
...
...
@@ -164,7 +147,7 @@ check_xroutes()
export
=
1
;
break
;
}
else
if
(
metric
==
METRIC_INHERIT
&&
xroutes
[
i
].
metric
==
routes
[
j
].
metric
)
{
xroutes
[
i
].
metric
==
routes
[
j
].
metric
*
256
)
{
export
=
1
;
break
;
}
...
...
@@ -183,29 +166,13 @@ check_xroutes()
/* Add any new routes */
for
(
i
=
0
;
i
<
numaddr
;
i
++
)
{
if
(
martian_prefix
(
addresses
[
i
].
prefix
,
addresses
[
i
].
plen
))
continue
;
metric
=
redistribute_filter
(
addresses
[
i
].
prefix
,
addresses
[
i
].
plen
,
addresses
[
i
].
ifindex
,
RTPROT_BABEL_LOCAL
);
if
(
metric
==
METRIC_INHERIT
)
metric
=
0
;
if
(
metric
<
INFINITY
)
{
rc
=
add_xroute
(
XROUTE_LOCAL
,
addresses
[
i
].
prefix
,
addresses
[
i
].
plen
,
0
,
addresses
[
i
].
ifindex
,
RTPROT_BABEL_LOCAL
);
if
(
rc
)
change
=
1
;
}
}
for
(
i
=
0
;
i
<
numroutes
;
i
++
)
{
if
(
martian_prefix
(
routes
[
i
].
prefix
,
routes
[
i
].
plen
))
continue
;
metric
=
redistribute_filter
(
routes
[
i
].
prefix
,
routes
[
i
].
plen
,
routes
[
i
].
ifindex
,
routes
[
i
].
proto
);
if
(
metric
==
METRIC_INHERIT
)
metric
=
routes
[
i
].
metric
;
metric
=
routes
[
i
].
metric
*
256
;
if
(
metric
<
INFINITY
)
{
rc
=
add_xroute
(
XROUTE_REDISTRIBUTED
,
routes
[
i
].
prefix
,
routes
[
i
].
plen
,
...
...
xroute.h
View file @
a28b52a5
...
...
@@ -25,8 +25,7 @@ int check_xroutes(void);
/* These should come in decreasing order of priority. */
#define XROUTE_FORCED 1
#define XROUTE_LOCAL 2
#define XROUTE_REDISTRIBUTED 3
#define XROUTE_REDISTRIBUTED 2
struct
xroute
{
unsigned
char
prefix
[
16
];
...
...
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