#757291 ifupdown: loopback methods have inverted filter clause

Package:
ifupdown
Source:
ifupdown
Description:
high level tools to configure network interfaces
Submitter:
Paul Gortmaker
Date:
2014-10-01 13:57:05 UTC
Severity:
normal
#757291#5
Date:
2014-08-06 20:34:46 UTC
From:
To:
Package: ifupdown
Version: 0.7.48.1
Severity: normal

Compared to the hurd link.defn for loopback, we see these
are inverted, meaning that you would only be able to configure
a loopback device that was _not_ named "lo" (unlikely to exist).

The result was that we'd update /run/network/ifstate for "lo"
but never actually do anything for up/down, as shown below:

root@localhost:~# ifconfig -s
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0   7736329      0   2016 0       5289422      0      0      0 BMRU
lo        65536 0        18      0      0 0            18      0      0      0 LRU
root@localhost:~# ifdown lo
root@localhost:~# echo $?
0
root@localhost:~# ifconfig -s
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0   7736406      0   2016 0       5289455      0      0      0 BMRU
lo        65536 0        18      0      0 0            18      0      0      0 LRU
root@localhost:~# ifconfig lo down
root@localhost:~# ifconfig -s
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0   7736474      0   2016 0       5289481      0      0      0 BMRU
root@localhost:~#

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 inet.defn  | 12 ++++++------
 inet6.defn |  8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/inet.defn b/inet.defn
index b176ab4ed03e..5fdfb14a0e1c 100644
--- a/inet.defn
+++ b/inet.defn
@@ -6,10 +6,10 @@ method loopback
     This method may be used to define the IPv4 loopback interface.

   up
-    ip link set dev %iface% up if (!iface_is_lo())
+    ip link set dev %iface% up if (iface_is_lo())

   down
-    ip link set dev %iface% down if (!iface_is_lo())
+    ip link set dev %iface% down if (iface_is_lo())

 method static
   description
@@ -212,11 +212,11 @@ method loopback

   up
     ifconfig %iface% 127.0.0.1 up \
-	if (!iface_is_lo())
+	if (iface_is_lo())

   down
     ifconfig %iface% down \
-	if (!iface_is_lo())
+	if (iface_is_lo())

 method static
   description
@@ -371,11 +371,11 @@ method loopback

   up
     inetutils-ifconfig --interface %iface% --address 127.0.0.1 --up \
-	if (!iface_is_lo())
+	if (iface_is_lo())

   down
     inetutils-ifconfig --interface %iface% --down \
-	if (!iface_is_lo())
+	if (iface_is_lo())

 method static
   description
diff --git a/inet6.defn b/inet6.defn
index 09325539cd01..4df64aff38cc 100644
--- a/inet6.defn
+++ b/inet6.defn
@@ -33,11 +33,11 @@ method loopback
   description
     This method may be used to define the IPv6 loopback interface.
   up
-    -ip link set dev %iface% up 2>/dev/null if (!iface_is_lo())
-    -ip addr add dev %iface% ::1 2>/dev/null if (!iface_is_lo())
+    -ip link set dev %iface% up 2>/dev/null if (iface_is_lo())
+    -ip addr add dev %iface% ::1 2>/dev/null if (iface_is_lo())
   down
-    -ip addr del dev %iface% ::1 2>/dev/null if (!iface_is_lo())
-    -ip link set dev %iface% down 2>/dev/null if (!iface_is_lo())
+    -ip addr del dev %iface% ::1 2>/dev/null if (iface_is_lo())
+    -ip link set dev %iface% down 2>/dev/null if (iface_is_lo())

 method static
   description

#757291#10
Date:
2014-09-30 15:20:17 UTC
From:
To:
Hi!

I have just been tearing out my hair about this one, on ubuntu though.
I've checked the source and it's the same error.

Without network-manager loopback isn't brought up on boot by ifupdown
scripts.

