From: git@ipfire.org
To: ipfire-scm@lists.ipfire.org
Subject: [git.ipfire.org] IPFire 2.x development tree branch, next, updated. 4e341f19b076e906c493347c8a11af5c45efc976
Date: Mon, 09 Mar 2015 16:36:34 +0100 [thread overview]
Message-ID: <20150309153635.0098B21EC3@argus.ipfire.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 12463 bytes --]
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".
The branch, next has been updated
via 4e341f19b076e906c493347c8a11af5c45efc976 (commit)
via 600b99fb315f02cd778b7725cdf54ca95caf095d (commit)
from 5604dc748d0c38a05d2f909aedbe50d8d05684e7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4e341f19b076e906c493347c8a11af5c45efc976
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date: Mon Mar 9 16:36:04 2015 +0100
setup: Remove writing udev rules for network interfaces
commit 600b99fb315f02cd778b7725cdf54ca95caf095d
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date: Mon Mar 9 15:35:57 2015 +0100
network: Configure device names from /var/ipfire/ethernet/settings
Instead of creating a copy of the configuration values and
for better extensibility, we will have udev execute a script
that parses /var/ipfire/ethernet/settings and will return the
correct name of the corresponding device (green0, blue0, ...).
-----------------------------------------------------------------------
Summary of changes:
config/rootfiles/common/armv5tel/initscripts | 2 +
config/rootfiles/common/i586/initscripts | 2 +
config/rootfiles/common/udev | 3 +-
config/udev/60-net.rules | 3 ++
.../udev/network-hotplug-rename | 60 +++++++++++++++++-----
lfs/initscripts | 1 +
lfs/udev | 9 ++--
src/initscripts/init.d/network-trigger | 22 ++++++++
src/setup/netstuff.c | 21 --------
src/setup/networking.c | 1 -
src/setup/setup.h | 1 -
11 files changed, 84 insertions(+), 41 deletions(-)
create mode 100644 config/udev/60-net.rules
copy tools/check_langs.sh => config/udev/network-hotplug-rename (54%)
mode change 100755 => 100644
create mode 100644 src/initscripts/init.d/network-trigger
Difference in files:
diff --git a/config/rootfiles/common/armv5tel/initscripts b/config/rootfiles/common/armv5tel/initscripts
index 53bc64f..05b8cee 100755
--- a/config/rootfiles/common/armv5tel/initscripts
+++ b/config/rootfiles/common/armv5tel/initscripts
@@ -60,6 +60,7 @@ etc/rc.d/init.d/mounttmpfs
#etc/rc.d/init.d/mysql
#etc/rc.d/init.d/netsnmpd
etc/rc.d/init.d/network
+etc/rc.d/init.d/network-trigger
etc/rc.d/init.d/network-vlans
#etc/rc.d/init.d/networking
etc/rc.d/init.d/networking/any
@@ -228,6 +229,7 @@ etc/rc.d/rcsysinit.d/S73swconfig
etc/rc.d/rcsysinit.d/S75firstsetup
etc/rc.d/rcsysinit.d/S80localnet
etc/rc.d/rcsysinit.d/S85firewall
+etc/rc.d/rcsysinit.d/S90network-trigger
etc/rc.d/rcsysinit.d/S91network-vlans
etc/rc.d/rcsysinit.d/S92rngd
etc/rc.d/rc3.d/S15fireinfo
diff --git a/config/rootfiles/common/i586/initscripts b/config/rootfiles/common/i586/initscripts
index 7bab7c4..d4779ab 100755
--- a/config/rootfiles/common/i586/initscripts
+++ b/config/rootfiles/common/i586/initscripts
@@ -62,6 +62,7 @@ etc/rc.d/init.d/mounttmpfs
#etc/rc.d/init.d/mysql
#etc/rc.d/init.d/netsnmpd
etc/rc.d/init.d/network
+etc/rc.d/init.d/network-trigger
etc/rc.d/init.d/network-vlans
#etc/rc.d/init.d/networking
etc/rc.d/init.d/networking/any
@@ -233,6 +234,7 @@ etc/rc.d/rcsysinit.d/S70console
etc/rc.d/rcsysinit.d/S75firstsetup
etc/rc.d/rcsysinit.d/S80localnet
etc/rc.d/rcsysinit.d/S85firewall
+etc/rc.d/rcsysinit.d/S90network-trigger
etc/rc.d/rcsysinit.d/S91network-vlans
etc/rc.d/rcsysinit.d/S92rngd
etc/rc.d/rc3.d/S15fireinfo
diff --git a/config/rootfiles/common/udev b/config/rootfiles/common/udev
index bc1cdaa..d01c461 100644
--- a/config/rootfiles/common/udev
+++ b/config/rootfiles/common/udev
@@ -2,7 +2,6 @@ bin/udevadm
etc/modprobe.d/blacklist.conf
etc/udev
#etc/udev/rules.d
-#etc/udev/rules.d/30-persistent-network.rules
#etc/udev/rules.d/55-lfs.rules
#etc/udev/rules.d/81-cdrom.rules
#etc/udev/rules.d/83-cdrom-symlinks.rules
@@ -29,6 +28,7 @@ lib/udev
#lib/udev/hwdb.d/60-keyboard.hwdb
#lib/udev/init-net-rules.sh
#lib/udev/mtd_probe
+#lib/udev/network-hotplug-rename
#lib/udev/rule_generator.functions
#lib/udev/rules.d
#lib/udev/rules.d/25-alsa.rules
@@ -37,6 +37,7 @@ lib/udev
#lib/udev/rules.d/50-udev-default.rules
#lib/udev/rules.d/60-cdrom_id.rules
#lib/udev/rules.d/60-keyboard.rules
+#lib/udev/rules.d/60-net.rules
#lib/udev/rules.d/60-persistent-alsa.rules
#lib/udev/rules.d/60-persistent-input.rules
#lib/udev/rules.d/60-persistent-serial.rules
diff --git a/config/udev/60-net.rules b/config/udev/60-net.rules
new file mode 100644
index 0000000..4f22a1e
--- /dev/null
+++ b/config/udev/60-net.rules
@@ -0,0 +1,3 @@
+# Call a script that checks for the right name of the new device.
+# If it matches the configuration it will be renamed accordingly.
+ACTION=="add", SUBSYSTEM=="net", PROGRAM="/lib/udev/network-hotplug-rename", RESULT=="?*", NAME="$result"
diff --git a/config/udev/network-hotplug-rename b/config/udev/network-hotplug-rename
new file mode 100644
index 0000000..331b788
--- /dev/null
+++ b/config/udev/network-hotplug-rename
@@ -0,0 +1,75 @@
+#!/bin/bash
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2015 IPFire Team <info(a)ipfire.org> #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+# Check if all appropriate variables are set
+[ -n "${INTERFACE}" ] || exit 2
+
+# Ignore virtual interfaces, etc.
+case "${INTERFACE}" in
+ lo)
+ exit 0
+ ;;
+ tun*)
+ exit 0
+ ;;
+ ppp*)
+ exit 0
+ ;;
+esac
+
+# Check if INTERFACE actually exists
+[ -d "/sys/class/net/${INTERFACE}" ] || exit 1
+
+# If the network configuration is not readable,
+# we cannot go on.
+if [ ! -r "/var/ipfire/ethernet/settings" ]; then
+ exit 1
+fi
+
+# Read network settings
+eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
+
+# Standard zones
+ZONES="RED GREEN ORANGE BLUE"
+
+# Determine the address of INTERFACE
+ADDRESS="$(</sys/class/net/${INTERFACE}/address)"
+
+# Walk through all zones and find the matching interface
+for zone in ${ZONES}; do
+ address="${zone}_MACADDR"
+ device="${zone}_DEV"
+
+ # Skip if address or device is unset
+ [ -n "${!address}" -a -n "${!device}" ] || continue
+
+ # If a matching interface has been found we will
+ # print the name to which udev will rename it.
+ if [ "${ADDRESS}" = "${!address}" ]; then
+ echo "${!device}"
+ exit 0
+ fi
+done
+
+# If we get here we have not found a matching device,
+# but we won't return an error any way. The new device
+# will remain with the previous name.
+exit 0
diff --git a/lfs/initscripts b/lfs/initscripts
index f656c72..4005941 100755
--- a/lfs/initscripts
+++ b/lfs/initscripts
@@ -176,6 +176,7 @@ $(TARGET) :
ln -sf ../init.d/firstsetup /etc/rc.d/rcsysinit.d/S75firstsetup
ln -sf ../init.d/localnet /etc/rc.d/rcsysinit.d/S80localnet
ln -sf ../init.d/firewall /etc/rc.d/rcsysinit.d/S85firewall
+ ln -sf ../init.d/network-trigger /etc/rc.d/rcsysinit.d/S90network-trigger
ln -sf ../init.d/network-vlans /etc/rc.d/rcsysinit.d/S91network-vlans
ln -sf ../init.d/rngd /etc/rc.d/rcsysinit.d/S92rngd
ln -sf ../init.d/wlanclient /etc/rc.d/rc0.d/K82wlanclient
diff --git a/lfs/udev b/lfs/udev
index 15dae81..e58839c 100644
--- a/lfs/udev
+++ b/lfs/udev
@@ -93,9 +93,6 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
rm -f /lib/udev/rules.d/75-persistent-net-generator.rules
rm -f /lib/udev/rules.d/80-net-name-slot.rules
- # Create rule file for the setup
- touch /etc/udev/rules.d/30-persistent-network.rules
-
# Blacklist some modules
cp -vf $(DIR_SRC)/config/udev/blacklist.conf /etc/modprobe.d/blacklist.conf
@@ -107,6 +104,12 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
install -v -m 644 $(DIR_SRC)/config/udev/25-alsa.rules \
/lib/udev/rules.d
+ # Install network rules.
+ install -v -m 755 $(DIR_SRC)/config/udev/network-hotplug-rename \
+ /lib/udev/network-hotplug-rename
+ install -v -m 644 $(DIR_SRC)/config/udev/60-net.rules \
+ /lib/udev/rules.d
+
# Install hwrng rules.
install -v -m 644 $(DIR_SRC)/config/udev/90-hwrng.rules \
/lib/udev/rules.d
diff --git a/src/initscripts/init.d/network-trigger b/src/initscripts/init.d/network-trigger
new file mode 100644
index 0000000..0d9de45
--- /dev/null
+++ b/src/initscripts/init.d/network-trigger
@@ -0,0 +1,22 @@
+#!/bin/sh
+########################################################################
+# Begin $rc_base/init.d/network-trigger
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+case "${1}" in
+ start)
+ boot_mesg "Triggering network devices..."
+ udevadm trigger --action="add" --subsystem-match="net"
+ evaluate_retval
+ ;;
+
+ *)
+ echo "Usage: ${0} {start}"
+ exit 1
+ ;;
+esac
+
+# End $rc_base/init.d/network-trigger
diff --git a/src/setup/netstuff.c b/src/setup/netstuff.c
index a656e9f..f5b3849 100644
--- a/src/setup/netstuff.c
+++ b/src/setup/netstuff.c
@@ -527,27 +527,6 @@ int rename_nics(void) {
}
}
-int create_udev(void)
-{
- #define UDEV_NET_CONF "/etc/udev/rules.d/30-persistent-network.rules"
- FILE *fp;
- int i;
-
- if ( (fp = fopen(UDEV_NET_CONF, "w")) == NULL ) {
- fprintf(stderr,"Couldn't open" UDEV_NET_CONF);
- return 1;
- }
-
- for (i = 0 ; i < 4 ; i++)
- {
- if (strcmp(knics[i].macaddr, "")) {
- fprintf(fp,"\n# %s\nACTION==\"add\", SUBSYSTEM==\"net\", ATTR{type}==\"1\", ATTR{address}==\"%s\", NAME=\"%s0\"\n", knics[i].description, knics[i].macaddr, lcolourcard[i]);
- }
- }
- fclose(fp);
- return 0;
-}
-
int write_configs_netudev(int card , int colour)
{
char commandstring[STRING_SIZE];
diff --git a/src/setup/networking.c b/src/setup/networking.c
index df4f00f..0791764 100644
--- a/src/setup/networking.c
+++ b/src/setup/networking.c
@@ -117,7 +117,6 @@ int handlenetworking(void)
} else {
rename_nics();
}
- create_udev();
return 1;
}
diff --git a/src/setup/setup.h b/src/setup/setup.h
index 388d2ed..14fd646 100644
--- a/src/setup/setup.h
+++ b/src/setup/setup.h
@@ -79,7 +79,6 @@ void networkdialogcallbacktype(newtComponent cm, void *data);
int interfacecheck(struct keyvalue *kv, char *colour);
int rename_nics(void);
int init_knics(void);
-int create_udev(void);
int scan_network_cards(void);
int nicmenu(int colour);
int clear_card_entry(int cards);
hooks/post-receive
--
IPFire 2.x development tree
reply other threads:[~2015-03-09 15:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150309153635.0098B21EC3@argus.ipfire.org \
--to=git@ipfire.org \
--cc=ipfire-scm@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox