From 216d4acf20674ab0fa06e2e286dd1048cbcc164c Mon Sep 17 00:00:00 2001 From: Malte Lehmann Date: Sun, 5 May 2024 20:17:31 +0200 Subject: [PATCH] wireguard backend: avoid error message if route already exists While processing node add events, flannel-wg routes are added irrespective of whether they already exist. This causes an error message for each wg peer. This might be misleading since there is actually no problem. By add or replacing the route, this can be avoided. Fixes #1963 --- pkg/backend/wireguard/device.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/backend/wireguard/device.go b/pkg/backend/wireguard/device.go index d5ad79723..ec0364af4 100644 --- a/pkg/backend/wireguard/device.go +++ b/pkg/backend/wireguard/device.go @@ -233,7 +233,7 @@ func (dev *wgDevice) addRoute(dst *net.IPNet) error { Dst: dst, } - err := netlink.RouteAdd(&route) + err := netlink.RouteReplace(&route) if err != nil { return fmt.Errorf("failed to add route %s: %w", dev.attrs.name, err) }