From d1360b82abea5c740865f29166446ce86ec9c334 Mon Sep 17 00:00:00 2001 From: Onur Filiz Date: Fri, 24 Jan 2020 17:28:07 -0800 Subject: [PATCH] loopback: Fix ipv6 address checks Signed-off-by: Onur Filiz --- plugins/main/loopback/loopback.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/main/loopback/loopback.go b/plugins/main/loopback/loopback.go index 2c4a047c3..2b07f7ebe 100644 --- a/plugins/main/loopback/loopback.go +++ b/plugins/main/loopback/loopback.go @@ -68,6 +68,7 @@ func cmdAdd(args *skel.CmdArgs) error { if err != nil { return err // not tested } + v4Addrs, err := netlink.AddrList(link, netlink.FAMILY_V4) if err != nil { return err // not tested @@ -89,7 +90,7 @@ func cmdAdd(args *skel.CmdArgs) error { if len(v6Addrs) != 0 { v6Addr = v6Addrs[0].IPNet // sanity check that this is a loopback address - for _, addr := range v4Addrs { + for _, addr := range v6Addrs { if !addr.IP.IsLoopback() { return fmt.Errorf("loopback interface found with non-loopback address %q", addr.IP) }