Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds IPv6 support for generic-veth chaining plugin #16041

Merged
merged 1 commit into from
Jun 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 {
pchaigno marked this conversation as resolved.
Show resolved Hide resolved
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