[systemd-devel] sshd.service fails on boot when primary listener is a bridge (br0) instead of real interface (eth0). What dependency is needed?

lyndat3 at your-mail.com lyndat3 at your-mail.com
Sun Apr 12 13:43:34 PDT 2015


> On Sun, Apr 12, 2015, at 12:49 PM, Lennart Poettering wrote:
> > Hmm? why that? why does sshd care?

opensuse has a convenient interface status tool

	rpm -q --whatprovides `which ifstatus `
		wicked-service-0.6.17-12.1.x86_64

	ifstatus br0
		br0             up
		      link:     #6, state up, mtu 1500
		      type:     bridge
		      config:   compat:/etc/sysconfig/network/ifcfg-br0
		      leases:   ipv4 static granted
		      leases:   ipv6 static granted
		      addr:     ipv4 172.30.11.2/22 [static]
		      addr:     ipv6 2001:470:1f05:6a0::2/64 [static]
		      route:    ipv4 default via 172.30.11.100
		      route:    ipv6 default via 2001:470:1f05:6a0::100

In the bridge case, with sshd listening on the br0 IP adddess, with this unit

	cat /etc/systemd/system/sshd.service 
		[Unit]
		Description=OpenSSH Daemon
		After=syslog.target network.target network-online.target

		[Service]
		EnvironmentFile=-/etc/sysconfig/ssh
		ExecStartPre=/usr/sbin/sshd-gen-keys-start
		ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
		ExecReload=/bin/kill -HUP $MAINPID
		KillMode=process
		Restart=always

		[Install]
		WantedBy=multi-user.target

SSHD fails to launch on boot, firing the error I shared above.

But if a force a dependency check

	cat << EOF > /usr/local/scripts/wait-for-br0.sh
		#!/bin/bash
		while [[ \$(ifstatus br0 | grep ^br0 | awk '{print \$2}') != 'up' ]]; do
		  sleep 1
		done
		EOF

	cat /etc/systemd/system/sshd.service 
		[Unit]
		Description=OpenSSH Daemon
		After=syslog.target network.target network-online.target

		[Service]
		EnvironmentFile=-/etc/sysconfig/ssh
		ExecStartPre=/usr/sbin/sshd-gen-keys-start
+		ExecStartPre=sh /usr/local/scripts/wait-for-br0.sh
		ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
		ExecReload=/bin/kill -HUP $MAINPID
		KillMode=process
		Restart=always

		[Install]
		WantedBy=multi-user.target

Then reboot, SSHD boots up correctly .  It's available as you'd expect.

It sure looks like a depdenency issue.

And even though the unit's waiting for 

	network.target network-online.target

it doesn't seem to consider br0 being up as prereqs for those targets.

So, if NOT those targets, which one?  How do I convince the sshd unit to correctly wait for BRIDGES being up using systemd's ntaive dependency management?

Or is the only way to assume that systemd can't detect the bridges and handle it manually like I did above?

LT


More information about the systemd-devel mailing list