Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-04 Thread Tom Gundersen
On Wed, Feb 4, 2015 at 2:41 PM, Patrik Flykt
 wrote:
>
> Hi,
>
> On Tue, 2015-02-03 at 17:27 +0100, Lennart Poettering wrote:
>> > Is the resume event detected somehow in systemd?
>>
>> The kernel unfortunately provides no API for this right now. However,
>> if logind is the one suspending the machine, then it sends out a
>> PrepareForSleep() signal before doing so. systemd-resolved already
>> hooks into that:
>>
>> http://cgit.freedesktop.org/systemd/systemd/tree/src/resolve/resolved-bus.c#n684
>>
>> Tom mentioned he's already looking into adding similar code to
>> networkd to handle this properly.
>
> Latest upstream works fine for me. Links break at suspend and are
> enabled at restore with PrepareForSleep() handled. Both versions of DHCP
> properly stop and start at these events.


Yeah, so on all the hardware I had tried so far we got proper
IFF_LOWER_{DOWN,UP} events on suspend/resume. Turns out that is not
always the case, so added the logic to listen for logind for this.
Please let me know if anyone notices problems.

Cheers,

Tom
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-04 Thread Patrik Flykt

Hi,

On Tue, 2015-02-03 at 17:27 +0100, Lennart Poettering wrote:
> > Is the resume event detected somehow in systemd? 
> 
> The kernel unfortunately provides no API for this right now. However,
> if logind is the one suspending the machine, then it sends out a
> PrepareForSleep() signal before doing so. systemd-resolved already
> hooks into that:
> 
> http://cgit.freedesktop.org/systemd/systemd/tree/src/resolve/resolved-bus.c#n684
> 
> Tom mentioned he's already looking into adding similar code to
> networkd to handle this properly.

Latest upstream works fine for me. Links break at suspend and are
enabled at restore with PrepareForSleep() handled. Both versions of DHCP
properly stop and start at these events.


Cheers,

Patrik


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-03 Thread Charles Devereaux
True, but it's better than nothing.

Well, I guess systemd-networkd doing basic things will have to wait on
kdbus :-)



On Tue, Feb 3, 2015 at 3:32 PM, Lennart Poettering 
wrote:

> 1;3802;0cOn Tue, 03.02.15 14:38, Charles Devereaux (syst...@guylhem.net)
> wrote:
>
> > On Tue, Feb 3, 2015 at 2:29 PM, Lennart Poettering <
> lenn...@poettering.net>
> > wrote:
> >
> > > I am pretty sure signals are not a particularly good interface for
> > > this. We should add a proper bus API for this one day, but this kinda
> > > has to wait until kdbus is a done deal, since networkd runs in early
> > > boot, and dbus-daemon is not available in early boot.
> >
> > Which would be a good usecase for signals (until kdbus happens, which
> might
> > take some time)
>
> Signals are asynchronous, which makes them a lot less useful to use,
> since you cannot wait resonably for completion the operation you request.
>
> Lennart
>
> --
> Lennart Poettering, Red Hat
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-03 Thread Lennart Poettering
1;3802;0cOn Tue, 03.02.15 14:38, Charles Devereaux (syst...@guylhem.net) wrote:

> On Tue, Feb 3, 2015 at 2:29 PM, Lennart Poettering 
> wrote:
> 
> > I am pretty sure signals are not a particularly good interface for
> > this. We should add a proper bus API for this one day, but this kinda
> > has to wait until kdbus is a done deal, since networkd runs in early
> > boot, and dbus-daemon is not available in early boot.
> 
> Which would be a good usecase for signals (until kdbus happens, which might
> take some time)

Signals are asynchronous, which makes them a lot less useful to use,
since you cannot wait resonably for completion the operation you request.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-03 Thread Charles Devereaux
On Tue, Feb 3, 2015 at 2:29 PM, Lennart Poettering 
wrote:

> I am pretty sure signals are not a particularly good interface for
> this. We should add a proper bus API for this one day, but this kinda
> has to wait until kdbus is a done deal, since networkd runs in early
> boot, and dbus-daemon is not available in early boot.


Which would be a good usecase for signals (until kdbus happens, which might
take some time)

