networkmanager-conf: Add support for bridge to user-module

This is a setup required for the factory testing image: the user module
must be reachable from the CPU. And since the subnet of the fct ethernet
port and the subnet of the user module are the same, we must bridge them
together.

BugzID: 81969
This commit is contained in:
Alexandre Bard 2022-11-14 15:50:31 +01:00
parent 6fa868f2d4
commit 230743c03d
3 changed files with 47 additions and 6 deletions

View File

@ -1,5 +1,3 @@
inherit allarch
DESCRIPTION = "Configuration files for NetworkManager" DESCRIPTION = "Configuration files for NetworkManager"
LICENSE = "Proprietary" LICENSE = "Proprietary"
@ -8,13 +6,15 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Proprietary;md
RDEPENDS_${PN} = "networkmanager" RDEPENDS_${PN} = "networkmanager"
PACKAGECONFIG ?= "" PACKAGECONFIG ?= ""
DEFAULT_ETH ??= "eth0" export DEFAULT_ETH ??= "eth0"
PACKAGECONFIG[unmanaged-devices] = "" PACKAGECONFIG[unmanaged-devices] = ""
PACKAGECONFIG[ethernet-dhcp] = "" PACKAGECONFIG[ethernet-dhcp] = ""
SRC_URI = " \ SRC_URI = " \
file://eth0-static \ file://eth0-static \
file://eth0-dhcp \ file://eth0-dhcp \
file://bridge-slave-eth0.nmconnection \
file://bridge-slave-umnet0.nmconnection \
file://NetworkManager.conf \ file://NetworkManager.conf \
file://00-fallback-dns.conf \ file://00-fallback-dns.conf \
file://unmanaged-devices.conf \ file://unmanaged-devices.conf \
@ -25,6 +25,8 @@ SRC_URI_append_am335x-nrhw20 = " \
file://system-connections-dhcp.tar.gz \ file://system-connections-dhcp.tar.gz \
" "
PACKAGE_ARCH = "${MACHINE_ARCH}"
do_install () { do_install () {
install -d ${D}${sysconfdir}/NetworkManager/dnsmasq.d install -d ${D}${sysconfdir}/NetworkManager/dnsmasq.d
install -d ${D}${sysconfdir}/NetworkManager/system-connections install -d ${D}${sysconfdir}/NetworkManager/system-connections
@ -37,11 +39,24 @@ do_install () {
install -m 0600 ${WORKDIR}/eth0-static ${D}${sysconfdir}/NetworkManager/system-connections/eth0.nmconnection install -m 0600 ${WORKDIR}/eth0-static ${D}${sysconfdir}/NetworkManager/system-connections/eth0.nmconnection
fi fi
# If the distro supports the user module we must bridge eth0 and umnet0
# and configure br0 instead of eth0
if ${@bb.utils.contains('COMBINED_FEATURES','user-module','true','false',d)}; then
DEFAULT_ETH="br0"
install -m 0600 ${WORKDIR}/bridge-slave-eth0.nmconnection ${D}${sysconfdir}/NetworkManager/system-connections/
install -m 0600 ${WORKDIR}/bridge-slave-umnet0.nmconnection ${D}${sysconfdir}/NetworkManager/system-connections/
# Change type of main connection to bridge
sed -i "s/type=.*/type=bridge/g" ${D}${sysconfdir}/NetworkManager/system-connections/eth0.nmconnection
printf "\n[bridge]\nstp=false\n" >> ${D}${sysconfdir}/NetworkManager/system-connections/eth0.nmconnection
fi
# Handle HWs with different default interface # Handle HWs with different default interface
if [ "${DEFAULT_ETH}" != "eth0" ]; then if [ "$DEFAULT_ETH" != "eth0" ]; then
sed -i 's/eth0/${DEFAULT_ETH}/g' ${D}${sysconfdir}/NetworkManager/system-connections/* # Replace interface name
sed -i "s/eth0/$DEFAULT_ETH/g" ${D}${sysconfdir}/NetworkManager/system-connections/eth0.nmconnection
mv ${D}${sysconfdir}/NetworkManager/system-connections/eth0.nmconnection \ mv ${D}${sysconfdir}/NetworkManager/system-connections/eth0.nmconnection \
${D}${sysconfdir}/NetworkManager/system-connections/${DEFAULT_ETH}.nmconnection ${D}${sysconfdir}/NetworkManager/system-connections/$DEFAULT_ETH.nmconnection
fi fi

View File

@ -0,0 +1,13 @@
[connection]
id=bridge-slave-eth0
uuid=06ecc0bb-7408-4ddd-b55c-dbb735c1d030
type=ethernet
interface-name=eth0
master=br0
permissions=
slave-type=bridge
[ethernet]
mac-address-blacklist=
[bridge-port]

View File

@ -0,0 +1,13 @@
[connection]
id=bridge-slave-umnet0
uuid=128dbe32-f484-4062-9bc5-31f90bfb1063
type=ethernet
interface-name=umnet0
master=br0
permissions=
slave-type=bridge
[ethernet]
mac-address-blacklist=
[bridge-port]