Copying bug report from ubuntu:
https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1375821
---- Upon booting a machine with the following setup on a relatively slimmed down netboot machine the loopback interface isn't brought up properly: cat /etc/network/interfaces auto lo iface lo inet loopback iface lo inet6 loopback auto eth0 iface eth0 inet6 auto dhcp 1 #iface eth0 inet ipv4ll auto eth1 iface eth1 inet6 auto dhcp 1 #iface eth1 inet ipv4ll Upon boot Loopback is unconfigured: root@<hostname>:~# ip addr show dev lo 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 Try to bring the interface up: root@<hostname>:~# ifup -v lo ifup: interface lo already configured Bring it down and up: root@<hostname>:~# ifdown -v lo Configuring interface lo=lo (inet) run-parts --verbose /etc/network/if-down.d run-parts: executing /etc/network/if-down.d/avahi-autoipd run-parts: executing /etc/network/if-down.d/upstart run-parts --verbose /etc/network/if-post-down.d Configuring interface lo=lo (inet) run-parts --verbose /etc/network/if-down.d run-parts: executing /etc/network/if-down.d/avahi-autoipd run-parts: executing /etc/network/if-down.d/upstart run-parts --verbose /etc/network/if-post-down.d Configuring interface lo=lo (inet6) run-parts --verbose /etc/network/if-down.d run-parts: executing /etc/network/if-down.d/avahi-autoipd run-parts: executing /etc/network/if-down.d/upstart run-parts --verbose /etc/network/if-post-down.d root@<hostname>:~# ifup -v lo Configuring interface lo=lo (inet) run-parts --verbose /etc/network/if-pre-up.d run-parts --verbose /etc/network/if-up.d run-parts: executing /etc/network/if-up.d/avahi-autoipd run-parts: executing /etc/network/if-up.d/openssh-server run-parts: executing /etc/network/if-up.d/upstart Configuring interface lo=lo (inet) run-parts --verbose /etc/network/if-pre-up.d run-parts --verbose /etc/network/if-up.d run-parts: executing /etc/network/if-up.d/avahi-autoipd run-parts: executing /etc/network/if-up.d/openssh-server run-parts: executing /etc/network/if-up.d/upstart Configuring interface lo=lo (inet6) run-parts --verbose /etc/network/if-pre-up.d run-parts --verbose /etc/network/if-up.d run-parts: executing /etc/network/if-up.d/avahi-autoipd run-parts: executing /etc/network/if-up.d/openssh-server run-parts: executing /etc/network/if-up.d/upstart no change: root@<hostname>:~# ip addr show dev lo 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 bring it down again: root@<hostname>:~# ifdown lo And up, but this time with --no-loopback: root@<hostname>:~# ifup -v --no-loopback lo Configuring interface lo=lo (inet) run-parts --verbose /etc/network/if-pre-up.d ip link set dev lo up run-parts --verbose /etc/network/if-up.d run-parts: executing /etc/network/if-up.d/avahi-autoipd run-parts: executing /etc/network/if-up.d/openssh-server run-parts: executing /etc/network/if-up.d/upstart Configuring interface lo=lo (inet6) run-parts --verbose /etc/network/if-pre-up.d ip link set dev lo up 2>/dev/null ip addr add dev lo ::1 2>/dev/null run-parts --verbose /etc/network/if-up.d run-parts: executing /etc/network/if-up.d/avahi-autoipd run-parts: executing /etc/network/if-up.d/openssh-server run-parts: executing /etc/network/if-up.d/upstart now it seems like something actually happened! check: root@<hostname>:~# ip addr show dev lo 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever All seems fine, everything is working from here on. My expectation is that ifup should configure the interface and set state to up, and ifdown should set state to down, even though it's a loopback that may or may not be magically autoconfigured somewhere else. And a question: If the case is that ifup shouldn't configure the loopback, what should configure it?
---- other interfaces (eth*) are configured as expected upon boot: root@<hostname>:~# ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:9c:02:ab:cb:d8 brd ff:ff:ff:ff:ff:ff inet6 my:ipv6:address:1/64 scope global temporary dynamic valid_lft 603348sec preferred_lft 84348sec inet6 my:ipv6:address:2/64 scope global dynamic valid_lft 2591995sec preferred_lft 604795sec inet6 fe80::29c:2ff:feab:cbd8/64 scope link valid_lft forever preferred_lft forever 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:9c:02:ab:cb:d9 brd ff:ff:ff:ff:ff:ff inet6 my:ipv6:address:3/64 scope global temporary dynamic valid_lft 603348sec preferred_lft 84348sec inet6 my:ipv6:address:4/64 scope global dynamic valid_lft 2591995sec preferred_lft 604795sec inet6 fe80::29c:2ff:feab:cbd9/64 scope link valid_lft forever preferred_lft forever It also seems like ifup is actively not configuring loopback twice, but running all scripts for it.. loopback should be up properly on both ipv4 and ipv6. I've subscribed and i'll gladly help if anything is missing to get this resolved.
#757291#15
Date:
2014-09-30 21:48:50 UTC
From:
To:
Hello,

