Skip to content

Commit

Permalink
Adds IPv6 support for generic-veth chaining plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Weilong Cui <cuiwl@google.com>
  • Loading branch information
Weil0ng committed Jun 2, 2021
1 parent e92dc6a commit 2b67103
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions plugins/cilium-cni/chaining/generic-veth/generic-veth.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ func (f *GenericVethChainer) Add(ctx context.Context, pluginCtx chainingapi.Plug
}
}()
var (
hostMac, vethHostName, vethLXCMac, vethIP string
vethHostIdx, peerIndex int
peer netlink.Link
netNs ns.NetNS
hostMac, vethHostName, vethLXCMac, vethIP, vethIPv6 string
vethHostIdx, peerIndex int
peer netlink.Link
netNs ns.NetNS
)

netNs, err = ns.GetNS(pluginCtx.Args.Netns)
Expand Down Expand Up @@ -107,6 +107,15 @@ func (f *GenericVethChainer) Add(ctx context.Context, pluginCtx chainingapi.Plug
}

vethIP = addrs[0].IPNet.IP.String()

addrsv6, err := netlink.AddrList(link, netlink.FAMILY_V6)
if err == nil && len(addrsv6) > 0 {
vethIPv6 = addrsv6[0].IPNet.IP.String()
} else if err != nil {
pluginCtx.Logger.WithError(err).WithFields(logrus.Fields{
logfields.Interface: link.Attrs().Name}).Warn("No valid IPv6 address found")
}

return nil
}

Expand Down Expand Up @@ -144,6 +153,7 @@ func (f *GenericVethChainer) Add(ctx context.Context, pluginCtx chainingapi.Plug
ep := &models.EndpointChangeRequest{
Addressing: &models.AddressPair{
IPV4: vethIP,
IPV6: vethIPv6,
},
ContainerID: pluginCtx.Args.ContainerID,
State: models.EndpointStateWaitingForIdentity,
Expand Down

0 comments on commit 2b67103

Please sign in to comment.