diff --git a/board/aarch64/linux_defconfig b/board/aarch64/linux_defconfig index 7583f6cd..5b267563 100644 --- a/board/aarch64/linux_defconfig +++ b/board/aarch64/linux_defconfig @@ -129,6 +129,8 @@ CONFIG_UEVENT_HELPER=y CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y +CONFIG_FW_CFG_SYSFS=y +CONFIG_FW_CFG_SYSFS_CMDLINE=y CONFIG_MTD=y CONFIG_MTD_BLOCK=y CONFIG_MTD_BLOCK2MTD=y diff --git a/board/amd64/linux_defconfig b/board/amd64/linux_defconfig index 5d1860ff..1f3d8956 100644 --- a/board/amd64/linux_defconfig +++ b/board/amd64/linux_defconfig @@ -61,6 +61,8 @@ CONFIG_NET_9P_VIRTIO=y CONFIG_PCI=y CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y +CONFIG_FW_CFG_SYSFS=y +CONFIG_FW_CFG_SYSFS_CMDLINE=y CONFIG_VIRTIO_BLK=y CONFIG_BLK_DEV_SD=y CONFIG_SCSI_VIRTIO=y diff --git a/board/common/rootfs/lib/infix/swup b/board/common/rootfs/lib/infix/swup index 1f7f864d..f2a52bf2 100755 --- a/board/common/rootfs/lib/infix/swup +++ b/board/common/rootfs/lib/infix/swup @@ -5,11 +5,14 @@ ident=$(basename "$0") num=0 -# Perform any interface renames as dictated by /etc/mactab. -if [ -f /etc/mactab ]; then - logger -k -p user.notice -t "$ident" "calling nameif -c /etc/mactab" - nameif -s -fi +# Perform any interface renames as dictated by, first, any Qemu +# override (for testing), and then the user specific /etc/mactab +for file in /sys/firmware/qemu_fw_cfg/by_name/opt/mactab/raw /etc/mactab; do + if [ -f $file ]; then + logger -k -p user.notice -t "$ident" "calling nameif -c $file" + nameif -c $file -s + fi +done # Find CPU interfaces used for connecting to a switch managed by DSA for netif in /sys/class/net/*; do @@ -37,3 +40,30 @@ ports=$(devlink port 2>/dev/null | awk '/flavour physical/{print $5}') for iface in $ports; do ip link set "$iface" group port done + +# Testing, e.g., using /etc/mactab may use TAP devices to create +# emulated switch ports, make sure to mark them as well +ports=$(ip -json link | jq -r '.[].ifname | match("^e[[:digit:]]+").string') +for iface in $ports; do + ip link set "$iface" group port +done + +# Factory default: all switch ports in VLAN 1 of br0 +# need to check for 'length > 0' because ip command +# outputs empty json objects for non-port group ifs +ports=$(ip -json link show group port | jq -r '.[].ifname | select(length > 0)' | tr "\n" " ") +if [ ! -f /etc/network/interfaces.d/br0 ] && [ -n "$ports" ]; then + cat <<-EOF >/etc/network/interfaces.d/br0 + auto br0 + iface br0 + bridge-ports $ports + bridge-vlan-aware yes + bridge-stp on + bridge-vids 1 + + auto vlan1 + iface vlan1 inet dhcp + vlan-id 1 + vlan-raw-device br0 + EOF +fi diff --git a/qemu/qemu.sh b/qemu/qemu.sh index 2d0c27aa..74be3aa5 100755 --- a/qemu/qemu.sh +++ b/qemu/qemu.sh @@ -71,9 +71,13 @@ net_args() echo -n "-nic bridge,br=$QEMU_NET_BRIDGE_DEV,model=$QEMU_NET_MODEL " elif [ "$QEMU_NET_TAP" = "y" ]; then QEMU_NET_TAP_N=${QEMU_NET_TAP_N:-1} + mactab=$(dirname "$QEMU_ROOTFS")/mactab + rm "$mactab" for i in $(seq 0 $(($QEMU_NET_TAP_N - 1))); do - echo -n "-nic tap,ifname=qtap$i,script=no,model=$QEMU_NET_MODEL " + echo "e$i 52:54:00:12:34:$((56 + i))" >>"$mactab" + echo -n "-nic tap,ifname=qtap$i,script=no,model=$QEMU_NET_MODEL " done + echo -n "-fw_cfg name=opt/mactab,file="$mactab" " elif [ "$QEMU_NET_USER" = "y" ]; then [ "$QEMU_NET_USER_OPTS" ] && QEMU_NET_USER_OPTS="$QEMU_NET_USER_OPTS,"