Merge pull request #47989 from robmry/ipv6_bridge_route_noerrlog

Don't log an error about route-add for IPv6 bridge
This commit is contained in:
Albin Kerouanton
2024-06-14 18:50:20 +02:00
committed by GitHub

View File

@@ -2,9 +2,11 @@ package bridge
import (
"context"
"errors"
"fmt"
"net/netip"
"os"
"syscall"
"github.com/containerd/log"
"github.com/vishvananda/netlink"
@@ -39,6 +41,8 @@ func setupBridgeIPv6(config *networkConfiguration, i *bridgeInterface) error {
}
// Setting route to global IPv6 subnet
// TODO(robmry) - remove this? The bridge is 'down' at this point so I think it
// always fails, and the route is added anyway when the bridge is set 'up'.
log.G(context.TODO()).Debugf("Adding route to IPv6 network %s via device %s", config.AddressIPv6.String(), config.BridgeName)
err = i.nlh.RouteAdd(&netlink.Route{
Scope: netlink.SCOPE_UNIVERSE,
@@ -46,7 +50,11 @@ func setupBridgeIPv6(config *networkConfiguration, i *bridgeInterface) error {
Dst: config.AddressIPv6,
})
if err != nil && !os.IsExist(err) {
log.G(context.TODO()).Errorf("Could not add route to IPv6 network %s via device %s: %s", config.AddressIPv6.String(), config.BridgeName, err)
if errors.Is(err, syscall.ENETDOWN) {
log.G(context.TODO()).Debugf("Could not add route to IPv6 network %s via device %s: %s", config.AddressIPv6.String(), config.BridgeName, err)
} else {
log.G(context.TODO()).Errorf("Could not add route to IPv6 network %s via device %s: %s", config.AddressIPv6.String(), config.BridgeName, err)
}
}
return nil