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
9ff33c57
Commit
9ff33c57
authored
Jan 02, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement setting of IPv4 forwarding flag.
parent
f40cbec0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
7 deletions
+34
-7
babel.c
babel.c
+3
-3
kernel.h
kernel.h
+1
-1
kernel_netlink.c
kernel_netlink.c
+29
-2
kernel_socket.c
kernel_socket.c
+1
-1
No files found.
babel.c
View file @
9ff33c57
...
@@ -286,7 +286,7 @@ main(int argc, char **argv)
...
@@ -286,7 +286,7 @@ main(int argc, char **argv)
fprintf
(
stderr
,
"Respecting %ld second silent time.
\n
"
,
fprintf
(
stderr
,
"Respecting %ld second silent time.
\n
"
,
(
long
int
)(
reboot_time
+
silent_time
-
now
.
tv_sec
));
(
long
int
)(
reboot_time
+
silent_time
-
now
.
tv_sec
));
rc
=
kernel_setup
(
1
);
rc
=
kernel_setup
(
1
,
do_ipv4
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
fprintf
(
stderr
,
"kernel_setup failed.
\n
"
);
fprintf
(
stderr
,
"kernel_setup failed.
\n
"
);
exit
(
1
);
exit
(
1
);
...
@@ -571,7 +571,7 @@ main(int argc, char **argv)
...
@@ -571,7 +571,7 @@ main(int argc, char **argv)
kernel_setup_interface
(
0
,
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
);
kernel_setup_interface
(
0
,
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
);
}
}
kernel_setup_socket
(
0
);
kernel_setup_socket
(
0
);
kernel_setup
(
0
);
kernel_setup
(
0
,
do_ipv4
);
fd
=
open
(
state_file
,
O_WRONLY
|
O_TRUNC
|
O_CREAT
,
0644
);
fd
=
open
(
state_file
,
O_WRONLY
|
O_TRUNC
|
O_CREAT
,
0644
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
...
@@ -614,7 +614,7 @@ main(int argc, char **argv)
...
@@ -614,7 +614,7 @@ main(int argc, char **argv)
for
(
i
=
0
;
i
<
numnets
;
i
++
)
for
(
i
=
0
;
i
<
numnets
;
i
++
)
kernel_setup_interface
(
0
,
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
);
kernel_setup_interface
(
0
,
nets
[
i
].
ifname
,
nets
[
i
].
ifindex
);
kernel_setup_socket
(
0
);
kernel_setup_socket
(
0
);
kernel_setup
(
0
);
kernel_setup
(
0
,
do_ipv4
);
exit
(
1
);
exit
(
1
);
}
}
...
...
kernel.h
View file @
9ff33c57
...
@@ -34,7 +34,7 @@ struct kernel_route {
...
@@ -34,7 +34,7 @@ struct kernel_route {
#define ROUTE_ADD 1
#define ROUTE_ADD 1
#define ROUTE_MODIFY 2
#define ROUTE_MODIFY 2
int
kernel_setup
(
int
setup
);
int
kernel_setup
(
int
setup
,
int
ipv4
);
int
kernel_setup_socket
(
int
setup
);
int
kernel_setup_socket
(
int
setup
);
int
kernel_setup_interface
(
int
setup
,
const
char
*
ifname
,
int
ifindex
);
int
kernel_setup_interface
(
int
setup
,
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_ipv4
(
const
char
*
ifname
,
int
ifindex
,
char
*
addr_r
);
int
kernel_interface_ipv4
(
const
char
*
ifname
,
int
ifindex
,
char
*
addr_r
);
...
...
kernel_netlink.c
View file @
9ff33c57
...
@@ -45,6 +45,7 @@ THE SOFTWARE.
...
@@ -45,6 +45,7 @@ THE SOFTWARE.
#include "util.h"
#include "util.h"
static
int
old_forwarding
=
-
1
;
static
int
old_forwarding
=
-
1
;
static
int
old_ipv4_forwarding
=
-
1
;
static
int
old_accept_redirects
=
-
1
;
static
int
old_accept_redirects
=
-
1
;
static
int
old_rp_filter
=
-
1
;
static
int
old_rp_filter
=
-
1
;
...
@@ -379,7 +380,7 @@ netlink_send_dump(int type, void *data, int len) {
...
@@ -379,7 +380,7 @@ netlink_send_dump(int type, void *data, int len) {
}
}
int
int
kernel_setup
(
int
setup
)
kernel_setup
(
int
setup
,
int
ipv4
)
{
{
int
rc
;
int
rc
;
...
@@ -403,6 +404,22 @@ kernel_setup(int setup)
...
@@ -403,6 +404,22 @@ kernel_setup(int setup)
return
-
1
;
return
-
1
;
}
}
if
(
ipv4
)
{
old_ipv4_forwarding
=
read_proc
(
"/proc/sys/net/ipv4/conf/all/forwarding"
);
if
(
old_ipv4_forwarding
<
0
)
{
perror
(
"Couldn't read IPv4 forwarding knob."
);
return
-
1
;
}
rc
=
write_proc
(
"/proc/sys/net/ipv4/conf/all/forwarding"
,
1
);
if
(
rc
<
0
)
{
perror
(
"Couldn't write IPv4 forwarding knob."
);
return
-
1
;
}
}
old_accept_redirects
=
old_accept_redirects
=
read_proc
(
"/proc/sys/net/ipv6/conf/all/accept_redirects"
);
read_proc
(
"/proc/sys/net/ipv6/conf/all/accept_redirects"
);
if
(
old_accept_redirects
<
0
)
{
if
(
old_accept_redirects
<
0
)
{
...
@@ -435,10 +452,20 @@ kernel_setup(int setup)
...
@@ -435,10 +452,20 @@ kernel_setup(int setup)
rc
=
write_proc
(
"/proc/sys/net/ipv6/conf/all/forwarding"
,
rc
=
write_proc
(
"/proc/sys/net/ipv6/conf/all/forwarding"
,
old_forwarding
);
old_forwarding
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
perror
(
"Couldn't write accept_redirects knob.
\n
"
);
perror
(
"Couldn't write forwarding knob.
\n
"
);
return
-
1
;
}
}
if
(
old_ipv4_forwarding
>=
0
)
{
rc
=
write_proc
(
"/proc/sys/net/ipv4/conf/all/forwarding"
,
old_ipv4_forwarding
);
if
(
rc
<
0
)
{
perror
(
"Couldn't write IPv4 forwarding knob.
\n
"
);
return
-
1
;
return
-
1
;
}
}
}
}
if
(
old_accept_redirects
>=
0
)
{
if
(
old_accept_redirects
>=
0
)
{
rc
=
write_proc
(
"/proc/sys/net/ipv6/conf/all/accept_redirects"
,
rc
=
write_proc
(
"/proc/sys/net/ipv6/conf/all/accept_redirects"
,
old_accept_redirects
);
old_accept_redirects
);
...
...
kernel_socket.c
View file @
9ff33c57
...
@@ -136,7 +136,7 @@ plen2mask(int n, struct in6_addr *dest)
...
@@ -136,7 +136,7 @@ plen2mask(int n, struct in6_addr *dest)
}
}
int
int
kernel_setup
(
int
setup
)
kernel_setup
(
int
setup
,
int
ipv4
)
{
{
int
rc
;
int
rc
;
if
(
setup
)
{
if
(
setup
)
{
...
...
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