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
aafcb019
Commit
aafcb019
authored
May 16, 2010
by
dermiste
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
portability enhancements for kernel_setup
parent
00fc98ec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
60 deletions
+40
-60
kernel_socket.c
kernel_socket.c
+40
-60
No files found.
kernel_socket.c
View file @
aafcb019
...
@@ -80,28 +80,6 @@ static int old_accept_redirects = -1;
...
@@ -80,28 +80,6 @@ static int old_accept_redirects = -1;
static
int
ifindex_lo
=
-
1
;
static
int
ifindex_lo
=
-
1
;
static
int
seq
;
static
int
seq
;
static
int
get_sysctl_int
(
char
*
name
)
{
int
old
;
size_t
len
=
sizeof
(
old
);
if
(
sysctlbyname
(
name
,
&
old
,
&
len
,
NULL
,
0
)
<
0
)
return
-
1
;
return
old
;
}
static
int
set_sysctl_int
(
char
*
name
,
int
new
)
{
int
old
;
size_t
len
=
sizeof
(
old
);
if
(
sysctlbyname
(
name
,
&
old
,
&
len
,
&
new
,
sizeof
(
new
))
<
0
)
return
-
1
;
return
old
;
}
int
int
mask2len
(
const
struct
in6_addr
*
addr
)
mask2len
(
const
struct
in6_addr
*
addr
)
{
{
...
@@ -156,47 +134,49 @@ int
...
@@ -156,47 +134,49 @@ int
kernel_setup
(
int
setup
)
kernel_setup
(
int
setup
)
{
{
int
rc
;
int
rc
;
if
(
setup
)
{
int
forwarding
=
1
;
int
accept_redirects
=
0
;
int
mib
[
4
];
size_t
datasize
;
mib
[
0
]
=
CTL_NET
;
mib
[
1
]
=
AF_INET6
;
seq
=
time
(
NULL
);
seq
=
time
(
NULL
);
old_forwarding
=
get_sysctl_int
(
"net.inet6.ip6.forwarding"
);
if
(
old_forwarding
<
0
)
{
mib
[
2
]
=
IPPROTO_IPV6
;
mib
[
3
]
=
IPV6CTL_FORWARDING
;
datasize
=
sizeof
(
old_forwarding
);
if
(
setup
)
rc
=
sysctl
(
mib
,
4
,
&
old_forwarding
,
&
datasize
,
&
forwarding
,
datasize
);
else
if
(
0
<=
old_forwarding
)
rc
=
sysctl
(
mib
,
4
,
NULL
,
NULL
,
&
old_forwarding
,
datasize
);
if
(
rc
==
-
1
)
{
if
(
errno
==
ENOMEM
)
perror
(
"Couldn't read forwarding knob."
);
perror
(
"Couldn't read forwarding knob."
);
return
-
1
;
else
}
rc
=
set_sysctl_int
(
"net.inet6.ip6.forwarding"
,
1
);
if
(
rc
<
0
)
{
perror
(
"Couldn't write forwarding knob."
);
perror
(
"Couldn't write forwarding knob."
);
return
-
1
;
return
-
1
;
}
}
old_accept_redirects
=
get_sysctl_int
(
"net.inet6.icmp6.rediraccept"
);
if
(
old_accept_redirects
<
0
)
{
mib
[
2
]
=
IPPROTO_ICMPV6
;
mib
[
3
]
=
ICMPV6CTL_REDIRACCEPT
;
datasize
=
sizeof
(
old_accept_redirects
);
if
(
setup
)
rc
=
sysctl
(
mib
,
4
,
&
old_accept_redirects
,
&
datasize
,
&
accept_redirects
,
datasize
);
else
if
(
0
<=
old_accept_redirects
)
rc
=
sysctl
(
mib
,
4
,
NULL
,
NULL
,
&
old_accept_redirects
,
datasize
);
if
(
rc
==
-
1
)
{
if
(
errno
==
ENOMEM
)
perror
(
"Couldn't read accept_redirects knob."
);
perror
(
"Couldn't read accept_redirects knob."
);
return
-
1
;
else
}
rc
=
set_sysctl_int
(
"net.inet6.icmp6.rediraccept"
,
0
);
if
(
rc
<
0
)
{
perror
(
"Couldn't write accept_redirects knob."
);
perror
(
"Couldn't write accept_redirects knob."
);
return
-
1
;
return
-
1
;
}
}
return
1
;
return
1
;
}
else
{
if
(
old_forwarding
>=
0
)
{
rc
=
set_sysctl_int
(
"net.inet6.ip6.forwarding"
,
old_forwarding
);
if
(
rc
<
0
)
{
perror
(
"Couldn't write accept_redirects knob.
\n
"
);
return
-
1
;
}
}
if
(
old_accept_redirects
>=
0
)
{
rc
=
set_sysctl_int
(
"net.inet6.icmp6.rediraccept"
,
old_accept_redirects
);
if
(
rc
<
0
)
{
perror
(
"Couldn't write accept_redirects knob.
\n
"
);
return
-
1
;
}
}
return
1
;
}
}
}
int
int
...
...
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