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
a12be898
Commit
a12be898
authored
Jun 04, 2007
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement kernel_routes.
parent
d231dae8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
kernel.c
kernel.c
+50
-0
kernel.h
kernel.h
+9
-0
No files found.
kernel.c
View file @
a12be898
...
...
@@ -33,7 +33,9 @@ THE SOFTWARE.
#include <net/route.h>
#include <net/if.h>
#include "babel.h"
#include "kernel.h"
#include "util.h"
static
int
old_forwarding
=
-
1
;
static
int
old_accept_redirects
=
-
1
;
...
...
@@ -241,3 +243,51 @@ kernel_route(int add, const unsigned char *dest, unsigned short plen,
return
-
1
;
return
1
;
}
/* This function should not return routes installed by us. It currently
does, which could lead to routing loops in some cases. */
int
kernel_routes
(
int
maxplen
,
struct
kernel_route
*
routes
,
int
maxroutes
)
{
FILE
*
f
;
char
dst
[
33
],
src
[
33
],
gw
[
33
],
iface
[
IF_NAMESIZE
];
unsigned
int
dst_plen
,
src_plen
,
metric
,
use
,
refcnt
,
flags
;
int
n
,
rc
;
f
=
fopen
(
"/proc/net/ipv6_route"
,
"r"
);
if
(
f
==
NULL
)
return
-
1
;
n
=
0
;
while
(
n
<
maxroutes
)
{
rc
=
fscanf
(
f
,
"%32s %02x %32s %02x %32s %08x %08x %08x %08x %s"
,
dst
,
&
dst_plen
,
src
,
&
src_plen
,
gw
,
&
metric
,
&
use
,
&
refcnt
,
&
flags
,
iface
);
if
(
rc
!=
10
)
break
;
if
(
!
(
flags
&
RTF_UP
)
||
dst_plen
>
maxplen
||
src_plen
!=
0
)
goto
skip
;
rc
=
parse_address
(
dst
,
routes
[
n
].
prefix
);
if
(
rc
<
0
)
goto
skip
;
routes
[
n
].
plen
=
dst_plen
;
routes
[
n
].
metric
=
MIN
(
metric
,
(
unsigned
)
KERNEL_INFINITY
);
routes
[
n
].
ifindex
=
if_nametoindex
(
iface
);
if
(
routes
[
n
].
ifindex
<
0
)
goto
skip
;
if
(
flags
&
RTF_GATEWAY
)
rc
=
parse_address
(
gw
,
routes
[
n
].
gw
);
else
memset
(
routes
[
n
].
gw
,
0
,
16
);
skip:
n
++
;
}
fclose
(
f
);
return
n
;
}
kernel.h
View file @
a12be898
...
...
@@ -22,9 +22,18 @@ THE SOFTWARE.
#define KERNEL_INFINITY 0xFFFF
struct
kernel_route
{
unsigned
char
prefix
[
16
];
int
plen
;
int
metric
;
int
ifindex
;
unsigned
char
gw
[
16
];
};
int
kernel_setup
(
int
setup
);
int
kernel_setup_interface
(
int
setup
,
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_mtu
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_wireless
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_route
(
int
add
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
);
int
kernel_routes
(
int
maxplen
,
struct
kernel_route
*
routes
,
int
maxroutes
);
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