Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hepto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACIDES
Hepto
Commits
84b47e5d
Commit
84b47e5d
authored
2 years ago
by
kaiyou
Browse files
Options
Downloads
Patches
Plain Diff
Improve router advertisement configuration
parent
84dfac3d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/selfcontain/net.go
+18
-5
18 additions, 5 deletions
pkg/selfcontain/net.go
with
18 additions
and
5 deletions
pkg/selfcontain/net.go
+
18
−
5
View file @
84b47e5d
...
...
@@ -14,6 +14,7 @@ import (
"github.com/vishvananda/netlink"
)
const
ACCEPT_RA
=
"net.ipv6.conf.eth0.accept_ra_pinfo"
const
ACCEPT_PINFO
=
"net.ipv6.conf.eth0.accept_ra_pinfo"
const
ACCEPT_DFTRTR
=
"net.ipv6.conf.eth0.accept_ra_defrtr"
...
...
@@ -44,6 +45,10 @@ func (c *Container) SetupNetworking(etc string) error {
return
fmt
.
Errorf
(
"could not set the interface up: %w"
,
err
)
}
// Setup addresses and routes
err
=
setupRA
(
iface
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"could not enable RA: %w"
,
err
)
}
err
=
setupAddress
(
iface
,
c
.
config
.
IP
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"could not set the address: %w"
,
err
)
...
...
@@ -104,12 +109,20 @@ func (c *Container) setupIPVlan(master string, mtu int) (string, error) {
return
tmpName
,
nil
}
func
setupRA
(
iface
netlink
.
Link
)
error
{
// Accept router advertisement, even when forwarding is
// enabled, this is further specified by setupAddress
// and setupGw
_
,
err
:=
sysctl
.
Sysctl
(
ACCEPT_RA
,
"2"
)
return
err
}
func
setupAddress
(
iface
netlink
.
Link
,
ip
net
.
IPNet
)
error
{
// Accept router advertisement for addresses if required,
// otherwise use provided IP
accept_
ra
:=
"1"
accept_
pinfo
:=
"1"
if
len
(
ip
.
IP
)
>
0
{
accept_
ra
=
"0"
accept_
pinfo
=
"0"
addr
:=
&
netlink
.
Addr
{
IPNet
:
&
ip
,
}
...
...
@@ -118,14 +131,14 @@ func setupAddress(iface netlink.Link, ip net.IPNet) error {
return
err
}
}
_
,
err
:=
sysctl
.
Sysctl
(
ACCEPT_PINFO
,
accept_
ra
)
_
,
err
:=
sysctl
.
Sysctl
(
ACCEPT_PINFO
,
accept_
pinfo
)
return
err
}
func
setupGw
(
iface
netlink
.
Link
,
gw
net
.
IP
)
error
{
// Accept router advertisement for default routes if required,
// otherwise use provided gateway
accept_r
a
:=
"1"
accept_
defrt
r
:=
"1"
if
len
(
gw
)
>
0
{
// First add a link-local route to the gateway, so that
// out-of-lan default routes are handled properly
...
...
@@ -151,7 +164,7 @@ func setupGw(iface netlink.Link, gw net.IP) error {
return
err
}
}
_
,
err
:=
sysctl
.
Sysctl
(
ACCEPT_DFTRTR
,
accept_r
a
)
_
,
err
:=
sysctl
.
Sysctl
(
ACCEPT_DFTRTR
,
accept_
defrt
r
)
return
err
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment