[Server-devel] [PATCH] New network infrastructure - udev scripts
Martin Langhoff
martin at laptop.org
Tue Aug 26 23:43:24 EDT 2008
From: Jerry Vonau <jvonau at shaw.ca>
Add the udev-based infrastructure
- etc/udev/rules.d/65-xsmeshnames.rules kicks in
before the stock fedora scripts have a chance
and names the "ethN" address as "wlanN" with
an N that matches the mshN device.
- udev-mesh-namer is the script that does the
name-picking magic
- ifup-local will bring up the device "pairs"
in tandem
- Disable NM, enable good old 'networking'
Credit: Jerry Vonau <jvonau at shaw.ca>
---
Makefile | 8 ++++-
altfiles/etc/udev/rules.d/65-xsmeshnames.rules | 15 ++++++++
scripts/ifup-local | 33 ++++++++++++++++++
scripts/udev-mesh-namer | 42 ++++++++++++++++++++++++
xs-config.spec.in | 16 ++++-----
5 files changed, 104 insertions(+), 10 deletions(-)
create mode 100644 altfiles/etc/udev/rules.d/65-xsmeshnames.rules
create mode 100755 scripts/ifup-local
create mode 100755 scripts/udev-mesh-namer
diff --git a/Makefile b/Makefile
index b8ba60a..d60d334 100644
--- a/Makefile
+++ b/Makefile
@@ -179,7 +179,8 @@ install: $(DESTDIR)
install -D altfiles/etc/dhclient-exit-hooks $(DESTDIR)/etc
install -D -d $(DESTDIR)/etc/udev/rules.d
- install -D altfiles/etc/udev/rules.d/10-olpcmesh.rules $(DESTDIR)/etc/udev/rules.d
+ install -D altfiles/etc/udev/rules.d/10-olpcmesh.rules $(DESTDIR)/etc/udev/rules.d
+ install -D altfiles/etc/udev/rules.d/65-xsmeshnames.rules $(DESTDIR)/etc/udev/rules.d
install -D -d $(DESTDIR)/etc/init.d
install -D altfiles/etc/init.d/olpc-network-config $(DESTDIR)/etc/init.d
@@ -197,3 +198,8 @@ install: $(DESTDIR)
install -D scripts/xs-commitchanged $(DESTDIR)/usr/bin
install -D scripts/cat-parts $(DESTDIR)/usr/bin
+ install -D -d $(DESTDIR)/sbin
+ install -D scripts/ifup-local $(DESTDIR)/sbin
+
+ install -D -d $(DESTDIR)/lib/udev
+ install -D scripts/udev-mesh-namer $(DESTDIR)/lib/udev/mesh-namer
diff --git a/altfiles/etc/udev/rules.d/65-xsmeshnames.rules b/altfiles/etc/udev/rules.d/65-xsmeshnames.rules
new file mode 100644
index 0000000..628bd1f
--- /dev/null
+++ b/altfiles/etc/udev/rules.d/65-xsmeshnames.rules
@@ -0,0 +1,15 @@
+## These rules pull in our mesh-namer script
+## which ensures that the "eth*" device gets
+## renamed to wlanN where N matches the mshN
+## device. So the pairs line up:
+##
+## wlan0 == msh0
+## wlan1 == msh1
+## wlan2 == msh2
+##
+## making the rest of the network infra much simpler.
+##
+## Credit: Jerry Vonau <jvonau at shaw.ca>
+##
+ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", ATTRS{idVendor}=="1286", ATTRS{idProduct}=="2001", ENV{INTERFACE_NAME}="msh"
+ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", ATTRS{idVendor}=="1286", ATTRS{idProduct}=="2001", PROGRAM="/lib/udev/mesh-namer", RESULT=="?*", ENV{INTERFACE_NAME}="$result"
\ No newline at end of file
diff --git a/scripts/ifup-local b/scripts/ifup-local
new file mode 100755
index 0000000..9734a8e
--- /dev/null
+++ b/scripts/ifup-local
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# Part of the OLPC XS Scripts
+#
+# Author: Jerry Vonau <jvonau at shaw.ca>
+#
+if [ x${1} = x ]; then
+ exit
+else
+case $1 in
+ wlan0)
+
+ /sbin/ip addr flush dev msh0 2>/dev/null
+ /sbin/ifup msh0
+ ;;
+ wlan1)
+
+ /sbin/ip addr flush dev msh1 2>/dev/null
+ /sbin/ifup msh1
+ ;;
+ wlan2)
+
+ /sbin/ip addr flush dev msh2 2>/dev/null
+ /sbin/ifup msh1
+ ;;
+ msh0)
+ /sbin/ifup br0
+ ;;
+ msh1)
+ /sbin/ifup br1
+ ;;
+esac
+fi
diff --git a/scripts/udev-mesh-namer b/scripts/udev-mesh-namer
new file mode 100755
index 0000000..88499a6
--- /dev/null
+++ b/scripts/udev-mesh-namer
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+#
+# Part of the OLPC XS Scripts
+#
+# Author: Jerry Vonau <jvonau at shaw.ca>
+#
+
+# Grab the interfaces in use
+mshdevs=""
+mshdevs="`ls /sys/class/net/ | grep msh`"
+ethdevs=""
+ethdevs="`ls /sys/class/net/ | grep eth`"
+meshmac=""
+
+# parse by interface return mac addr
+for mshdev in $mshdevs; do
+ meshmac=`udevinfo -a -p /sys/class/net/${mshdev} | grep address`
+#echo $meshmac
+
+# ok, lets look for the matching mac on the eth interface
+
+ for ethdev in $ethdevs; do
+ meshmac2=`udevinfo -a -p /sys/class/net/${ethdev} | grep address`
+#echo $meshmac
+ if [ $meshmac = $meshmac2 ]; then
+# echo "match found"
+ # COOL... now just write the alias names to /rules.d
+ case $mshdev in
+ msh0)
+ echo "wlan0"
+ ;;
+ msh1)
+ echo "wlan1"
+ ;;
+ msh2)
+ echo "wlan2"
+ ;;
+ esac
+ fi
+ done
+done
diff --git a/xs-config.spec.in b/xs-config.spec.in
index 4389475..834c4e1 100644
--- a/xs-config.spec.in
+++ b/xs-config.spec.in
@@ -14,7 +14,7 @@ Requires: nss
Requires: openssh-server
Requires: radvd
Requires: rpm
-Requires: selinux-policy
+Requires: selinux-policy
Requires: setup
Requires: smartmontools
Requires: sudo
@@ -169,13 +169,9 @@ pushd /etc
make -f xs-config.make all
popd
-#
-# If any kernel modules are being installed using this mechanism, you
-# need to depmod them in... however this will sometimes
-# run in a chroot / during livecd creation, and will fail
-# due to a mismatched uname.
-depmod -b %{DESTDIR} -C %{DESTDIR}/etc/depmod.d \
- || echo depmod failed - this is not fatal
+# Change the network infra we use
+chkconfig --add network
+chkconfig --del NetworkManager
chkconfig --add olpc-network-config
chkconfig --add olpc-mesh-config
@@ -249,6 +245,7 @@ fi
%{_sysconfdir}/dhclient-exit-hooks
%{_sysconfdir}/udev/rules.d/10-olpcmesh.rules
+%{_sysconfdir}/udev/rules.d/65-xsmeshnames.rules
%{_sysconfdir}/init.d/olpc-network-config
%{_sysconfdir}/init.d/olpc-mesh-config
%{_sysconfdir}/usbmount/mount.d/01_beep_on_mount
@@ -259,5 +256,6 @@ fi
%{_bindir}/xs-commitchanged
%{_bindir}/cat-parts
-
+/sbin/ifup-local
+/lib/udev/mesh-namer
%doc README
--
1.5.5.1
More information about the Server-devel
mailing list