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
c96af640
Commit
c96af640
authored
Jun 04, 2015
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the interface to prefix_cmp.
parent
9f6b430b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
15 deletions
+14
-15
disambiguation.c
disambiguation.c
+9
-9
kernel_netlink.c
kernel_netlink.c
+1
-2
util.h
util.h
+4
-4
No files found.
disambiguation.c
View file @
c96af640
...
@@ -49,15 +49,15 @@ rt_cmp(const struct babel_route *rt1, const struct babel_route *rt2)
...
@@ -49,15 +49,15 @@ rt_cmp(const struct babel_route *rt1, const struct babel_route *rt2)
enum
prefix_status
dst_st
,
src_st
;
enum
prefix_status
dst_st
,
src_st
;
const
struct
source
*
r1
=
rt1
->
src
,
*
r2
=
rt2
->
src
;
const
struct
source
*
r1
=
rt1
->
src
,
*
r2
=
rt2
->
src
;
dst_st
=
prefix_cmp
(
r1
->
prefix
,
r1
->
plen
,
r2
->
prefix
,
r2
->
plen
);
dst_st
=
prefix_cmp
(
r1
->
prefix
,
r1
->
plen
,
r2
->
prefix
,
r2
->
plen
);
if
(
dst_st
&
PST_MORE_SPECIFIC
)
if
(
dst_st
==
PST_MORE_SPECIFIC
)
return
-
1
;
return
-
1
;
else
if
(
dst_st
&
PST_LESS_SPECIFIC
)
else
if
(
dst_st
==
PST_LESS_SPECIFIC
)
return
1
;
return
1
;
src_st
=
prefix_cmp
(
r1
->
src_prefix
,
r1
->
src_plen
,
src_st
=
prefix_cmp
(
r1
->
src_prefix
,
r1
->
src_plen
,
r2
->
src_prefix
,
r2
->
src_plen
);
r2
->
src_prefix
,
r2
->
src_plen
);
if
(
src_st
&
PST_MORE_SPECIFIC
)
if
(
src_st
==
PST_MORE_SPECIFIC
)
return
-
1
;
return
-
1
;
else
if
(
src_st
&
PST_LESS_SPECIFIC
)
else
if
(
src_st
==
PST_LESS_SPECIFIC
)
return
1
;
return
1
;
return
0
;
return
0
;
}
}
...
@@ -78,7 +78,7 @@ conflicts(const struct babel_route *rt, const struct babel_route *rt1)
...
@@ -78,7 +78,7 @@ conflicts(const struct babel_route *rt, const struct babel_route *rt1)
enum
prefix_status
dst_st
,
src_st
;
enum
prefix_status
dst_st
,
src_st
;
const
struct
source
*
r
=
rt
->
src
,
*
r1
=
rt1
->
src
;
const
struct
source
*
r
=
rt
->
src
,
*
r1
=
rt1
->
src
;
dst_st
=
prefix_cmp
(
r
->
prefix
,
r
->
plen
,
r1
->
prefix
,
r1
->
plen
);
dst_st
=
prefix_cmp
(
r
->
prefix
,
r
->
plen
,
r1
->
prefix
,
r1
->
plen
);
if
(
dst_st
&
(
PST_DISJOINT
|
PST_EQUALS
)
)
if
(
dst_st
==
PST_DISJOINT
||
dst_st
==
PST_EQUALS
)
return
0
;
return
0
;
src_st
=
prefix_cmp
(
r
->
src_prefix
,
r
->
src_plen
,
src_st
=
prefix_cmp
(
r
->
src_prefix
,
r
->
src_plen
,
r1
->
src_prefix
,
r1
->
src_plen
);
r1
->
src_prefix
,
r1
->
src_plen
);
...
@@ -105,20 +105,20 @@ inter(const struct babel_route *rt, const struct babel_route *rt1,
...
@@ -105,20 +105,20 @@ inter(const struct babel_route *rt, const struct babel_route *rt1,
enum
prefix_status
dst_st
,
src_st
;
enum
prefix_status
dst_st
,
src_st
;
const
struct
source
*
r
=
rt
->
src
,
*
r1
=
rt1
->
src
;
const
struct
source
*
r
=
rt
->
src
,
*
r1
=
rt1
->
src
;
dst_st
=
prefix_cmp
(
r
->
prefix
,
r
->
plen
,
r1
->
prefix
,
r1
->
plen
);
dst_st
=
prefix_cmp
(
r
->
prefix
,
r
->
plen
,
r1
->
prefix
,
r1
->
plen
);
if
(
dst_st
&
PST_DISJOINT
)
if
(
dst_st
==
PST_DISJOINT
)
return
NULL
;
return
NULL
;
src_st
=
prefix_cmp
(
r
->
src_prefix
,
r
->
src_plen
,
src_st
=
prefix_cmp
(
r
->
src_prefix
,
r
->
src_plen
,
r1
->
src_prefix
,
r1
->
src_plen
);
r1
->
src_prefix
,
r1
->
src_plen
);
if
(
src_st
&
PST_DISJOINT
)
if
(
src_st
==
PST_DISJOINT
)
return
NULL
;
return
NULL
;
if
(
dst_st
&
(
PST_MORE_SPECIFIC
|
PST_EQUALS
)
)
{
if
(
dst_st
==
PST_MORE_SPECIFIC
||
dst_st
==
PST_EQUALS
)
{
zone
->
dst_prefix
=
r
->
prefix
;
zone
->
dst_prefix
=
r
->
prefix
;
zone
->
dst_plen
=
r
->
plen
;
zone
->
dst_plen
=
r
->
plen
;
}
else
{
}
else
{
zone
->
dst_prefix
=
r1
->
prefix
;
zone
->
dst_prefix
=
r1
->
prefix
;
zone
->
dst_plen
=
r1
->
plen
;
zone
->
dst_plen
=
r1
->
plen
;
}
}
if
(
src_st
&
(
PST_MORE_SPECIFIC
|
PST_EQUALS
)
)
{
if
(
src_st
==
PST_MORE_SPECIFIC
||
src_st
==
PST_EQUALS
)
{
zone
->
src_prefix
=
r
->
src_prefix
;
zone
->
src_prefix
=
r
->
src_prefix
;
zone
->
src_plen
=
r
->
src_plen
;
zone
->
src_plen
=
r
->
src_plen
;
}
else
{
}
else
{
...
...
kernel_netlink.c
View file @
c96af640
...
@@ -1961,8 +1961,7 @@ filter_kernel_rules(struct nlmsghdr *nh, void *data)
...
@@ -1961,8 +1961,7 @@ filter_kernel_rules(struct nlmsghdr *nh, void *data)
return
1
;
return
1
;
if
(
prefix_cmp
(
src
,
src_plen
,
if
(
prefix_cmp
(
src
,
src_plen
,
kernel_tables
[
i
].
src
,
kernel_tables
[
i
].
plen
)
kernel_tables
[
i
].
src
,
kernel_tables
[
i
].
plen
)
==
PST_EQUALS
&&
==
PST_EQUALS
&&
table
==
kernel_tables
[
i
].
table
&&
table
==
kernel_tables
[
i
].
table
&&
!
rule_exists
[
i
])
{
!
rule_exists
[
i
])
{
rule_exists
[
i
]
=
1
;
rule_exists
[
i
]
=
1
;
...
...
util.h
View file @
c96af640
...
@@ -114,10 +114,10 @@ int daemonise(void);
...
@@ -114,10 +114,10 @@ int daemonise(void);
int
set_src_prefix
(
unsigned
char
*
src_addr
,
unsigned
char
*
src_plen
);
int
set_src_prefix
(
unsigned
char
*
src_addr
,
unsigned
char
*
src_plen
);
enum
prefix_status
{
enum
prefix_status
{
PST_
DISJOINT
=
1
<<
0
,
PST_
EQUALS
=
0
,
PST_
EQUALS
=
1
<<
1
,
PST_
DISJOINT
,
PST_MORE_SPECIFIC
=
1
<<
2
,
PST_MORE_SPECIFIC
,
PST_LESS_SPECIFIC
=
1
<<
3
PST_LESS_SPECIFIC
};
};
enum
prefix_status
enum
prefix_status
prefix_cmp
(
const
unsigned
char
*
p1
,
unsigned
char
plen1
,
prefix_cmp
(
const
unsigned
char
*
p1
,
unsigned
char
plen1
,
...
...
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