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
90fc2cbf
Commit
90fc2cbf
authored
Apr 23, 2019
by
Killian Lufau
Committed by
Juliusz Chroboczek
Jun 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor find_table and calls to kernel_route.
This is only a cleanup and not a functional change
parent
f8bce04c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
32 deletions
+34
-32
disambiguation.c
disambiguation.c
+33
-27
rule.c
rule.c
+1
-5
No files found.
disambiguation.c
View file @
90fc2cbf
...
...
@@ -36,8 +36,9 @@ THE SOFTWARE.
#include "route.h"
#include "source.h"
#include "neighbour.h"
#include "rule.h"
#include "disambiguation.h"
#include "configuration.h"
#include "rule.h"
struct
zone
{
const
unsigned
char
*
dst_prefix
;
...
...
@@ -214,55 +215,60 @@ is_installed(struct zone *zone)
}
static
int
add_route
(
const
struct
zone
*
zone
,
const
struct
babel_route
*
route
)
change_route
(
int
operation
,
const
struct
zone
*
zone
,
const
struct
babel_route
*
route
,
int
metric
,
const
unsigned
char
*
new_next_hop
,
int
new_ifindex
,
int
new_metric
)
{
int
table
=
find_table
(
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
);
return
kernel_route
(
ROUTE_ADD
,
table
,
zone
->
dst_prefix
,
zone
->
dst_plen
,
struct
filter_result
filter_result
;
unsigned
int
ifindex
=
route
->
neigh
->
ifp
->
ifindex
;
install_filter
(
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
,
&
filter_result
);
int
table
=
filter_result
.
table
?
filter_result
.
table
:
find_table
(
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
);
return
kernel_route
(
operation
,
table
,
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
,
route
->
nexthop
,
route
->
neigh
->
ifp
->
ifindex
,
metric_to_kernel
(
route_metric
(
route
)),
NULL
,
0
,
0
,
0
);
route
->
nexthop
,
ifindex
,
metric
,
new_next_hop
,
new_ifindex
,
new_metric
,
operation
==
ROUTE_MODIFY
?
table
:
0
);
}
static
int
add_route
(
const
struct
zone
*
zone
,
const
struct
babel_route
*
route
)
{
return
change_route
(
ROUTE_ADD
,
zone
,
route
,
metric_to_kernel
(
route_metric
(
route
)),
NULL
,
0
,
0
);
}
static
int
del_route
(
const
struct
zone
*
zone
,
const
struct
babel_route
*
route
)
{
int
table
=
find_table
(
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
);
return
kernel_route
(
ROUTE_FLUSH
,
table
,
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
,
route
->
nexthop
,
route
->
neigh
->
ifp
->
ifindex
,
metric_to_kernel
(
route_metric
(
route
)),
NULL
,
0
,
0
,
0
);
return
change_route
(
ROUTE_FLUSH
,
zone
,
route
,
metric_to_kernel
(
route_metric
(
route
)),
NULL
,
0
,
0
);
}
static
int
chg_route
(
const
struct
zone
*
zone
,
const
struct
babel_route
*
old
,
const
struct
babel_route
*
new
)
{
int
table
=
find_table
(
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
);
return
kernel_route
(
ROUTE_MODIFY
,
table
,
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
,
old
->
nexthop
,
old
->
neigh
->
ifp
->
ifindex
,
return
change_route
(
ROUTE_MODIFY
,
zone
,
old
,
metric_to_kernel
(
route_metric
(
old
)),
new
->
nexthop
,
new
->
neigh
->
ifp
->
ifindex
,
metric_to_kernel
(
route_metric
(
new
))
,
table
);
metric_to_kernel
(
route_metric
(
new
)));
}
static
int
chg_route_metric
(
const
struct
zone
*
zone
,
const
struct
babel_route
*
route
,
int
old_metric
,
int
new_metric
)
{
int
table
=
find_table
(
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
);
return
kernel_route
(
ROUTE_MODIFY
,
table
,
zone
->
dst_prefix
,
zone
->
dst_plen
,
zone
->
src_prefix
,
zone
->
src_plen
,
route
->
nexthop
,
route
->
neigh
->
ifp
->
ifindex
,
return
change_route
(
ROUTE_MODIFY
,
zone
,
route
,
old_metric
,
route
->
nexthop
,
route
->
neigh
->
ifp
->
ifindex
,
new_metric
,
table
);
new_metric
);
}
int
...
...
rule.c
View file @
90fc2cbf
...
...
@@ -178,14 +178,10 @@ int
find_table
(
const
unsigned
char
*
dest
,
unsigned
short
plen
,
const
unsigned
char
*
src
,
unsigned
short
src_plen
)
{
struct
filter_result
filter_result
=
{
0
};
struct
rule
*
kr
=
NULL
;
int
i
,
found
;
install_filter
(
dest
,
plen
,
src
,
src_plen
,
&
filter_result
);
if
(
filter_result
.
table
)
{
return
filter_result
.
table
;
}
else
if
(
is_default
(
src
,
src_plen
))
{
if
(
is_default
(
src
,
src_plen
))
{
return
export_table
;
}
else
if
(
kernel_disambiguate
(
v4mapped
(
dest
)))
{
return
export_table
;
...
...
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