Skip to content

Commit

Permalink
Bump up containernetworking libraries version (#4425)
Browse files Browse the repository at this point in the history
1. Bump up github.com/containernetworking/cni version to v1.1.2
2. Bump up github.com/containernetworking/plugins v1.1.1

Signed-off-by: wenyingd <wenyingd@vmware.com>
  • Loading branch information
wenyingd authored Feb 27, 2023
1 parent d5dd02e commit be83891
Show file tree
Hide file tree
Showing 32 changed files with 396 additions and 279 deletions.
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/ClickHouse/clickhouse-go v1.5.4
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/Mellanox/sriovnet v1.1.0
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331
github.com/Microsoft/hcsshim v0.8.9
github.com/Microsoft/go-winio v0.4.17
github.com/Microsoft/hcsshim v0.8.20
github.com/TomCodeLV/OVSDB-golang-lib v0.0.0-20200116135253-9bbdfadcd881
github.com/awalterschulze/gographviz v2.0.1+incompatible
github.com/aws/aws-sdk-go-v2 v1.16.10
Expand All @@ -19,8 +19,8 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/cheggaaa/pb/v3 v3.1.0
github.com/confluentinc/bincover v0.1.0
github.com/containernetworking/cni v0.8.1
github.com/containernetworking/plugins v0.8.7
github.com/containernetworking/cni v1.1.1
github.com/containernetworking/plugins v1.1.1
github.com/coreos/go-iptables v0.6.0
github.com/fsnotify/fsnotify v1.6.0
github.com/gammazero/deque v0.1.2
Expand All @@ -31,7 +31,7 @@ require (
github.com/google/btree v1.1.2
github.com/google/uuid v1.3.0
github.com/hashicorp/memberlist v0.5.0
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.1
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.3.0
github.com/k8snetworkplumbingwg/sriov-cni v2.1.0+incompatible
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd
github.com/lithammer/dedent v1.1.0
Expand Down Expand Up @@ -120,7 +120,7 @@ require (
github.com/cenkalti/rpc2 v0.0.0-20180727162946-9642ea02d0aa // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59 // indirect
github.com/containerd/cgroups v1.0.1 // indirect
github.com/contiv/libovsdb v0.0.0-20170227191248-d0061a53e358 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
Expand Down Expand Up @@ -173,11 +173,11 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8 // indirect
github.com/safchain/ethtool v0.0.0-20210803160452-9aa261dae9b1 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/streamrail/concurrent-map v0.0.0-20160823150647-8bf1e9bacbf6 // indirect
github.com/ti-mo/netfilter v0.3.1 // indirect
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f // indirect
go.etcd.io/etcd/api/v3 v3.5.1 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
Expand Down
308 changes: 290 additions & 18 deletions go.sum

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions pkg/agent/cniserver/interface_configuration_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"time"

cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ip"
"github.com/containernetworking/plugins/pkg/ipam"
"github.com/containernetworking/plugins/pkg/ns"
Expand All @@ -37,7 +37,6 @@ import (
netlinkutil "antrea.io/antrea/pkg/agent/util/netlink"
cnipb "antrea.io/antrea/pkg/apis/cni/v1beta1"
"antrea.io/antrea/pkg/ovs/ovsconfig"
cniip "antrea.io/antrea/third_party/containernetworking/ip"
)

// NetDeviceType type Enum
Expand All @@ -48,7 +47,7 @@ const (

// Declared variables for test
var (
ipSetupVethWithName = cniip.SetupVethWithName
ipSetupVethWithName = ip.SetupVethWithName
ipamConfigureIface = ipam.ConfigureIface
ethtoolTXHWCsumOff = ethtool.EthtoolTXHWCsumOff
renameInterface = util.RenameInterface
Expand Down Expand Up @@ -304,9 +303,9 @@ func (ic *ifConfigurator) advertiseContainerAddr(containerNetNS string, containe
}
var targetIPv4, targetIPv6 net.IP
for _, ipc := range result.IPs {
if ipc.Version == "4" {
if ipc.Address.IP.To4() != nil {
targetIPv4 = ipc.Address.IP
} else if ipc.Version == "6" {
} else {
targetIPv6 = ipc.Address.IP
}
}
Expand Down
24 changes: 9 additions & 15 deletions pkg/agent/cniserver/interface_configuration_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"unsafe"

cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -300,52 +300,46 @@ func TestAdvertiseContainerAddr(t *testing.T) {
name: "interface-not-found",
runInNS: true,
result: &current.Result{IPs: []*current.IPConfig{
{Version: "4", Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
{Version: "6", Interface: &interfaceID, Address: ipv6CIDR, Gateway: ipv6Gateway},
{Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
{Interface: &interfaceID, Address: ipv6CIDR, Gateway: ipv6Gateway},
}},
netInterfaceError: fmt.Errorf("unable to find interface"),
}, {
name: "invalid-ipam-result",
runInNS: true,
result: &current.Result{IPs: []*current.IPConfig{
{Version: "5", Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
}},
}, {
name: "advertise-ipv4-only",
runInNS: true,
result: &current.Result{IPs: []*current.IPConfig{
{Version: "4", Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
{Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
}},
advertiseIPv4: true,
}, {
name: "advertise-ipv4-failure",
runInNS: true,
result: &current.Result{IPs: []*current.IPConfig{
{Version: "4", Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
{Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
}},
ipv4ArpingErr: fmt.Errorf("failed to send GARP on interface"),
advertiseIPv4: true,
}, {
name: "advertise-ipv6-only",
runInNS: true,
result: &current.Result{IPs: []*current.IPConfig{
{Version: "6", Interface: &interfaceID, Address: ipv6CIDR, Gateway: ipv6Gateway},
{Interface: &interfaceID, Address: ipv6CIDR, Gateway: ipv6Gateway},
}},
advertiseIPv6: true,
}, {
name: "advertise-ipv6-failure",
runInNS: true,
result: &current.Result{IPs: []*current.IPConfig{
{Version: "6", Interface: &interfaceID, Address: ipv6CIDR, Gateway: ipv6Gateway},
{Interface: &interfaceID, Address: ipv6CIDR, Gateway: ipv6Gateway},
}},
advertiseIPv6: true,
ipv6NDPErr: fmt.Errorf("failed to send IPv6 NDP on interface"),
}, {
name: "advertise-dualstack",
runInNS: true,
result: &current.Result{IPs: []*current.IPConfig{
{Version: "4", Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
{Version: "6", Interface: &interfaceID, Address: ipv6CIDR, Gateway: ipv6Gateway},
{Interface: &interfaceID, Address: ipv4CIDR, Gateway: ipv4Gateway},
{Interface: &interfaceID, Address: ipv6CIDR, Gateway: ipv6Gateway},
}},
advertiseIPv4: true,
advertiseIPv6: true,
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/cniserver/interface_configuration_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/Microsoft/hcsshim"
"github.com/Microsoft/hcsshim/hcn"
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"

Expand Down Expand Up @@ -105,7 +105,7 @@ func (ic *ifConfigurator) delEndpoint(name string) {
// findContainerIPConfig finds a valid IPv4 address since IPv6 is not supported for Windows at this stage.
func findContainerIPConfig(ips []*current.IPConfig) (*current.IPConfig, error) {
for _, ipc := range ips {
if ipc.Version == "4" {
if ipc.Address.IP.To4() != nil {
return ipc, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package cniserver

import (
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
)

type postInterfaceCreateHook func() error
Expand Down
8 changes: 2 additions & 6 deletions pkg/agent/cniserver/ipam/antrea_ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/klog/v2"

Expand Down Expand Up @@ -81,15 +81,13 @@ func getAllocationOwner(args *invoke.Args, k8sArgs *types.K8sArgs, reservedOwner

// Helper to generate IP config and default route, taking IP version into account
func generateIPConfig(ip net.IP, prefixLength int, gwIP net.IP) (*current.IPConfig, *cnitypes.Route) {
ipVersion := "4"
ipAddrBits := 32
dstNet := net.IPNet{
IP: net.ParseIP("0.0.0.0"),
Mask: net.CIDRMask(0, ipAddrBits),
}

if ip.To4() == nil {
ipVersion = "6"
ipAddrBits = 128

dstNet = net.IPNet{
Expand All @@ -103,7 +101,6 @@ func generateIPConfig(ip net.IP, prefixLength int, gwIP net.IP) (*current.IPConf
GW: gwIP,
}
ipConfig := current.IPConfig{
Version: ipVersion,
Address: net.IPNet{IP: ip, Mask: net.CIDRMask(int(prefixLength), ipAddrBits)},
Gateway: gwIP,
}
Expand Down Expand Up @@ -266,8 +263,7 @@ func (d *AntreaIPAM) secondaryNetworkAdd(args *invoke.Args, k8sArgs *types.K8sAr
for _, a := range ipamConf.Addresses {
result.IPs = append(result.IPs, &current.IPConfig{
Address: a.IPNet,
Gateway: a.Gateway,
Version: a.Version})
Gateway: a.Gateway})
}

// Copy routes and DNS from the input IPAM configuration.
Expand Down
3 changes: 2 additions & 1 deletion pkg/agent/cniserver/ipam/antrea_ipam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
cnitypes "github.com/containernetworking/cni/pkg/types"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -51,7 +52,7 @@ var (
testNoAnnotation = "empty"
testJunkAnnotation = "junk"

testCNIVersion = "0.4.0"
testCNIVersion = current.ImplementedSpecVersion
)

func createIPPools(crdClient *fakepoolclient.IPPoolClientset) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/ipam_delegator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/klog/v2"

argtypes "antrea.io/antrea/pkg/agent/cniserver/types"
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/ipam_delegator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"github.com/stretchr/testify/assert"

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/ipam_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"sync"

"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"

"antrea.io/antrea/pkg/agent/cniserver/types"
cnipb "antrea.io/antrea/pkg/apis/cni/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/ipam/ipam_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/containernetworking/cni/pkg/invoke"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/stretchr/testify/assert"

argtypes "antrea.io/antrea/pkg/agent/cniserver/types"
Expand Down
13 changes: 4 additions & 9 deletions pkg/agent/cniserver/ipam/testing/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@ import (
"strings"

"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
)

func GenerateIPAMResult(cniVersion string, ipConfig []string, routeConfig []string, dnsConfig []string) *current.Result {
ipamResult := &current.Result{}
if cniVersion != "" {
ipamResult.CNIVersion = cniVersion
} else {
ipamResult.CNIVersion = "0.3.1"
}
func GenerateIPAMResult(ipConfig []string, routeConfig []string, dnsConfig []string) *current.Result {
ipamResult := &current.Result{CNIVersion: current.ImplementedSpecVersion}
ipamResult.IPs = parseIPs(ipConfig)
ipamResult.Routes = parseRoute(routeConfig)
ipamResult.DNS = types.DNS{Nameservers: dnsConfig}
Expand Down Expand Up @@ -65,7 +60,7 @@ func parseIPs(ips []string) []*current.IPConfig {
func parseIPConfig(ipAddress string, gw string, version string) *current.IPConfig {
ip, ipv4Net, _ := net.ParseCIDR(ipAddress)
ipv4Net.IP = ip
ipConfig := &current.IPConfig{Version: version, Address: *ipv4Net}
ipConfig := &current.IPConfig{Address: *ipv4Net}
if gw != "" {
gateway := net.ParseIP(gw)
ipConfig.Gateway = gateway
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/cniserver/pod_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"net"
"strings"

"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -386,7 +386,7 @@ func (pc *podConfigurator) validateOVSInterfaceConfig(containerID string, contai
}

for _, ipc := range ips {
if ipc.Version == "4" {
if ipc.Address.IP.To4() != nil {
ipv4Addr := util.GetIPv4Addr(containerConfig.IPs)
if ipv4Addr != nil && ipv4Addr.Equal(ipc.Address.IP) {
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/pod_configuration_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package cniserver

import (
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/klog/v2"

"antrea.io/antrea/pkg/agent/interfacestore"
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/pod_configuration_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"

cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/cniserver/pod_configuration_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package cniserver
import (
"fmt"

"github.com/containernetworking/cni/pkg/types/current"
current "github.com/containernetworking/cni/pkg/types/100"
"k8s.io/klog/v2"

"antrea.io/antrea/pkg/agent/interfacestore"
Expand Down
Loading

0 comments on commit be83891

Please sign in to comment.