From df7cf77a08d50c2e3eb648b012d78e0f621e2af7 Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Tue, 6 Aug 2019 00:46:07 +0000 Subject: [PATCH] network: Ignore routes with proto as "kernel" Routes with proto "kernel" are routes that are automatically added by the kernel. It is a route added automatically when you assign an address to an interface which is not /32. With this commit, these routes are ignored. The guest kernel would add these routes on the guest side. A corresponding commit on the agent side would no longer delete these routes while updating them. Without this commit, netlink gives an error complaining that a route already exists when you try to add a route with the same dest subnet. Something like: dest: 192.168.1.0/24 device:net1 source:192.168.1.217 scope:253 dest: 192.168.1.0/24 device:net2 source:192.168.1.218 scope:253 Depends-on: github.com/kata-containers/agent#624 Fixes: #1811 Signed-off-by: Archana Shinde --- netmon/netmon.go | 5 +++++ virtcontainers/network.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/netmon/netmon.go b/netmon/netmon.go index 9d0c5d9d82..b4b74ad120 100644 --- a/netmon/netmon.go +++ b/netmon/netmon.go @@ -307,6 +307,11 @@ func convertRoutes(netRoutes []netlink.Route) []vcTypes.Route { // by Kata yet. for _, netRoute := range netRoutes { dst := "" + + if netRoute.Protocol == unix.RTPROT_KERNEL { + continue + } + if netRoute.Dst != nil { if netRoute.Dst.IP.To4() != nil { dst = netRoute.Dst.String() diff --git a/virtcontainers/network.go b/virtcontainers/network.go index df553f4c27..c1e1fa9c66 100644 --- a/virtcontainers/network.go +++ b/virtcontainers/network.go @@ -1170,6 +1170,10 @@ func generateInterfacesAndRoutes(networkNS NetworkNamespace) ([]*vcTypes.Interfa for _, route := range endpoint.Properties().Routes { var r vcTypes.Route + if route.Protocol == unix.RTPROT_KERNEL { + continue + } + if route.Dst != nil { r.Dest = route.Dst.String()