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
46957e84
Commit
46957e84
authored
Jun 02, 2007
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kernel support for blackhole routes.
parent
03d5785b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
10 deletions
+24
-10
kernel.c
kernel.c
+21
-9
kernel.h
kernel.h
+3
-1
No files found.
kernel.c
View file @
46957e84
...
...
@@ -37,6 +37,7 @@ THE SOFTWARE.
static
int
old_forwarding
=
-
1
;
static
int
old_accept_redirects
=
-
1
;
static
int
ifindex_lo
=
-
1
;
static
int
read_proc
(
char
*
filename
)
...
...
@@ -198,7 +199,7 @@ static int route_socket = -1;
int
kernel_route
(
int
add
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
const
unsigned
char
*
gate
,
int
ifindex
,
int
metric
)
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
)
{
struct
in6_rtmsg
msg
;
int
rc
;
...
...
@@ -209,21 +210,32 @@ kernel_route(int add, const unsigned char *dest, unsigned short plen,
return
-
1
;
}
if
(
ifindex_lo
<
0
)
{
ifindex_lo
=
if_nametoindex
(
"lo"
);
if
(
ifindex_lo
<
0
)
return
-
1
;
}
memset
(
&
msg
,
0
,
sizeof
(
msg
));
msg
.
rtmsg_flags
=
RTF_UP
;
if
(
plen
<
128
)
{
msg
.
rtmsg_flags
|=
RTF_GATEWAY
;
}
else
{
memcpy
(
&
msg
.
rtmsg_dst
,
dest
,
sizeof
(
struct
in6_addr
));
msg
.
rtmsg_dst_len
=
plen
;
msg
.
rtmsg_metric
=
metric
;
if
(
plen
>=
128
)
msg
.
rtmsg_flags
|=
RTF_HOST
;
if
(
memcmp
(
dest
,
gate
,
16
)
!=
0
)
if
(
metric
>=
KERNEL_INFINITY
)
{
msg
.
rtmsg_ifindex
=
ifindex_lo
;
}
else
{
msg
.
rtmsg_ifindex
=
ifindex
;
if
(
plen
<
128
||
memcmp
(
dest
,
gate
,
16
)
!=
0
)
msg
.
rtmsg_flags
|=
RTF_GATEWAY
;
}
msg
.
rtmsg_metric
=
metric
;
memcpy
(
&
msg
.
rtmsg_dst
,
dest
,
sizeof
(
struct
in6_addr
));
msg
.
rtmsg_dst_len
=
plen
;
memcpy
(
&
msg
.
rtmsg_gateway
,
gate
,
sizeof
(
struct
in6_addr
));
msg
.
rtmsg_ifindex
=
ifindex
;
rc
=
ioctl
(
route_socket
,
add
?
SIOCADDRT
:
SIOCDELRT
,
&
msg
);
if
(
rc
<
0
)
return
-
1
;
...
...
kernel.h
View file @
46957e84
...
...
@@ -20,9 +20,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#define KERNEL_INFINITY 0xFFFF
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
,
int
metric
);
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
);
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