diff --git a/link_test.go b/link_test.go index 5752e82..ca4e7a8 100644 --- a/link_test.go +++ b/link_test.go @@ -62,10 +62,10 @@ func testLinkAddDel(t *testing.T, link Link) { var peer *Veth other, err := LinkByName(veth.PeerName) if err != nil { - t.Fatal("Peer %s not created", veth.PeerName) + t.Fatalf("Peer %s not created", veth.PeerName) } if peer, ok = other.(*Veth); !ok { - t.Fatal("Peer %s is incorrect type", veth.PeerName) + t.Fatalf("Peer %s is incorrect type", veth.PeerName) } if peer.TxQLen != testTxQLen { t.Fatalf("TxQLen of peer is %d, should be %d", peer.TxQLen, testTxQLen) @@ -108,54 +108,54 @@ func testLinkAddDel(t *testing.T, link Link) { func compareVxlan(t *testing.T, expected, actual *Vxlan) { if actual.VxlanId != expected.VxlanId { - t.Fatalf("Vxlan.VxlanId doesn't match") + t.Fatal("Vxlan.VxlanId doesn't match") } if expected.SrcAddr != nil && !actual.SrcAddr.Equal(expected.SrcAddr) { - t.Fatalf("Vxlan.SrcAddr doesn't match") + t.Fatal("Vxlan.SrcAddr doesn't match") } if expected.Group != nil && !actual.Group.Equal(expected.Group) { - t.Fatalf("Vxlan.Group doesn't match") + t.Fatal("Vxlan.Group doesn't match") } if expected.TTL != -1 && actual.TTL != expected.TTL { - t.Fatalf("Vxlan.TTL doesn't match") + t.Fatal("Vxlan.TTL doesn't match") } if expected.TOS != -1 && actual.TOS != expected.TOS { - t.Fatalf("Vxlan.TOS doesn't match") + t.Fatal("Vxlan.TOS doesn't match") } if actual.Learning != expected.Learning { - t.Fatalf("Vxlan.Learning doesn't match") + t.Fatal("Vxlan.Learning doesn't match") } if actual.Proxy != expected.Proxy { - t.Fatalf("Vxlan.Proxy doesn't match") + t.Fatal("Vxlan.Proxy doesn't match") } if actual.RSC != expected.RSC { - t.Fatalf("Vxlan.RSC doesn't match", actual, expected) + t.Fatal("Vxlan.RSC doesn't match") } if actual.L2miss != expected.L2miss { - t.Fatalf("Vxlan.L2miss doesn't match") + t.Fatal("Vxlan.L2miss doesn't match") } if actual.L3miss != expected.L3miss { - t.Fatalf("Vxlan.L3miss doesn't match") + t.Fatal("Vxlan.L3miss doesn't match") } if expected.NoAge { if !actual.NoAge { - t.Fatalf("Vxlan.NoAge doesn't match") + t.Fatal("Vxlan.NoAge doesn't match") } } else if expected.Age > 0 && actual.Age != expected.Age { - t.Fatalf("Vxlan.Age doesn't match") + t.Fatal("Vxlan.Age doesn't match") } if expected.Limit > 0 && actual.Limit != expected.Limit { - t.Fatalf("Vxlan.Limit doesn't match") + t.Fatal("Vxlan.Limit doesn't match") } if expected.Port > 0 && actual.Port != expected.Port { - t.Fatalf("Vxlan.Port doesn't match") + t.Fatal("Vxlan.Port doesn't match") } if expected.PortLow > 0 || expected.PortHigh > 0 { if actual.PortLow != expected.PortLow { - t.Fatalf("Vxlan.PortLow doesn't match") + t.Fatal("Vxlan.PortLow doesn't match") } if actual.PortHigh != expected.PortHigh { - t.Fatalf("Vxlan.PortHigh doesn't match") + t.Fatal("Vxlan.PortHigh doesn't match") } } } diff --git a/neigh_test.go b/neigh_test.go index 3b84162..50da59c 100644 --- a/neigh_test.go +++ b/neigh_test.go @@ -72,8 +72,6 @@ func TestNeighAddDel(t *testing.T) { } } - return - // Delete the arpTable for _, entry := range arpTable { err := NeighDel(&Neigh{ @@ -87,17 +85,18 @@ func TestNeighAddDel(t *testing.T) { } } - // Dump and see that none of deleted entries are there - dump, err = NeighList(dummy.Index, 0) - if err != nil { - t.Errorf("Failed to NeighList: %v", err) - } + // TODO: seems not working because of cache + //// Dump and see that none of deleted entries are there + //dump, err = NeighList(dummy.Index, 0) + //if err != nil { + //t.Errorf("Failed to NeighList: %v", err) + //} - for _, entry := range arpTable { - if dumpContains(dump, entry) { - t.Errorf("Dump contains: %v", entry) - } - } + //for _, entry := range arpTable { + //if dumpContains(dump, entry) { + //t.Errorf("Dump contains: %v", entry) + //} + //} if err := LinkDel(&dummy); err != nil { t.Fatal(err) diff --git a/netlink.go b/netlink.go index 3ff7935..41ebdb1 100644 --- a/netlink.go +++ b/netlink.go @@ -30,10 +30,10 @@ func ParseIPNet(s string) (*net.IPNet, error) { if err != nil { return nil, err } - return &net.IPNet{ip, ipNet.Mask}, nil + return &net.IPNet{IP: ip, Mask: ipNet.Mask}, nil } // NewIPNet generates an IPNet from an ip address using a netmask of 32. func NewIPNet(ip net.IP) *net.IPNet { - return &net.IPNet{ip, net.CIDRMask(32, 32)} + return &net.IPNet{IP: ip, Mask: net.CIDRMask(32, 32)} } diff --git a/nl/xfrm_linux.go b/nl/xfrm_linux.go index 59f4607..d953130 100644 --- a/nl/xfrm_linux.go +++ b/nl/xfrm_linux.go @@ -103,9 +103,9 @@ func (x *XfrmAddress) ToIP() net.IP { func (x *XfrmAddress) ToIPNet(prefixlen uint8) *net.IPNet { ip := x.ToIP() if GetIPFamily(ip) == FAMILY_V4 { - return &net.IPNet{ip, net.CIDRMask(int(prefixlen), 32)} + return &net.IPNet{IP: ip, Mask: net.CIDRMask(int(prefixlen), 32)} } else { - return &net.IPNet{ip, net.CIDRMask(int(prefixlen), 128)} + return &net.IPNet{IP: ip, Mask: net.CIDRMask(int(prefixlen), 128)} } } diff --git a/protinfo_test.go b/protinfo_test.go index 14427fa..54bec93 100644 --- a/protinfo_test.go +++ b/protinfo_test.go @@ -71,6 +71,6 @@ func TestProtinfo(t *testing.T) { } if err := LinkSetProtinfo(iface3, pi3); err == nil || err.Error() != "operation not supported" { - t.Fatal("Set protinfo for link without master is not supported, but err: %s", err) + t.Fatalf("Set protinfo for link without master is not supported, but err: %s", err) } }