From 8abd2ec53f4606778e3bdb0e5b6f7f231f918d09 Mon Sep 17 00:00:00 2001 From: Archana Shinde Date: Thu, 11 Apr 2019 21:21:38 -0700 Subject: [PATCH] netmon: Fix bug in how routes are converted The agent expects a IP CIDR for the route destination rather than an IP address. netmon was incorrectly converting route dest to an IP address and hence exiting with an error. We did not have an integration test for netmon with tcfilter mode. macvtap mode did not uncover this, as with macvtap routes are not really passed to the agent. We delete the IP on the veth device, and netmon looks at the routes after the IP is deleted with macvtap. Fixes #1523 Signed-off-by: Archana Shinde --- netmon/netmon.go | 2 +- netmon/netmon_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/netmon/netmon.go b/netmon/netmon.go index 5595ce2ba8..9d0c5d9d82 100644 --- a/netmon/netmon.go +++ b/netmon/netmon.go @@ -309,7 +309,7 @@ func convertRoutes(netRoutes []netlink.Route) []vcTypes.Route { dst := "" if netRoute.Dst != nil { if netRoute.Dst.IP.To4() != nil { - dst = netRoute.Dst.IP.String() + dst = netRoute.Dst.String() } else { netmonLog.WithField("destination", netRoute.Dst.IP.String()).Warn("Not IPv4 format") } diff --git a/netmon/netmon_test.go b/netmon/netmon_test.go index 0eb7ba5449..294ec4617e 100644 --- a/netmon/netmon_test.go +++ b/netmon/netmon_test.go @@ -213,7 +213,7 @@ func TestConvertRoutes(t *testing.T) { expected := []vcTypes.Route{ { - Dest: testIPAddress, + Dest: testIPAddressWithMask, Gateway: testIPAddress, Source: testIPAddress, Scope: uint32(testScope),