In an ideal world, kdbus will be the perfect solution, but at the moment,
the few signals mentioned would immediately solve some serious limitations
of systemd-networkd.

Also, in the future, having 2 ways to do the same thing might be a good
thing, especially for something as important as networking (ex: in case
some distribution do not want to use kdbus, or waits a while to implement
it, and in the meantime has to use weird hack. signals could lessen the
pain)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-03 Thread Lennart Poettering
On Tue, 03.02.15 14:15, Charles Devereaux (syst...@guylhem.net) wrote:

> My current solution with dhcpcd is a sleep service sending signals to
> dhcpcd (give back the lease/reclaim it), something which could be extended
> to systemd-networkd, with other signals for other meanings that you may not
> want by default, like:
>  - removing the configuration it did (which is currently kept when
> systemd-networkd is stopped, which could be useful in some scenarios to
> avoid asking an additional IP address every time)
>  - starting or stopping the DHCP servers services (which once started keep
> running)
> 
> Even if systemd-networkd does not support a fine grained logic as I
> regretted in another message about br0, this would at least support most of
> the basic scenarios many people will need.

I am pretty sure signals are not a particularly good interface for
this. We should add a proper bus API for this one day, but this kinda
has to wait until kdbus is a done deal, since networkd runs in early
boot, and dbus-daemon is not available in early boot.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-03 Thread Charles Devereaux
My current solution with dhcpcd is a sleep service sending signals to
dhcpcd (give back the lease/reclaim it), something which could be extended
to systemd-networkd, with other signals for other meanings that you may not
want by default, like:
 - removing the configuration it did (which is currently kept when
systemd-networkd is stopped, which could be useful in some scenarios to
avoid asking an additional IP address every time)
 - starting or stopping the DHCP servers services (which once started keep
running)

Even if systemd-networkd does not support a fine grained logic as I
regretted in another message about br0, this would at least support most of
the basic scenarios many people will need.

$ cat /dhcpcd-sleep.service
[Unit]
Description=DHCP client sleep hook
Before=sleep.target
ConditionVirtualization=no

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/killall -USR1 dhcpcd
ExecStop=/usr/bin/killall -SIGALRM dhcpcd

[Install]
WantedBy=sleep.target



On Tue, Feb 3, 2015 at 11:27 AM, Lennart Poettering 
wrote:

> On Tue, 03.02.15 18:20, Patrik Flykt (patrik.fl...@linux.intel.com) wrote:
>
> > On Tue, 2015-02-03 at 11:46 +0100, Lennart Poettering wrote:
> > > On Mon, 02.02.15 23:12, Charles Devereaux (syst...@guylhem.net) wrote:
> > >
> > > > Another problem with systemd-networkd is that the lease is not
> renewed
> > > > after sleep.
> > > >
> > > > This is a basic feature, a laptop is frequently physicially moved,
> which
> > > > means another DHCP lease should be acquired, but I don't see how to
> > > > do that.
> > >
> > > Hmm, I figure all DHCP leases should be refreshed when we come back
> > > from suspend. Hooking that up should be pretty easy. Added to the TODO
> > > list.
> > >
> > > That said, isn't the link beat lost anyway during suspend, and thus we
> > > should refresh automatically, anyway?
> > >
> > > Either way refreshing on resume can't hurt...
> >
> > Is the resume event detected somehow in systemd?
>
> The kernel unfortunately provides no API for this right now. However,
> if logind is the one suspending the machine, then it sends out a
> PrepareForSleep() signal before doing so. systemd-resolved already
> hooks into that:
>
>
> http://cgit.freedesktop.org/systemd/systemd/tree/src/resolve/resolved-bus.c#n684
>
> Tom mentioned he's already looking into adding similar code to
> networkd to handle this properly.
>
> Lennart
>
> --
> Lennart Poettering, Red Hat
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-03 Thread Lennart Poettering
On Tue, 03.02.15 18:20, Patrik Flykt (patrik.fl...@linux.intel.com) wrote:

