From e7dc1e42cdf519c20c9f104153ef778462fcdbd9 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 5 Jul 2012 12:54:13 +0200 Subject: [PATCH] network: factor out parse_ifname_opts() for ifname-genrules --- modules.d/40network/ifname-genrules.sh | 2 ++ modules.d/40network/net-lib.sh | 16 ++++++++++++++++ modules.d/40network/parse-ifname.sh | 16 +--------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/modules.d/40network/ifname-genrules.sh b/modules.d/40network/ifname-genrules.sh index e188c88..b0b429c 100755 --- a/modules.d/40network/ifname-genrules.sh +++ b/modules.d/40network/ifname-genrules.sh @@ -7,6 +7,8 @@ if ! getarg ifname= >/dev/null ; then return fi +command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh + { for p in $(getargs ifname=); do parse_ifname_opts $p diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index 9132e4d..9a1e004 100644 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -289,3 +289,19 @@ ip_to_var() { esac fi } + +parse_ifname_opts() { + local IFS=: + set $1 + + case $# in + 7) + ifname_if=$1 + # udev requires MAC addresses to be lower case + ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/') + ;; + *) + die "Invalid arguments for ifname=" + ;; + esac +} diff --git a/modules.d/40network/parse-ifname.sh b/modules.d/40network/parse-ifname.sh index ce73a72..d5156b3 100755 --- a/modules.d/40network/parse-ifname.sh +++ b/modules.d/40network/parse-ifname.sh @@ -18,21 +18,7 @@ if ! getarg ifname= >/dev/null ; then return fi -parse_ifname_opts() { - local IFS=: - set $1 - - case $# in - 7) - ifname_if=$1 - # udev requires MAC addresses to be lower case - ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/') - ;; - *) - die "Invalid arguments for ifname=" - ;; - esac -} +command -v parse_ifname_opts >/dev/null || . /lib/net-lib.sh # Check ifname= lines for p in $(getargs ifname=); do