Skip to content

Commit ee627e3

Browse files
HadrienPatteTheRayquaza
authored andcommitted
[datadog] runtime: Reject netkit L3 devices with clear error
Netkit devices in L3 mode have no MAC address and require IP routing instead of L2 bridging. Since L3 routing is not currently implemented, reject these devices early with a clear error message directing users to use netkit L2 mode or veth devices instead. Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
1 parent a0d46db commit ee627e3

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/runtime/virtcontainers/network_linux.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,11 @@ func tapNetworkPair(ctx context.Context, endpoint Endpoint, queues int, disableV
10361036
// bridge created by the network plugin on the host actually expects
10371037
// to see traffic from this MAC address and not another one.
10381038
tapHardAddr := attrs.HardwareAddr
1039+
if len(attrs.HardwareAddr) == 0 {
1040+
// L3 devices (e.g., netkit in L3 mode) have no MAC address and are not currently supported.
1041+
// They require IP routing instead of L2 bridging, which is not yet implemented.
1042+
return fmt.Errorf("Device %s has no MAC address (netkit L3 mode is not supported - use netkit L2 mode or veth devices)", attrs.Name)
1043+
}
10391044
netPair.TAPIface.HardAddr = attrs.HardwareAddr.String()
10401045

10411046
if err := netHandle.LinkSetMTU(tapLink, attrs.MTU); err != nil {
@@ -1133,6 +1138,11 @@ func setupTCFiltering(ctx context.Context, endpoint Endpoint, queues int, disabl
11331138
// the one inside the VM in order to avoid any firewall issues. The
11341139
// bridge created by the network plugin on the host actually expects
11351140
// to see traffic from this MAC address and not another one.
1141+
if len(attrs.HardwareAddr) == 0 {
1142+
// L3 devices (e.g., netkit in L3 mode) have no MAC address and are not currently supported.
1143+
// They require IP routing instead of L2 bridging, which is not yet implemented.
1144+
return fmt.Errorf("Device %s has no MAC address (netkit L3 mode is not supported - use netkit L2 mode or veth devices)", attrs.Name)
1145+
}
11361146
netPair.TAPIface.HardAddr = attrs.HardwareAddr.String()
11371147

11381148
if err := netHandle.LinkSetMTU(tapLink, attrs.MTU); err != nil {

0 commit comments

Comments
 (0)