Adds cursory unit test for default-route and cleans lint (and one errant test)

This commit is contained in:
dougbtv
2019-10-28 14:59:39 -04:00
committed by Doug Smith
parent 3a9dd7ed76
commit 8c76fd62e0
3 changed files with 60 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ import (
"github.com/intel/multus-cni/logging"
"github.com/vishvananda/netlink"
"net"
"strings"
)
// DeleteDefaultGW removes the default gateway from marked interfaces.
@@ -98,7 +99,7 @@ func SetDefaultGW(args *skel.CmdArgs, ifName string, gateways []net.IP, res *cni
// Set a correct CIDR depending on IP type
_, dstipnet, _ := net.ParseCIDR("::0/0")
if gw.To4 != nil {
if strings.Count(gw.String(), ":") < 2 {
_, dstipnet, _ = net.ParseCIDR("0.0.0.0/0")
}
newResultDefaultRoutes = append(newResultDefaultRoutes, &cnitypes.Route{Dst: *dstipnet, GW: gw})