[lfs-support] [lfs-dev] /sbin/ifup, MTU, bridging, and CHECK_LINK

Qrux qrux.qed at gmail.com
Sat Feb 25 18:28:51 PST 2012


On Feb 25, 2012, at 5:41 PM, Qrux wrote:

>> On Feb 25, 2012, at 9:14 AM, Bruce Dubbs wrote:
>> 
>>> Qrux wrote:
>>>> Bruce, Nathan, et al.,
>>>> 
>>>> Bridging sort of "inverted" the semantics
>>>> of /lib/lsb/<service> by setting IFACE to the bridge interface.  It
>>>> inverted the semantics in ipv4-static.  I just altered it so the
>>>> semantics are identical.
>>> 
>>> I'm not seeing everything you are saying.  Can you please send me a diff.
>> 
>> TL;DR - I understand where it came from (i.e., using IFACE to specify the bridge), but in the new services implementation, it's cleaner to have service-specific variables to implement service-specific actions and allow IFACE to uniformly refer to the physical link.
>> 
>> Code immediately below; explanations follow.
>> 
>> 	Q

I made a mistake.  In trying to get the "ifconfig.testconfig" working, I broke my own script.  Here's a picture of bridging (it might make it easier to see what I'm talking about):

    ifup ----------------- eth0 -- ${IFACE}
      |
      |
      + bridge -----------  br0 -- ${1}, ${BRIDGE}
      |
      + ipv4-static ------  br0 -- ${1}, ${BRIDGE}

Here's a picture of "normal":

    ifup ----------------- eth0 -- ${IFACE}
      |
      |
      + ipv4-static ------ eth0 -- ${1}, ${IFACE}

So, if we want ifup to be blind to services, (which I think we do), ${IFACE} needs to refer to the link, so it can do link-type stuff (MTU, CHECK_LINK, perhaps other things for PPP, SLIP, exotics, etc).  But, if ifup is blind to downstream services, it has to pass something that makes sense to both scripts, while knowing that each services has access to the entire config file.

But, passing ${IFACE} to /lib/services/bridge breaks it (obviously).  Passing ${1} works in both cases, and just requires introducing a bridge-specific variable.  Voilà--${BRIDGE} solves the problem (as we were going to introduce one anyway).

So, ${1} solves both problems.  If you don't like ${1}, then you could, for example, add a new var for ipv4-static.  I'll probably do a complete rework later.  For now, diffs below (using ${1}).  Just wanted to fix my bugs.

(BTW, bridge is 99% the same as last time, other than a typo which has been corrected.)

	Q



--- ifup	2012-02-09 15:34:37.000000000 -0800
+++ ifup-MTU	2012-02-25 17:42:40.000000000 -0800
@@ -105,10 +105,14 @@
      log_warning_msg "\nInterface ${IFACE} doesn't exist."
      exit 0
   fi
+
+   # Link is up, so set MTU (if value is a positive int).
+   test -n "${MTU}" -a $MTU -eq $MTU -a 0 -lt $MTU 2> /dev/null && \
+      ip link set dev ${IFACE} mtu $MTU
 fi
 
 for S in ${SERVICE}; do 
- IFCONFIG=${file} /lib/services/${S} ${IFACE} up
+ IFCONFIG=${file} /lib/services/${S} ${1} up
 done
 
 # End /sbin/ifup
--- ifdown	2012-02-01 18:52:05.000000000 -0800
+++ ifdown-MTU	2012-02-25 17:43:05.000000000 -0800
@@ -76,7 +76,7 @@
   for S in ${SERVICES}; do
 
     if [ -n "${S}" -a -x "/lib/services/${S}" ]; then
-      IFCONFIG=${file} /lib/services/${S} ${IFACE} down
+      IFCONFIG=${file} /lib/services/${S} ${1} down
     else
       MSG="Unable to process ${file}.  Either "
       MSG="${MSG}the SERVICE variable was not set "
--- bridge	2012-02-01 18:52:01.000000000 -0800
+++ bridge-MTU	2012-02-25 18:04:44.000000000 -0800
@@ -14,22 +14,23 @@
 . /lib/lsb/init-functions
 . ${IFCONFIG}
 
-if [ -n "${INTERFACE}" ]; then
-  log_failure_msg "INTERFACES variable missing from ${IFCONFIG}"
+# Call the bridge ${BRIDGE} for clarity.
+if [ -z "${BRIDGE}" ]; then
+  log_failure_msg "BRIDGE variable missing from ${IFCONFIG}"
   exit 1
 fi
 
 case "${2}" in
   up)
      log_info_msg2 "\n"
-     log_info_msg "Creating the ${1} interface..."
-     brctl addbr ${1}
-     ip link set ${1} up
+     log_info_msg "Creating the ${BRIDGE} interface..."
+     brctl addbr ${BRIDGE}
+     ip link set ${BRIDGE} up
      evaluate_retval
-     for I in ${INTERFACES}; do
-        log_info_msg "Adding ${I} to ${1}..."
-        ip link set ${I} up &&
-        brctl addif ${1} ${I}
+     for IF in ${IFACE}; do
+        log_info_msg "Adding ${IF} to ${BRIDGE}..."
+        #QRUX - Don't worry about the PHY link; let ifup deal with that.
+        brctl addif ${BRIDGE} ${IF}
         evaluate_retval
      done
 
@@ -44,16 +45,16 @@
   ;;
 
   down)
-     for I in ${INTERFACES}; do
-        log_info_msg "Removing ${I} from ${1}..."
-        ip link set ${I} down &&
-        brctl delif ${1} ${I}
+     for IF in ${IFACE}; do
+        log_info_msg "Removing ${IF} from ${BRIDGE}..."
+        #QRUX - Don't worry about the PHY link; let ifdown deal with that.
+        brctl delif ${BRIDGE} ${IF}
         evaluate_retval
      done
 
-     log_info_msg "Bringing down the ${1} interface..."
-     ip link set ${1} down
-     brctl delbr ${1}
+     log_info_msg "Bringing down the ${BRIDGE} interface..."
+     ip link set ${BRIDGE} down
+     brctl delbr ${BRIDGE}
      evaluate_retval
   ;;
 




More information about the lfs-support mailing list