Bug 763533

Summary: running ifrenew breaks network configuration
Product: [openSUSE] openSUSE 12.1 Reporter: Christoph Thiel <cthiel>
Component: NetworkAssignee: Marius Tomaschewski <mt>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Critical    
Priority: P1 - Urgent CC: fcrozat, james.mason, lchiquitto, stefan.fent
Version: Final   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard: .
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Deadline: 2012-08-17   
Attachments: output from ifrenew (with "set -x" set in ifup)
/var/log/messages details
/sbin/ifup-dhcp with renew fix
ifrenew-dhcp as patch

Description Christoph Thiel 2012-05-22 19:11:33 UTC
Created attachment 491988 [details]
output from ifrenew (with "set -x" set in ifup)

On a minimal installation of openSUSE 12.1, with dhcp network configured via ifup, running

  # ifrenew eth0

will not yield the expected result, but kill the network compeltely.
Comment 2 Christoph Thiel 2012-05-22 19:17:04 UTC
# cat ifcfg-eth0
BOOTPROTO='dhcp4'
STARTMODE='onboot'
NAME='Ethernet Network Card'
#
Comment 3 Christoph Thiel 2012-05-22 19:17:34 UTC
Created attachment 491989 [details]
/var/log/messages details
Comment 5 Marius Tomaschewski 2012-05-23 07:12:16 UTC
I guess this is a similar problem as in bug #727771 and bug #747931.

ifrenew kills dhcp client. systemd notices this and thinks that the
network is dead and stops it.

Also: ifrenew and also the dhcp new client are not started via systemctl
[network cgroup] and do not count as valid processes of the network service.
This is valid for any manually called network related command, except of
the normal "rcnetwork <start|stop|reload|...>" actions -- without any
additional parameters or rc.status will not redirect to systemctl.

