Skip to content

Commit

Permalink
Merge pull request #12501 from tomponline/tp-network-bridge-comments
Browse files Browse the repository at this point in the history
lxd/network/driver/bridge: Improve comments for accept_ra
  • Loading branch information
tomponline authored Nov 4, 2023
2 parents 21d9fe4 + b488428 commit 916dd99
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lxd/network/driver_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -1147,13 +1147,21 @@ func (n *bridge) setup(oldConfig map[string]string) error {
return err
}

// First set accept_ra to 2 for everything.
// First set accept_ra to 2 for all interfaces (if not disabled).
// This ensures that the host can still receive IPv6 router advertisements even with
// forwarding enabled (which enable below), as the default is to ignore router adverts
// when forward is enabled, and this could render the host unreachable if it uses
// SLAAC generated IPs.
for _, entry := range entries {
// Check that IPv6 router advertisement acceptance is enabled currently.
// If its set to 0 then we don't want to enable, and if its already set to 2 then
// we don't need to do anything.
content, err := os.ReadFile(fmt.Sprintf("/proc/sys/net/ipv6/conf/%s/accept_ra", entry.Name()))
if err == nil && string(content) != "1\n" {
continue
}

// If IPv6 router acceptance is enabled (set to 1) then we now set it to 2.
err = util.SysctlSet(fmt.Sprintf("net/ipv6/conf/%s/accept_ra", entry.Name()), "2")
if err != nil && !os.IsNotExist(err) {
return err
Expand Down

0 comments on commit 916dd99

Please sign in to comment.