Skip to content

Commit

Permalink
Bandwidth plugin support (aws#1560)
Browse files Browse the repository at this point in the history
* bandwidth plugin support

* update netns
  • Loading branch information
jayanthvn authored and haouc committed Aug 31, 2021
1 parent 2cd1e45 commit e584b26
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cmd/routed-eni-cni-plugin/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,16 @@ func add(args *skel.CmdArgs, cniTypes typeswrapper.CNITYPES, grpcClient grpcwrap
Mask: net.IPv4Mask(255, 255, 255, 255),
}

var hostVethName string
if r.PodVlanId != 0 {
hostVethName := generateHostVethName("vlan", string(k8sArgs.K8S_POD_NAMESPACE), string(k8sArgs.K8S_POD_NAME))
hostVethName = generateHostVethName("vlan", string(k8sArgs.K8S_POD_NAMESPACE), string(k8sArgs.K8S_POD_NAME))

err = driverClient.SetupPodENINetwork(hostVethName, args.IfName, args.Netns, addr, int(r.PodVlanId), r.PodENIMAC,
r.PodENISubnetGW, int(r.ParentIfIndex), mtu, log)
} else {
// build hostVethName
// Note: the maximum length for linux interface name is 15
hostVethName := generateHostVethName(conf.VethPrefix, string(k8sArgs.K8S_POD_NAMESPACE), string(k8sArgs.K8S_POD_NAME))
hostVethName = generateHostVethName(conf.VethPrefix, string(k8sArgs.K8S_POD_NAMESPACE), string(k8sArgs.K8S_POD_NAME))

err = driverClient.SetupNS(hostVethName, args.IfName, args.Netns, addr, int(r.DeviceNumber), r.VPCcidrs, r.UseExternalSNAT, mtu, log)
}
Expand Down Expand Up @@ -213,15 +214,24 @@ func add(args *skel.CmdArgs, cniTypes typeswrapper.CNITYPES, grpcClient grpcwrap
return errors.Wrap(err, "add command: failed to setup network")
}

containerInterfaceIndex := 1
ips := []*current.IPConfig{
{
Version: "4",
Address: *addr,
Version: "4",
Address: *addr,
Interface: &containerInterfaceIndex,
},
}

hostInterface := &current.Interface{Name: hostVethName}
containerInterface := &current.Interface{Name: args.IfName, Sandbox: args.Netns}

result := &current.Result{
IPs: ips,
Interfaces: []*current.Interface{
hostInterface,
containerInterface,
},
}

return cniTypes.PrintResult(result, conf.CNIVersion)
Expand Down

0 comments on commit e584b26

Please sign in to comment.