Hotfix: zypper install sysvinit-init
Comment 6 Frederic Crozat 2012-05-23 11:32:26 UTC
hmm, with X-Systemd-RemainAfterExit: true in /etc/init.d/network, network service shouldn't go down when its cgroups become empty..
Comment 7 Marius Tomaschewski 2012-05-23 14:26:45 UTC
(In reply to comment #6)
> hmm, with X-Systemd-RemainAfterExit: true in /etc/init.d/network, network
> service shouldn't go down when its cgroups become empty..

But it definitively happens. Just kill the dhcp client (from outside) and
start it manually again and you'll see that systemd noticed this (somehow)
and calls a "stop" for the service:

root@xanthos:~ # rcnetwork status
redirecting to systemctl
network.service - LSB: Configure the localfs depending network interfaces
          Loaded: loaded (/etc/init.d/network)
          Active: active (running) since Wed, 23 May 2012 16:21:30 +0200; 1min 12s ago
         Process: 29224 ExecStop=/etc/init.d/network stop (code=exited, status=0/SUCCESS)
         Process: 30630 ExecStart=/etc/init.d/network start (code=exited, status=0/SUCCESS)
          CGroup: name=systemd:/system/network.service
                  └ 330 /sbin/dhcpcd --netconfig -L -E -c /etc/sysconfig/network/scr...
root@xanthos:~ # ps axwww | grep dhcpcd | grep -v grep
  330 ?        Ss     0:00 /sbin/dhcpcd --netconfig -L -E -c /etc/sysconfig/network/scripts/dhcpcd-hook -t 0 -h xanthos eth0
root@xanthos:~ # logger ===================================================
root@xanthos:~ # kill -TERM 330 
root@xanthos:~ # rcnetwork status
redirecting to systemctl
network.service - LSB: Configure the localfs depending network interfaces
          Loaded: loaded (/etc/init.d/network)
          Active: deactivating (stop) since Wed, 23 May 2012 16:23:07 +0200; 2s ago
         Process: 30630 ExecStart=/etc/init.d/network start (code=exited, status=0/SUCCESS)
         Control: 1342 (network)
          CGroup: name=systemd:/system/network.service
                  ├ 1342 /bin/bash /etc/init.d/network stop
                  ├ 2447 /bin/bash /sbin/ifdown eth0 -o rc onboot
                  ├ 2516 /bin/bash /sbin/ifdown-dhcp eth0 eth0 -o rc onboot
                  ├ 2522 /bin/bash /sbin/ifdown-dhcp eth0 eth0 -o rc onboot
                  └ 2531 usleep 100000
root@xanthos:~ # rcnetwork status
redirecting to systemctl
network.service - LSB: Configure the localfs depending network interfaces
          Loaded: loaded (/etc/init.d/network)
          Active: inactive (dead) since Wed, 23 May 2012 16:23:11 +0200; 10s ago
         Process: 1342 ExecStop=/etc/init.d/network stop (code=exited, status=0/SUCCESS)
         Process: 30630 ExecStart=/etc/init.d/network start (code=exited, status=0/SUCCESS)
          CGroup: name=systemd:/system/network.service
Comment 8 Marius Tomaschewski 2012-05-23 14:30:50 UTC
Created attachment 492120 [details]
/sbin/ifup-dhcp with renew fix

But the above comment does not mean, that we can fix renew for dhcpcd.

root@xanthos:~ # logger ============= renew =====================
root@xanthos:~ # ifrenew eth0
    eth0      device: Intel Corporation 82567LM-3 Gigabit Network Connection (rev 02)
Starting DHCP4 client on eth0.  
    eth0      IP address: 172.16.20.1/24 (xanthos)

the messages:
May 23 16:27:08 xanthos root: ============= renew =====================
May 23 16:27:19 xanthos ifrenew[5944]:     eth0      device: Intel Corporation 82567LM-3 Gigabit Network Connection (rev 02)
May 23 16:27:19 xanthos ifrenew-dhcp[5968]: Starting DHCP4 client on eth0
May 23 16:27:19 xanthos dhcpcd[6001]: eth0: sending signal 14 to pid 4914
May 23 16:27:19 xanthos dhcpcd[6001]: eth0: exiting
May 23 16:27:19 xanthos dhcpcd[4914]: eth0: received SIGALRM, renewing lease
May 23 16:27:19 xanthos dhcpcd[4914]: eth0: renewing lease of 172.16.20.1
May 23 16:27:19 xanthos dhcpcd[4914]: eth0: leased 172.16.20.1 for 3600 seconds
May 23 16:27:19 xanthos dhcpcd[4914]: eth0: adding IP address 172.16.20.1/24
May 23 16:27:19 xanthos dhcpcd[4914]: eth0: adding default route via 172.16.20.254 metric 0
May 23 16:27:19 xanthos ifrenew-dhcp[5968]: . 
May 23 16:27:19 xanthos ifup[6119]:     eth0      device: Intel Corporation 82567LM-3 Gigabit Network Connection (rev 02)
May 23 16:27:19 xanthos ifrenew-dhcp[5968]:  
May 23 16:27:19 xanthos ifrenew-dhcp[5968]:     eth0      IP address: 172.16.20.1/24 (xanthos)
Comment 9 Marius Tomaschewski 2012-05-23 14:33:08 UTC
(In reply to comment #8)
> But the above comment does not mean, that we can fix renew for dhcpcd.
                                               ^^^
                                              can't

Christian, just install the attached test script to /sbin/ifup-dhcp and
execute ifrenew. Does it work for you?
Comment 10 Christoph Thiel 2012-05-23 14:40:29 UTC
Will give it a try! Thanks for the quick hotfix.
Comment 11 Frederic Crozat 2012-05-23 14:43:07 UTC
hmm, it looks like I might have broken something in one of my systemd 12.1 update, since 
systemctl -p RemainAfterExit network.service 
returns "RemainAfterExit=no"

while it should return yes.

I'm checking older version of systemd to confirm this.
Comment 12 Frederic Crozat 2012-05-23 14:55:17 UTC
ok, something is definitively wrong in the X-Systemd-RemainAfterExit: handling, even in previous systemd 12.1 update, which seems to be overriden by the heuristic I added for initscripts. Let me see if I can fix that properly
Comment 13 Christoph Thiel 2012-05-23 15:03:03 UTC
The X-Systemd-RemainAfterExit issue should probably get tracked in a different bug, right?
Comment 14 Frederic Crozat 2012-05-23 15:15:08 UTC
(In reply to comment #13)
> The X-Systemd-RemainAfterExit issue should probably get tracked in a different
> bug, right?

well, it is the root cause of this issue (not working properly)
Comment 15 Christoph Thiel 2012-05-23 15:18:26 UTC
OK, makes sense.
Comment 16 Marius Tomaschewski 2012-05-23 15:27:16 UTC
IMO

 - Bug 727771 systemd: shuts down network for no reason
 - Bug 747931 systemd shut off network at boot time in
              a bridge over vlan configuration

may be a a better choice than this bug ... important is, that both
(renew and systemd) get a fix.

I've applied the attached ifup-dhcp renew fix to:
  OBS/home:mtomaschewski:branches:openSUSE:12.1:Update/sysconfig
Comment 17 Frederic Crozat 2012-05-23 15:36:22 UTC
arggg, found it.

in /etc/init.d/network, try to move the "#X-Systemd-RemainAfterExit:" line BEFORE the #Description line, otherwise, it is understood as part of the Description :(

you'll need to run "systemctl daemon-reload" to properly reload the initscript in systemd.

I'll fixing systemd parsing code to correctly handle X-Systemd-RemainAfterExit and Pidfile even if they are located after Description: tag
Comment 18 Marius Tomaschewski 2012-05-23 15:40:45 UTC
Yes, moving X-Systemd-RemainAfterExit before Description plus a
"systemctl daemon-reload" works fine:

root@xanthos:~ # rcnetwork status
redirecting to systemctl
network.service - LSB: Configure the localfs depending network interfaces
	  Loaded: loaded (/etc/init.d/network)
	  Active: active (running) since Wed, 23 May 2012 16:24:59 +0200; 1h 13min ago
	  CGroup: name=systemd:/system/network.service
		  └ 4914 /sbin/dhcpcd --netconfig -L -E -c /etc/sysconfig/network/scr...
root@xanthos:~ # ps axwww | grep dhcpcd | grep -v grep
 4914 ?        Ss     0:00 /sbin/dhcpcd --netconfig -L -E -c /etc/sysconfig/network/scripts/dhcpcd-hook -t 0 -h xanthos eth0
root@xanthos:~ # kill 4914 
root@xanthos:~ # ifup-dhcp eth0
Starting DHCP4 client on eth0.  
    eth0      IP address: 172.16.20.1/24 (xanthos)
root@xanthos:~ # rcnetwork status
redirecting to systemctl
network.service - LSB: Configure the localfs depending network interfaces
	  Loaded: loaded (/etc/init.d/network)
	  Active: active (exited) since Wed, 23 May 2012 16:24:59 +0200; 1h 13min ago
	  CGroup: name=systemd:/system/network.service
root@xanthos:~ # ps axwww | grep dhcpcd | grep -v grep
 9404 ?        Ss     0:00 /sbin/dhcpcd --netconfig -L -E -c /etc/sysconfig/network/scripts/dhcpcd-hook -t 0 -h xanthos eth0
root@xanthos:~ # rcnetwork status -o &>/dev/null && echo OK
OK
Comment 19 Frederic Crozat 2012-05-23 15:56:11 UTC
ok, I've committed the fix to my test repository home:fcrozat:systemd / systemd, it should be available pretty soon (when obs is done) in http://download.opensuse.org/repositories/home:/fcrozat:/systemd/openSUSE_12.1/
Comment 20 Christoph Thiel 2012-05-23 20:09:55 UTC
I verfied the changes to ifup-dhcp successfully.
Comment 25 Marius Tomaschewski 2012-05-24 07:27:27 UTC
Created attachment 492225 [details]
ifrenew-dhcp as patch
Comment 31 Swamp Workflow Management 2012-05-29 09:08:42 UTC
openSUSE-RU-2012:0649-1: An update that has two recommended fixes can now be installed.

Category: recommended (important)
Bug References: 724775,763533
CVE References: 
Sources used:
openSUSE 12.1 (src):    sysconfig-0.75.4-2.10.1
Comment 33 Swamp Workflow Management 2012-07-20 14:15:15 UTC
The SWAMPID for this issue is 48406.
This issue was rated as low.
Please submit fixed packages until 2012-08-17.
Also create a patchinfo file using this link:
https://swamp.suse.de/webswamp/wf/48406
Comment 34 Swamp Workflow Management 2012-08-17 16:07:36 UTC
Update released for: sysconfig, sysconfig-debuginfo, sysconfig-debugsource
Products:
SLE-DEBUGINFO 11-SP2 (i386, ia64, ppc64, s390x, x86_64)
SLE-DESKTOP 11-SP2 (i386, x86_64)
SLE-SERVER 11-SP2 (i386, ia64, ppc64, s390x, x86_64)
SLES4VMWARE 11-SP2 (i386, x86_64)