Skip to content

Commit d8481bc

Browse files
HadrienPattedatadog-compute-robot
authored andcommitted
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 f6f474b commit d8481bc

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
@@ -892,6 +892,11 @@ func tapNetworkPair(ctx context.Context, endpoint Endpoint, queues int, disableV
892892
// bridge created by the network plugin on the host actually expects
893893
// to see traffic from this MAC address and not another one.
894894
tapHardAddr := attrs.HardwareAddr
895+
if len(attrs.HardwareAddr) == 0 {
896+
// L3 devices (e.g., netkit in L3 mode) have no MAC address and are not currently supported.
897+
// They require IP routing instead of L2 bridging, which is not yet implemented.
898+
return fmt.Errorf("Device %s has no MAC address (netkit L3 mode is not supported - use netkit L2 mode or veth devices)", attrs.Name)
899+
}
895900
netPair.TAPIface.HardAddr = attrs.HardwareAddr.String()
896901

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

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

0 commit comments

Comments
 (0)