> On Tue, 2015-02-03 at 11:46 +0100, Lennart Poettering wrote:
> > On Mon, 02.02.15 23:12, Charles Devereaux (syst...@guylhem.net) wrote:
> > 
> > > Another problem with systemd-networkd is that the lease is not renewed
> > > after sleep.
> > > 
> > > This is a basic feature, a laptop is frequently physicially moved, which
> > > means another DHCP lease should be acquired, but I don't see how to
> > > do that.
> > 
> > Hmm, I figure all DHCP leases should be refreshed when we come back
> > from suspend. Hooking that up should be pretty easy. Added to the TODO
> > list.
> > 
> > That said, isn't the link beat lost anyway during suspend, and thus we
> > should refresh automatically, anyway? 
> > 
> > Either way refreshing on resume can't hurt...
> 
> Is the resume event detected somehow in systemd? 

The kernel unfortunately provides no API for this right now. However,
if logind is the one suspending the machine, then it sends out a
PrepareForSleep() signal before doing so. systemd-resolved already
hooks into that:

http://cgit.freedesktop.org/systemd/systemd/tree/src/resolve/resolved-bus.c#n684

Tom mentioned he's already looking into adding similar code to
networkd to handle this properly.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-03 Thread Patrik Flykt
On Tue, 2015-02-03 at 11:46 +0100, Lennart Poettering wrote:
> On Mon, 02.02.15 23:12, Charles Devereaux (syst...@guylhem.net) wrote:
> 
> > Another problem with systemd-networkd is that the lease is not renewed
> > after sleep.
> > 
> > This is a basic feature, a laptop is frequently physicially moved, which
> > means another DHCP lease should be acquired, but I don't see how to
> > do that.
> 
> Hmm, I figure all DHCP leases should be refreshed when we come back
> from suspend. Hooking that up should be pretty easy. Added to the TODO
> list.
> 
> That said, isn't the link beat lost anyway during suspend, and thus we
> should refresh automatically, anyway? 
> 
> Either way refreshing on resume can't hurt...

Is the resume event detected somehow in systemd? I'd assume that links
are lost when suspending and reconnected on resume, so maybe that is the
only event needing attention. I'll take a quick look into what my laptop
thinks about the issue...


Cheers,

Patrik

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-03 Thread Lennart Poettering
On Mon, 02.02.15 23:12, Charles Devereaux (syst...@guylhem.net) wrote:

> Another problem with systemd-networkd is that the lease is not renewed
> after sleep.
> 
> This is a basic feature, a laptop is frequently physicially moved, which
> means another DHCP lease should be acquired, but I don't see how to
> do that.

Hmm, I figure all DHCP leases should be refreshed when we come back
from suspend. Hooking that up should be pretty easy. Added to the TODO
list.

That said, isn't the link beat lost anyway during suspend, and thus we
should refresh automatically, anyway? 

Either way refreshing on resume can't hurt...

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-02 Thread Charles Devereaux
Another problem with systemd-networkd is that the lease is not renewed
after sleep.

This is a basic feature, a laptop is frequently physicially moved, which
means another DHCP lease should be acquired, but I don't see how to do that.

How can I make that happen? It's not clear to me, since systemd-networkd
does not seem to support triggers. At the moment I'm back to dhcpcd5.

On Mon, Feb 2, 2015 at 5:33 PM, Lennart Poettering 
wrote:

