Skip to content

Commit f15a28a

Browse files
41ksHadrienPatte
authored andcommitted
cilium-cni: skip ParentInterfaceIndex when IPv4 is disabled in ENI mode
In ENI IPAM mode the CNI plugin derived the endpoint's parent interface index from ipam.IPv4.MasterMac. In IPv6-only clusters IPv4 is not allocated, so ipam.IPv4 is nil and this dereference panicked. ParentInterfaceIndex is only consumed by the IPv4 masquerade datapath (to redirect reply traffic out the endpoint's ENI), so there is nothing to set when IPv4 is disabled. Guard the lookup on ipv4IsEnabled. Signed-off-by: Alex Melhem <alex.melhem@datadoghq.com>
1 parent df80056 commit f15a28a

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

plugins/cilium-cni/cmd/cmd.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,11 +698,18 @@ func (cmd *Cmd) Add(args *skel.CmdArgs) (err error) {
698698
// Prevent cilium agent from trying to release the IP when the endpoint is deleted.
699699
ep.DatapathConfiguration.ExternalIpam = true
700700
case ipamOption.IPAMENI:
701-
ifindex, err := ifindexFromMac(ipam.IPv4.MasterMac)
702-
if err == nil {
703-
ep.ParentInterfaceIndex = ifindex
704-
} else {
705-
scopedLogger.Error("Unable to get interface index from MAC address", logfields.Error, err)
701+
// ParentInterfaceIndex is only consumed by the IPv4 masquerade
702+
// datapath (to redirect reply traffic out the endpoint's ENI), so
703+
// there is nothing to set when IPv4 is disabled.
704+
//
705+
// See nodeport_snat_fwd_ipv4 in bpf/lib/nodeport_egress.h
706+
if ipv4IsEnabled(ipam) {
707+
ifindex, err := ifindexFromMac(ipam.IPv4.MasterMac)
708+
if err == nil {
709+
ep.ParentInterfaceIndex = ifindex
710+
} else {
711+
scopedLogger.Error("Unable to get interface index from MAC address", logfields.Error, err)
712+
}
706713
}
707714
}
708715

0 commit comments

Comments
 (0)