clearfog: bridge over all ethernet interfaces with STP enabled

This is close to what the OpenROADM MSA suggests (they use RSTP, and we
don't have the mstpd in place for that, yet).

I'm using an extra generator because I need to specify which MAC address
to use for the bridge (that's important for DHCP). I could probably
generate a drop-in or something, but hey, this big hammer works. The
reason for having to use a dynamic thing is that there's no
systemd-networkd feature to specify "please use MAC from the first
iface" - -so one has to read that data and write out a config file just
for that.

Change-Id: Ia12b53a93cbfe83c6c3e0472cd1910c4918e9abb
diff --git a/board/czechlight/clearfog/overlay/usr/lib/systemd/network/br0.network b/board/czechlight/clearfog/overlay/usr/lib/systemd/network/br0.network
new file mode 100644
index 0000000..756e9f1
--- /dev/null
+++ b/board/czechlight/clearfog/overlay/usr/lib/systemd/network/br0.network
@@ -0,0 +1,5 @@
+[Match]
+Name=br0
+
+[Network]
+DHCP=yes
diff --git a/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth0.network b/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth0.network
index 16ac288..50bb37c 100644
--- a/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth0.network
+++ b/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth0.network
@@ -1,4 +1,7 @@
 [Match]
 Name=eth0
+
 [Network]
-DHCP=yes
+Bridge=br0
+LLDP=true
+EmitLLDP=nearest-bridge
diff --git a/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth1.network b/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth1.network
index c13511b..c83f5aa 100644
--- a/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth1.network
+++ b/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth1.network
@@ -1,4 +1,7 @@
 [Match]
 Name=eth1
+
 [Network]
-DHCP=yes
+Bridge=br0
+LLDP=true
+EmitLLDP=nearest-bridge
diff --git a/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth2.network b/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth2.network
index 4196824..9b10d22 100644
--- a/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth2.network
+++ b/board/czechlight/clearfog/overlay/usr/lib/systemd/network/eth2.network
@@ -1,4 +1,7 @@
 [Match]
 Name=eth2
+
 [Network]
-DHCP=yes
+Bridge=br0
+LLDP=true
+EmitLLDP=nearest-bridge
diff --git a/board/czechlight/clearfog/overlay/usr/lib/systemd/system-generators/czechlight-br0-clone-mac b/board/czechlight/clearfog/overlay/usr/lib/systemd/system-generators/czechlight-br0-clone-mac
new file mode 100755
index 0000000..a87a67c
--- /dev/null
+++ b/board/czechlight/clearfog/overlay/usr/lib/systemd/system-generators/czechlight-br0-clone-mac
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+
+# got to override the lock dir as /var is not available yet
+ETH0_MAC=$(/sbin/fw_printenv -n eth1addr -l $1)
+
+mkdir -p /run/systemd/network
+
+cat > /run/systemd/network/00-br0-cloned-mac.netdev <<EOF
+[NetDev]
+Name=br0
+Kind=bridge
+MACAddress=${ETH0_MAC}
+HelloTimeSec=1
+ForwardDelaySec=4
+[Bridge]
+STP=1
+EOF
+
+/bin/rm -f /run/systemd/generator/fw_printenv.lock