> On Sun, 11.01.15 18:45, Charles Devereaux (syst...@guylhem.net) wrote:
>
> > What's not is the time it takes to systemd-networkd : 1 second for IPv6
> is
> > acceptable (I'm using SLAAC with radvd on the other end), but for ipv4
> it's
> > more like 3 seconds, plus another 3 to use the proper DNS server (!!)
>
> [...]
>
> > So basically, I don't know why it's so slow, except that it comes from
> DHCP
> > IPv4
>
> Tom has fixed that with d4cdbea5550ae9defa1c731ffe091837d329fec7,
> could you please verify?
>
> Lennart
>
> --
> Lennart Poettering, Red Hat
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-02-02 Thread Lennart Poettering
On Sun, 11.01.15 18:45, Charles Devereaux (syst...@guylhem.net) wrote:

> What's not is the time it takes to systemd-networkd : 1 second for IPv6 is
> acceptable (I'm using SLAAC with radvd on the other end), but for ipv4 it's
> more like 3 seconds, plus another 3 to use the proper DNS server (!!)

[...]

> So basically, I don't know why it's so slow, except that it comes from DHCP
> IPv4

Tom has fixed that with d4cdbea5550ae9defa1c731ffe091837d329fec7,
could you please verify?

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] slow systemd-networkd DHCP client on wlan0 with systemd v217

2015-01-11 Thread Charles Devereaux
Hello

With dhcpcd5 and the following options, once wpa_supplicant is done,  I
have a connection within the same second if I ignore ARP.

With systemd-network, it's much much slower.

$ systemd-analyze blame
  3.923s systemd-networkd-wait-online.service
(...)

I tried to measure the time taken on wlan0, to see where the problem came
from::

Jan 11 17:53:01 thinkpad wpa_supplicant@wlan0[391]: started
Jan 11 17:53:02 thinkpad kernel: IPv6: ADDRCONF(NETDEV_UP): wlan0: link is
not ready
Jan 11 17:53:03 thinkpad kernel: wlan0: authenticate with ea:fc:af:f6:dd:cd
Jan 11 17:53:03 thinkpad kernel: wlan0: send auth to ea:fc:af:f6:dd:cd (try
1/3)
Jan 11 17:53:03 thinkpad kernel: wlan0: authenticated
Jan 11 17:53:03 thinkpad kernel: wlan0: associate with ea:fc:af:f6:dd:cd
(try 1/3)
Jan 11 17:53:03 thinkpad kernel: wlan0: RX AssocResp from ea:fc:af:f6:dd:cd
(capab=0x411 status=0 aid=2)
Jan 11 17:53:03 thinkpad kernel: IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link
becomes ready
Jan 11 17:53:03 thinkpad kernel: wlan0: associated
Jan 11 17:53:03 thinkpad systemd-networkd[419]: wlan0   : gained
carrier
Jan 11 17:53:04 thinkpad avahi-daemon[403]: Joining mDNS multicast group on
interface wlan0.IPv6 with address fe80::xxx
Jan 11 17:53:04 thinkpad avahi-daemon[403]: New relevant interface
wlan0.IPv6 for mDNS.
Jan 11 17:53:04 thinkpad avahi-daemon[403]: Registering new address record
for fe80::xxx on wlan0.IPv6.
Jan 11 17:53:06 thinkpad systemd-networkd[419]: wlan0   : DHCPv4
address 192.168.1.19/16 via 192.168.1.1
Jan 11 17:53:06 thinkpad systemd-networkd[419]: wlan0   : link
configured
Jan 11 17:53:06 thinkpad avahi-daemon[403]: Joining mDNS multicast group on
interface wlan0.IPv4 with address 192.168.1.19.
Jan 11 17:53:06 thinkpad avahi-daemon[403]: New relevant interface
wlan0.IPv4 for mDNS.
Jan 11 17:53:06 thinkpad avahi-daemon[403]: Registering new address record
for 192.168.1.19 on wlan0.IPv4.
Jan 11 17:53:09 thinkpad systemd-resolved[428]: Switching to DNS server
192.168.1.1 for interface wlan0.

You can see wpa_supplicant is started at :01 (I'm using a udev rule so that
it's started when wlan0 appears), and is done at :03. That's slow but normal

What's not is the time it takes to systemd-networkd : 1 second for IPv6 is
acceptable (I'm using SLAAC with radvd on the other end), but for ipv4 it's
more like 3 seconds, plus another 3 to use the proper DNS server (!!)

>From https://plus.google.com/+TomGundersen/posts/eztZWbwmxM8, I understand
it should be done much faster.

What am I doing wrong here?

After manually checking the .c files, commits mentionned on google plus,
#66a67effcc5beaf8a61e1c1147c3114b02a96439 and
#d23c45bfccb3ed6e2628e6d12b4ea12b8c920ab9 seem to have been applied to the
systemd-stable v217 I'm using.

Nothing in the code suggestssection 4.4.1 has become an opt-in, which was
mentioned in the comments.

The .network I'm using is very simple.

$ cat /etc/systemd/network/wireless.network
[Match]
Name=w*
Virtualization=no

[Network]
DHCP=both

[DHCP]
UseHostname=false

So basically, I don't know why it's so slow, except that it comes from DHCP
IPv4
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel