diff options
author | 2020-03-17 05:32:22 +0000 | |
---|---|---|
committer | 2020-09-17 16:24:55 -0700 | |
commit | 62079e3b34f2f7ce7f04dc42e305c32bb719bd57 (patch) | |
tree | d1b39c0dccaf863fee4052c3bd4ae4e02836a0c4 /cmd/ovn4nfvk8s-cni/app | |
parent | 342d8470b54ca175756d0216c9f5294fd69746ec (diff) |
adding primary network features
- adding docker build bugfixes
- Removing the dependence on Multus
- ovn4nfv-k8s CNI will be default or cluster networking
- ovn4nfv-k8s creates ovn overlay mutli-networking using pod annotations itself
- remove the outdated unit test
Based on the Ritu(ovn4nfv-k8s-plugin committer) patches
Change-Id: Ic48bd11d746e6339075fb3ba33f12463bb3f218d
Co-authored-by: Ritu Sood <ritu.sood@intel.com>
Signed-off-by: Kuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>
Change-Id: I9702bbd2d4aa23157052258ef6b363bc7b472a63
Diffstat (limited to 'cmd/ovn4nfvk8s-cni/app')
-rw-r--r-- | cmd/ovn4nfvk8s-cni/app/helper_linux.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/cmd/ovn4nfvk8s-cni/app/helper_linux.go b/cmd/ovn4nfvk8s-cni/app/helper_linux.go index 676901e..2dba628 100644 --- a/cmd/ovn4nfvk8s-cni/app/helper_linux.go +++ b/cmd/ovn4nfvk8s-cni/app/helper_linux.go @@ -6,7 +6,7 @@ import ( "fmt" "net" "os/exec" - "regexp" + "strconv" "strings" "github.com/sirupsen/logrus" @@ -37,7 +37,7 @@ func renameLink(curName, newName string) error { return nil } -func setupInterface(netns ns.NetNS, containerID, ifName, macAddress, ipAddress, gatewayIP, defaultGateway string, mtu int) (*current.Interface, *current.Interface, error) { +func setupInterface(netns ns.NetNS, containerID, ifName, macAddress, ipAddress, gatewayIP, defaultGateway string, idx, mtu int) (*current.Interface, *current.Interface, error) { hostIface := ¤t.Interface{} contIface := ¤t.Interface{} @@ -97,9 +97,7 @@ func setupInterface(netns ns.NetNS, containerID, ifName, macAddress, ipAddress, } // rename the host end of veth pair - re := regexp.MustCompile("(\\d+)\\D*\\z") - index := re.FindAllString(ifName, -1) - hostIface.Name = containerID[:14] + index[0] + hostIface.Name = containerID[:14] + strconv.Itoa(idx) if err := renameLink(oldHostVethName, hostIface.Name); err != nil { return nil, nil, fmt.Errorf("failed to rename %s to %s: %v", oldHostVethName, hostIface.Name, err) } @@ -108,21 +106,24 @@ func setupInterface(netns ns.NetNS, containerID, ifName, macAddress, ipAddress, } // ConfigureInterface sets up the container interface -var ConfigureInterface = func(args *skel.CmdArgs, namespace, podName, macAddress, ipAddress, gatewayIP, interfaceName, defaultGateway string, mtu int) ([]*current.Interface, error) { +var ConfigureInterface = func(args *skel.CmdArgs, namespace, podName, macAddress, ipAddress, gatewayIP, interfaceName, defaultGateway string, idx, mtu int) ([]*current.Interface, error) { netns, err := ns.GetNS(args.Netns) if err != nil { return nil, fmt.Errorf("failed to open netns %q: %v", args.Netns, err) } defer netns.Close() - hostIface, contIface, err := setupInterface(netns, args.ContainerID, interfaceName, macAddress, ipAddress, gatewayIP, defaultGateway, mtu) - if err != nil { - return nil, err - } + var ifaceID string - if interfaceName != "" { + if interfaceName != "*" { ifaceID = fmt.Sprintf("%s_%s_%s", namespace, podName, interfaceName) } else { ifaceID = fmt.Sprintf("%s_%s", namespace, podName) + interfaceName = args.IfName + defaultGateway = "true" + } + hostIface, contIface, err := setupInterface(netns, args.ContainerID, interfaceName, macAddress, ipAddress, gatewayIP, defaultGateway, idx, mtu) + if err != nil { + return nil, err } ovsArgs := []string{ |