Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Stable IPv6 addresses #2227

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/dom0-ztools/rootfs/etc/sysctl.d/02-eve.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ kernel.softlockup_panic = 1
# zedrouter settings
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.default.forwarding = 1
# We use ip6tables for the bridge
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
Expand All @@ -20,11 +21,16 @@ net.netfilter.nf_conntrack_timestamp = 1
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.default.log_martians = 0

net.ipv6.conf.default.accept_ra = 2
net.ipv6.conf.all.accept_ra = 2
# Avoid lots of temporary addresses; use RFC7217 instead
net.ipv6.conf.default.addr_gen_mode = 2
net.ipv6.conf.all.addr_gen_mode = 2
net.ipv6.conf.default.use_tempaddr = 0
net.ipv6.conf.all.use_tempaddr = 0
# Used a fixed number to get the same for each boot/EVE update
net.ipv6.conf.default.stable_secret = ff::0
net.ipv6.conf.all.stable_secret = ff::0

# For reliable downloads need less than 2 hour keepalive timer
net.ipv4.tcp_keepalive_time = 60
Expand Down
39 changes: 38 additions & 1 deletion pkg/pillar/devicenetwork/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
// Ethernet interfaces have no bridge
// Assumes that the caller has checked that the interfaces exist
// We therefore skip any interfaces which do not exist
// Also sets sysctls on the interface
func UpdateBridge(log *base.LogObject, newConfig, oldConfig types.DevicePortConfig) {

// Look for adds
Expand Down Expand Up @@ -47,6 +48,7 @@ func addBridge(log *base.LogObject, ifname string) error {
log.Noticef("addBridge(%s)", ifname)
if !strings.HasPrefix(ifname, "eth") {
log.Functionf("addBridge: skipping %s", ifname)
setSysctls(log, ifname)
return nil
}
link, err := netlink.LinkByName(ifname)
Expand Down Expand Up @@ -115,6 +117,7 @@ func addBridge(log *base.LogObject, ifname string) error {
log.Error(err)
return err
}
setSysctls(log, ifname)
// ip link set kethN master ethN
if err := netlink.LinkSetMaster(kernLink, bridge); err != nil {
err = fmt.Errorf("addBridge LinkSetMaster(%s, %s) failed: %v",
Expand All @@ -128,14 +131,48 @@ func addBridge(log *base.LogObject, ifname string) error {
log.Error(err)
return err
}
// update cached ifindex
// updatecached ifindex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to remove the space between "update" and "cached"?

_, err = UpdateIfnameToIndex(log, ifname)
if err != nil {
log.Errorf("addBridge: UpdateIfnameToIndex failed: %v", err)
}
return nil
}

// Make sure we have the settings needed for IPv6
func setSysctls(log *base.LogObject, ifname string) {
sysctlSetting := fmt.Sprintf("net.ipv6.conf.%s.stable_secret=ff::0",
ifname)
args := []string{"-w", sysctlSetting}
log.Noticef("Calling command %s %v", "sysctl", args)
out, err := base.Exec(log, "sysctl", args...).CombinedOutput()
if err != nil {
errStr := fmt.Sprintf("sysctl command %s failed %s output %s",
args, err, out)
log.Errorln(errStr)
}
sysctlSetting = fmt.Sprintf("net.ipv6.conf.%s.accept_ra=2",
ifname)
args = []string{"-w", sysctlSetting}
log.Noticef("Calling command %s %v", "sysctl", args)
out, err = base.Exec(log, "sysctl", args...).CombinedOutput()
if err != nil {
errStr := fmt.Sprintf("sysctl command %s failed %s output %s",
args, err, out)
log.Errorln(errStr)
}
sysctlSetting = fmt.Sprintf("net.ipv6.conf.%s.addr_gen_mode=4",
ifname)
args = []string{"-w", sysctlSetting}
log.Noticef("Calling command %s %v", "sysctl", args)
out, err = base.Exec(log, "sysctl", args...).CombinedOutput()
if err != nil {
errStr := fmt.Sprintf("sysctl command %s failed %s output %s",
args, err, out)
log.Errorln(errStr)
}
}

// Check if the name is ethN and a bridge
// If so delete it and find kethN and rename it back to ethN.
// Also restore the Mac address on ethN
Expand Down