With this config my ifupdown says the following:

ip link set up dev lo 2>/dev/null
run-parts --exit-on-error /etc/network/if-pre-up.d
run-parts --exit-on-error /etc/network/if-up.d
run-parts --exit-on-error /etc/network/if-pre-up.d
run-parts --exit-on-error /etc/network/if-up.d
run-parts --exit-on-error /etc/network/if-pre-up.d
run-parts --exit-on-error /etc/network/if-up.d

It does this. You don't even need to add loopback interface to the
config for this.

#757291#20
Date:
2014-10-01 12:49:30 UTC
From:
To:
hm, my isn't.

What could the difference between your setup and mine be?

version of ifupdown running:
ifup --version
ifup version 0.7.47.2ubuntu4
Copyright (c) 1999-2009 Anthony Towns
Copyright (c) 2010-2013 Andrew Shadura

I've looked through the source and it seems that version 0.7.41 changed
ifupdown to do "noop" on loopbacks which would explain the behaviour i
see. I'm curious as to why this was changed though since i don't think
it's the expected behaviour to ignore the request.
http://anonscm.debian.org/hg/collab-maint/ifupdown/rev/1ff1adb9ea06

#757291#25
Date:
2014-10-01 12:56:23 UTC
From:
To:
Hi,

It's not exactly no-op.

   7.216 +    -ip link set up dev %iface% 2>/dev/null \
   7.217 + if (iface_is_lo())

The interface is brought up when an internal ‘link’ method is
executed. Subsequent calls to a loopback method therefore are no-op by
default, as the interface is already configured by that point.

This comment explains this in detail. It should work unless something is broken.

In that version this code works differently, indeed.

#757291#30
Date:
2014-10-01 13:03:29 UTC
From:
To:
Hello,

Okay, I see:

diff -pruN 0.7.48.1/link.defn 0.7.48.1ubuntu4/link.defn
--- 0.7.48.1/link.defn 2014-03-23 13:37:15.000000000 +0000
+++ 0.7.48.1ubuntu4/link.defn 2014-05-01 22:10:40.000000000 +0000
@@ -10,18 +10,8 @@ method none
     vlan_id0 (get_token : 0 "") =vlan_id1
     vlan_id1 (to_decimal 10) =vlan_id
   up
-    if test -d /sys/class/net/%link% -a \
-            ! -d /sys/class/net/%iface0% ; \
-    then \
-        ip link set up dev %link%; \
-        ip link add link %link% name %iface0% type vlan id %vlan_id%; \
-    fi if (iface_has(".") && (!var_set_anywhere("bridge_ports", ifd)))
-    -ip link set up dev %iface% 2>/dev/null \
- if (iface_is_lo())
+
   down
-    ip link del %iface% if (iface_has(".") && (!iface_has(":")) &&
(!var_set_anywhere("bridge_ports", ifd)))
-    -ip link set down dev %iface% 2>/dev/null \
- if (iface_is_lo())

 architecture kfreebsd

Ubuntu maintainer broke it by mistake.
Stéphane, I'm handing this off to you :)

#757291#39
Date:
2014-10-01 13:49:57 UTC
From:
To:
Do you have any ideas or any way to figure out why loopback isn't
configured at any time on trusty? (even when running ifup lo from
commandline?)

If i understand link.defn correctly "ip link set up dev lo" should be
run if the interface is loopback, but it isn't being run when i test it.

Where in ifup is "method none" in link.defn called?


And isn't this in inet.defn related to the issue?
address_family inet
architecture linux

method loopback
   description
     This method may be used to define the IPv4 loopback interface.

   up
     ip link set dev %iface% up if (!iface_is_lo()) << method loopback,
bring interface up if not loopback?

   down
     ip link set dev %iface% down if (!iface_is_lo()) << same

#757291#44
Date:
2014-10-01 13:52:48 UTC
From:
To:
Hi,

Not at all. As I told you in another email, Ubuntu maintainer has
patched some code out by mistake.