Re: [systemd-devel] Changing configurations with networkd

2014-11-04 Thread Dan Williams
On Wed, 2014-07-23 at 16:46 +0200, Marcel Holtmann wrote:
> Hi Michael,
> 
> >>> I think the lease should be remembered and reused in this case.
> >> 
> >> Hm, this sounds like a bug somewhere. When the new discover is sent
> >> out it should send the same identifying information to the server, and
> >> hence be given the same lease back again. Wireshark should tell you if
> >> the fault is networkd's or the DHCP server.
> > 
> > I get the same address at first, but after several minutes the DHCP server
> > decides to offer a new address. I should note, that I have a 10 minute
> > lease time for debugging purposes, so that might make the problem more
> > prominent. I'll see if I can figure out what happens here.
> 
> look at your DHCP server and see what lease time it really hands out after 
> reboot.
> 
> However this is between you and your DHCP server. If you configure a lease 
> time of 10 minutes, then that is the only guaranteed time for a given IP 
> address. There is no mandate that the server has to give you the same address 
> after 10 minutes when you ask again. It is valid to just get a different one. 
> And that many home routers try to give you back the same one does not mean 
> that they are required to do so.
> 
> The nice DHCP servers will remember your Ethernet address and/or identity 
> information and give you back your old IP address. Either with the left over 
> lease time or with a brand new lease time. There is really no need to store 
> this information on disk. If the lease expired the information on disk are 
> stale as well. And since our DHCP implementation is so fast, it makes really 
> no difference.

Digging up an old thread because I just ran into this situation.

A "so fast" DHCP client doesn't help if the server doesn't cooperate,
and we don't control the DHCP server.

The router I was using (which isn't a dirt-cheap one) doesn't care about
the client ID or hardware address, it will only give you the same IP
address back if you send your old IP address in the 'ciaddr' field and
your lease is still valid.  And the 'ciaddr' field is zeroed on
DISCOVER, which means that to retrieve the same IP address/lease with
this router, REBOOT/RENEW is necessary.  I suspect that's likely the
case for quite a few more routers out there as well.  The router doesn't
have problems with other clients/OSs that I have found, just the systemd
DHCP code.

So it appears that to retrieve the same address again for as many
routers as possible, the lease details (lifetime, start time, last IP
address, client ID) should probably be stored somewhere for the client
to send later on reboot or service restart.

Dan

> It is safer start out with a brand new DHCP lease instead of having to deal 
> with renewal during boot. At least that way you know the DHCP server is still 
> there and you have a valid IP address. Just re-using a stored IP with a 
> left-over lease is not safe anyway. You never know what changed in the 
> network when you were off.
> 
> Regards
> 
> Marcel
> 
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


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


Re: [systemd-devel] Changing configurations with networkd

2014-08-15 Thread Lennart Poettering
On Fri, 15.08.14 09:12, Michael Olbrich (m.olbr...@pengutronix.de) wrote:

> 
> On Thu, Aug 14, 2014 at 05:38:05PM +0200, Lennart Poettering wrote:
> > On Fri, 25.07.14 09:48, Michael Olbrich (m.olbr...@pengutronix.de) wrote:
> > 
> > > What I'm _not_ seeing, and what usually comes when anything else changes 
> > > in
> > > the network configuration is:
> > > systemd-timesyncd[348]: Network configuration changed, trying to 
> > > establish connection.
> > > 
> > > I would expect, that systemd-timesyncd should be notified in this case as
> > > well, right?
> > 
> > This should be fixed with current git. Could you please recheck?
> 
> Indeed:
> 
> Aug 01 00:20:15 BaseKit systemd-networkd[434]: eth0: removed 
> address: 192.168.51.144/24 (valid for 0)
> Aug 01 00:20:15 BaseKit systemd-timesyncd[346]: Network configuration 
> changed, trying to establish connection.
> Aug 01 00:20:15 BaseKit systemd-networkd[434]: eth0: added 
> address: 192.168.51.145/24 (valid for 9min 30s)
> Aug 01 00:20:15 BaseKit systemd-timesyncd[346]: Network configuration 
> changed, trying to establish connection.
> 
> I'm not sure, why the new address is found again though.
> 
> Note: this is with "net.ipv4.conf.all.promote_secondaries = 1".  Setting
> just "net.ipv4.conf.default.promote_secondaries = 1", as it's currently
> done in /usr/lib/sysctl.d/50-default.conf is not always sufficient. I think
> the default only works for new interfaces that show up afterwards.

This is in indeed a race. I changed the sysctl fragment now to write to
both *.all.* and *.default.* for all IP related sysctls.

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] Changing configurations with networkd

2014-08-15 Thread Michael Olbrich
On Thu, Aug 14, 2014 at 05:38:05PM +0200, Lennart Poettering wrote:
> On Fri, 25.07.14 09:48, Michael Olbrich (m.olbr...@pengutronix.de) wrote:
> 
> > What I'm _not_ seeing, and what usually comes when anything else changes in
> > the network configuration is:
> > systemd-timesyncd[348]: Network configuration changed, trying to establish 
> > connection.
> > 
> > I would expect, that systemd-timesyncd should be notified in this case as
> > well, right?
> 
> This should be fixed with current git. Could you please recheck?

Indeed:

Aug 01 00:20:15 BaseKit systemd-networkd[434]: eth0: removed 
address: 192.168.51.144/24 (valid for 0)
Aug 01 00:20:15 BaseKit systemd-timesyncd[346]: Network configuration changed, 
trying to establish connection.
Aug 01 00:20:15 BaseKit systemd-networkd[434]: eth0: added address: 
192.168.51.145/24 (valid for 9min 30s)
Aug 01 00:20:15 BaseKit systemd-timesyncd[346]: Network configuration changed, 
trying to establish connection.

I'm not sure, why the new address is found again though.

Note: this is with "net.ipv4.conf.all.promote_secondaries = 1".  Setting
just "net.ipv4.conf.default.promote_secondaries = 1", as it's currently
done in /usr/lib/sysctl.d/50-default.conf is not always sufficient. I think
the default only works for new interfaces that show up afterwards.

Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Changing configurations with networkd

2014-08-14 Thread Lennart Poettering
On Fri, 25.07.14 09:48, Michael Olbrich (m.olbr...@pengutronix.de) wrote:

> What I'm _not_ seeing, and what usually comes when anything else changes in
> the network configuration is:
> systemd-timesyncd[348]: Network configuration changed, trying to establish 
> connection.
> 
> I would expect, that systemd-timesyncd should be notified in this case as
> well, right?

This should be fixed with current git. Could you please recheck?

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] Changing configurations with networkd

2014-08-14 Thread Lennart Poettering
On Thu, 24.07.14 10:49, Tom Gundersen (t...@jklm.no) wrote:

> > I think there was some misunderstanding here. I don't want to keep the
> > lease across reboots. I don't care about that. I think networkd should
> > remember the lease when restarting networkd only and not send a new dhcp
> > discover.
> 
> Right, I spoke too quickly. What I don't want is to preserve state
> between reboots, preserving it between restarts of networkd would
> indeed be fine. We already serialize the dhcp leases to /run, so I'd
> be happy to take a patch to deserialize these again when networkd
> starts.

Yeah, this would be great. This is what we are doing for machined and
logind too now, where we store everything in /run all the time, and can
then stop and start at any time without losing any information. I think
we should follow this scheme wherever we can. This would be particularly
useful when transitioning from the initrd to the main system, since the
initrd's networkd could simply be terminated and be replaced by the
host's version and still find everything.

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] Changing configurations with networkd

2014-07-25 Thread Tom Gundersen
On Fri, Jul 25, 2014 at 11:19 AM, Michael Olbrich
 wrote:
> Hi,
>
> On Fri, Jul 25, 2014 at 11:00:27AM +0200, Brendan Hide wrote:
>> On 24/07/14 14:05, Marcel Holtmann wrote:
>> >[snip]
>> >>... you already are getting
>> >>assigned the correct IP address at first, and then only later does
>> >>this change. What is causing your DHCP server to send out a different
>> >>IP address later on, I don't know, but it seems unlikely that this is
>> >>anything we can fix in the client.
>> >I have my doubts as well here. Seems like a misconfigured DHCP server.
>>
>> I feel like I'm flogging a dead horse - on the other hand it is
>> twitching just that little bit more than I'm comfortable with. ;)
>>
>> Since Michael specified that he has configured the DHCP lease to
>> last only 10 minutes, it stands to reason that he is getting the new
>> *different* IP address after ten minutes. This time period is highly
>> unusual - but for testing purposes appropriate. So far there is
>> nothing to suggest that the DHCP server is doing anything wrong.
>>
>> Michael, can you confirm the above?
>
> Not quite. When networkd sends a request to renew the address, then I keep
> the same address. However, when networkd is restarted it starts with a
> DHCP discover.
> Most of the time I still get the same address, but occasionally I get a new
> one. I'm not sure what triggers this. It feels like the whole
> discover/ofer/request/ack sequence takes longer for a new address, but I'vv
> not measured this.

If you want to investigate this, the best way is to use wireshark and
listen to DHCP traffic. Should be pretty clear what is going on.

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-25 Thread Michael Olbrich
Hi,

On Fri, Jul 25, 2014 at 11:00:27AM +0200, Brendan Hide wrote:
> On 24/07/14 14:05, Marcel Holtmann wrote:
> >[snip]
> >>... you already are getting
> >>assigned the correct IP address at first, and then only later does
> >>this change. What is causing your DHCP server to send out a different
> >>IP address later on, I don't know, but it seems unlikely that this is
> >>anything we can fix in the client.
> >I have my doubts as well here. Seems like a misconfigured DHCP server.
> 
> I feel like I'm flogging a dead horse - on the other hand it is
> twitching just that little bit more than I'm comfortable with. ;)
> 
> Since Michael specified that he has configured the DHCP lease to
> last only 10 minutes, it stands to reason that he is getting the new
> *different* IP address after ten minutes. This time period is highly
> unusual - but for testing purposes appropriate. So far there is
> nothing to suggest that the DHCP server is doing anything wrong.
> 
> Michael, can you confirm the above?

Not quite. When networkd sends a request to renew the address, then I keep
the same address. However, when networkd is restarted it starts with a
DHCP discover.
Most of the time I still get the same address, but occasionally I get a new
one. I'm not sure what triggers this. It feels like the whole
discover/ofer/request/ack sequence takes longer for a new address, but I'vv
not measured this.

Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Changing configurations with networkd

2014-07-25 Thread Tom Gundersen
On Fri, Jul 25, 2014 at 11:00 AM, Brendan Hide
 wrote:
> On 24/07/14 14:05, Marcel Holtmann wrote:
>>
>> Hi Tom,
>>
>> [snip]
>>>
>>> ... you already are getting
>>>
>>> assigned the correct IP address at first, and then only later does
>>> this change. What is causing your DHCP server to send out a different
>>> IP address later on, I don't know, but it seems unlikely that this is
>>> anything we can fix in the client.
>>
>> I have my doubts as well here. Seems like a misconfigured DHCP server.
>
>
> I feel like I'm flogging a dead horse - on the other hand it is twitching
> just that little bit more than I'm comfortable with. ;)
>
> Since Michael specified that he has configured the DHCP lease to last only
> 10 minutes, it stands to reason that he is getting the new *different* IP
> address after ten minutes. This time period is highly unusual - but for
> testing purposes appropriate. So far there is nothing to suggest that the
> DHCP server is doing anything wrong.
>
> Michael, can you confirm the above?

All that is fine, and it is within the spec for the DHCP server to
send out a different IP address. However, most DHCP servers will send
you the same one you are already using, and if that is the desired
behaviour that is something that should be configured in the DHCP
server (and nothing the client can do anything about).

I now pushed a change to our default sysctl file, so transitioning
between IPs should now work.

Thanks!

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-25 Thread Brendan Hide

On 24/07/14 14:05, Marcel Holtmann wrote:

Hi Tom,

[snip]

... you already are getting
assigned the correct IP address at first, and then only later does
this change. What is causing your DHCP server to send out a different
IP address later on, I don't know, but it seems unlikely that this is
anything we can fix in the client.

I have my doubts as well here. Seems like a misconfigured DHCP server.


I feel like I'm flogging a dead horse - on the other hand it is 
twitching just that little bit more than I'm comfortable with. ;)


Since Michael specified that he has configured the DHCP lease to last 
only 10 minutes, it stands to reason that he is getting the new 
*different* IP address after ten minutes. This time period is highly 
unusual - but for testing purposes appropriate. So far there is nothing 
to suggest that the DHCP server is doing anything wrong.


Michael, can you confirm the above?

--
__
Brendan Hide
http://swiftspirit.co.za/
http://www.webafrica.co.za/?AFF1E97

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-25 Thread Michael Olbrich
Hi,

On Thu, Jul 24, 2014 at 11:58:15PM +0200, Tom Gundersen wrote:
> On Thu, Jul 24, 2014 at 10:54 PM, Zbigniew Jędrzejewski-Szmek
>  wrote:
> > On Thu, Jul 24, 2014 at 09:18:14PM +0200, Tom Gundersen wrote:
> >> A quick fix would be to set
> >>
> >> /proc/sys/net/ipv4/conf/all/promote_secondaries
> >>
> >> to 1.
> > Wouldn't it be nice to set it to 1 always. The default setting of 0
> > is a brain damaged trap.
> 
> Yeah, I have been trying to find some info about why one might want it
> to be 0, to me it makes no sense at all. So far I found no reasons to
> keep this default, so unless someone has any new info I'll flip the
> switch.

Something I noted, when I tested this. When the old address expires then I
get this in the log:
systemd-networkd[573]: eth0: removed address: 192.168.51.139/24
systemd-networkd[573]: eth0: added address: 192.168.51.140/24

That looks correct, 192.168.51.139 ist the one that expires and
192.168.51.140 is promoted.

What I'm _not_ seeing, and what usually comes when anything else changes in
the network configuration is:
systemd-timesyncd[348]: Network configuration changed, trying to establish 
connection.

I would expect, that systemd-timesyncd should be notified in this case as
well, right?

Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Tom Gundersen
On Thu, Jul 24, 2014 at 10:54 PM, Zbigniew Jędrzejewski-Szmek
 wrote:
> On Thu, Jul 24, 2014 at 09:18:14PM +0200, Tom Gundersen wrote:
>> A quick fix would be to set
>>
>> /proc/sys/net/ipv4/conf/all/promote_secondaries
>>
>> to 1.
> Wouldn't it be nice to set it to 1 always. The default setting of 0
> is a brain damaged trap.

Yeah, I have been trying to find some info about why one might want it
to be 0, to me it makes no sense at all. So far I found no reasons to
keep this default, so unless someone has any new info I'll flip the
switch.

Cheers,

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Kay Sievers
On Thu, Jul 24, 2014 at 10:54 PM, Zbigniew Jędrzejewski-Szmek
 wrote:
> On Thu, Jul 24, 2014 at 09:18:14PM +0200, Tom Gundersen wrote:
>> A quick fix would be to set
>>
>> /proc/sys/net/ipv4/conf/all/promote_secondaries
>>
>> to 1.
> Wouldn't it be nice to set it to 1 always. The default setting of 0
> is a brain damaged trap.

We flip a few defaults with our sysctl file already. If it is the
right thing to do, we can just add that there.

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Zbigniew Jędrzejewski-Szmek
On Thu, Jul 24, 2014 at 09:18:14PM +0200, Tom Gundersen wrote:
> A quick fix would be to set
> 
> /proc/sys/net/ipv4/conf/all/promote_secondaries
> 
> to 1.
Wouldn't it be nice to set it to 1 always. The default setting of 0
is a brain damaged trap.

Zbyszek

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Tom Gundersen
On Thu, Jul 24, 2014 at 5:59 PM, Michael Olbrich
 wrote:
> On Thu, Jul 24, 2014 at 02:05:24PM +0200, Marcel Holtmann wrote:
>> > Right, I spoke too quickly. What I don't want is to preserve state
>> > between reboots, preserving it between restarts of networkd would
>> > indeed be fine. We already serialize the dhcp leases to /run, so I'd
>> > be happy to take a patch to deserialize these again when networkd
>> > starts.
>>
>> I am not sure this is useful either. It feels like a bandaid for the time
>> where networkd does not have an API to reload configuration changes. Killing
>> networkd should give you a clean start from the configuration files and not
>> magic cached value somewhere. Otherwise you end up with funny side effects
>> all the time and have to explain to users to clear some /run states. Or ask
>> them "to switch the computer off and back on again".
>>
>> When you are opting for DHCP instead of static addresses, then there is
>> really no guarantee for addresses staying the same. At least not for the
>> client to know. So unless you own the DHCP server and configure it with
>> static assignment. In all cases you have to confirm with the DHCP server that
>> you address is still valid.
>
> Getting a new IP address is not the biggest problem. But right now, when
> the valid_lft for the _old_ address is over, then then _new_ address is
> removed as well and the interface has no address at all! That is not
> acceptable. I can live with a different new address for now, but not with
> no address at all.

Indeed, this needs to be fixed. A quick fix would be to set

/proc/sys/net/ipv4/conf/all/promote_secondaries

to 1.


Cheers,

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Michael Olbrich
On Thu, Jul 24, 2014 at 02:05:24PM +0200, Marcel Holtmann wrote:
> > Right, I spoke too quickly. What I don't want is to preserve state
> > between reboots, preserving it between restarts of networkd would
> > indeed be fine. We already serialize the dhcp leases to /run, so I'd
> > be happy to take a patch to deserialize these again when networkd
> > starts.
> 
> I am not sure this is useful either. It feels like a bandaid for the time
> where networkd does not have an API to reload configuration changes. Killing
> networkd should give you a clean start from the configuration files and not
> magic cached value somewhere. Otherwise you end up with funny side effects
> all the time and have to explain to users to clear some /run states. Or ask
> them "to switch the computer off and back on again".
> 
> When you are opting for DHCP instead of static addresses, then there is
> really no guarantee for addresses staying the same. At least not for the
> client to know. So unless you own the DHCP server and configure it with
> static assignment. In all cases you have to confirm with the DHCP server that
> you address is still valid.

Getting a new IP address is not the biggest problem. But right now, when
the valid_lft for the _old_ address is over, then then _new_ address is
removed as well and the interface has no address at all! That is not
acceptable. I can live with a different new address for now, but not with
no address at all.

Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Brendan Hide

On 24/07/14 10:49, Tom Gundersen wrote:

On Thu, Jul 24, 2014 at 10:16 AM, Michael Olbrich
 wrote:

On Wed, Jul 23, 2014 at 04:46:26PM +0200, Marcel Holtmann wrote:


There is no mandate that the server has to give you the same address
after 10 minutes when you ask again. It is valid to just get a different one.
And that many home routers try to give you back the same one does not mean
that they are required to do so.

[snip]


What is causing your DHCP server to send out a different
IP address later on, I don't know, but it seems unlikely that this is
anything we can fix in the client.


As Marcel says, the DHCP server behaviour of giving a different IP is perfectly normal 
behaviour. Once the lease is expired the DHCP server's only obligation is to give a 
"valid" config - it doesn't have to be the same. Based on the information 
given, networkd isn't taking the right action.

A peripheral issue with this thread is that I don't see any mention of a "reload" option. A 
graceful zero-to-minimal-downtime "reload" should cater for Michael's use-case of manual changes to 
the "static" config files. Of course I haven't checked if this is already supported. ;)

I see a couple of choices here with regards to the restart/stop-start situation:
a) What *seems* to be the direction in this thread: Don't tear down, save the 
state, re-attempt same lease (keeps config functional when the daemon is 
stopped; not standards-compliant; doesn't fit with previous paradigms)
b) tear down on stop, save state, rebuild on start (robust; less "musical 
chairs"; downtime)

Technically I see b) as the right choices. The reasoning to me is twofold:
1) The alternative would violate standards: A DHCP lease might end after the 
daemon has stopped and the network is not going to automatically deconfigure. 
For static configs this is less of an issue.
2) The "standard" paradigm for most (all?) of the network{,ing} services for 
any current or previous *nix I've seen is that a stop or restart tears down the 
configuration.

--
__
Brendan Hide
http://swiftspirit.co.za/
http://www.webafrica.co.za/?AFF1E97

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Marcel Holtmann
Hi Tom,

>> I think the lease should be remembered and reused in this case.
> 
> Hm, this sounds like a bug somewhere. When the new discover is sent
> out it should send the same identifying information to the server, and
> hence be given the same lease back again. Wireshark should tell you if
> the fault is networkd's or the DHCP server.
 
 I get the same address at first, but after several minutes the DHCP server
 decides to offer a new address. I should note, that I have a 10 minute
 lease time for debugging purposes, so that might make the problem more
 prominent. I'll see if I can figure out what happens here.
>>> 
>>> look at your DHCP server and see what lease time it really hands out after 
>>> reboot.
>>> 
>>> However this is between you and your DHCP server. If you configure a lease
>>> time of 10 minutes, then that is the only guaranteed time for a given IP
>>> address. There is no mandate that the server has to give you the same 
>>> address
>>> after 10 minutes when you ask again. It is valid to just get a different 
>>> one.
>>> And that many home routers try to give you back the same one does not mean
>>> that they are required to do so.
>>> 
>>> The nice DHCP servers will remember your Ethernet address and/or identity
>>> information and give you back your old IP address. Either with the left over
>>> lease time or with a brand new lease time. There is really no need to store
>>> this information on disk. If the lease expired the information on disk are
>>> stale as well. And since our DHCP implementation is so fast, it makes really
>>> no difference.
>>> 
>>> It is safer start out with a brand new DHCP lease instead of having to deal
>>> with renewal during boot. At least that way you know the DHCP server is 
>>> still
>>> there and you have a valid IP address. Just re-using a stored IP with a
>>> left-over lease is not safe anyway. You never know what changed in the
>>> network when you were off.
>> 
>> I think there was some misunderstanding here. I don't want to keep the
>> lease across reboots. I don't care about that. I think networkd should
>> remember the lease when restarting networkd only and not send a new dhcp
>> discover.
> 
> Right, I spoke too quickly. What I don't want is to preserve state
> between reboots, preserving it between restarts of networkd would
> indeed be fine. We already serialize the dhcp leases to /run, so I'd
> be happy to take a patch to deserialize these again when networkd
> starts.

I am not sure this is useful either. It feels like a bandaid for the time where 
networkd does not have an API to reload configuration changes. Killing networkd 
should give you a clean start from the configuration files and not magic cached 
value somewhere. Otherwise you end up with funny side effects all the time and 
have to explain to users to clear some /run states. Or ask them "to switch the 
computer off and back on again".

When you are opting for DHCP instead of static addresses, then there is really 
no guarantee for addresses staying the same. At least not for the client to 
know. So unless you own the DHCP server and configure it with static 
assignment. In all cases you have to confirm with the DHCP server that you 
address is still valid.

> That said, I'm not sure this will help you much in your case. It would
> allow us to explicitly request the current IP address when restarting
> networkd, but according to your previous email you already are getting
> assigned the correct IP address at first, and then only later does
> this change. What is causing your DHCP server to send out a different
> IP address later on, I don't know, but it seems unlikely that this is
> anything we can fix in the client.

I have my doubts as well here. Seems like a misconfigured DHCP server.

Regards

Marcel

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Tom Gundersen
On Thu, Jul 24, 2014 at 10:16 AM, Michael Olbrich
 wrote:
> On Wed, Jul 23, 2014 at 04:46:26PM +0200, Marcel Holtmann wrote:
>> Hi Michael,
>>
>> >>> I think the lease should be remembered and reused in this case.
>> >>
>> >> Hm, this sounds like a bug somewhere. When the new discover is sent
>> >> out it should send the same identifying information to the server, and
>> >> hence be given the same lease back again. Wireshark should tell you if
>> >> the fault is networkd's or the DHCP server.
>> >
>> > I get the same address at first, but after several minutes the DHCP server
>> > decides to offer a new address. I should note, that I have a 10 minute
>> > lease time for debugging purposes, so that might make the problem more
>> > prominent. I'll see if I can figure out what happens here.
>>
>> look at your DHCP server and see what lease time it really hands out after 
>> reboot.
>>
>> However this is between you and your DHCP server. If you configure a lease
>> time of 10 minutes, then that is the only guaranteed time for a given IP
>> address. There is no mandate that the server has to give you the same address
>> after 10 minutes when you ask again. It is valid to just get a different one.
>> And that many home routers try to give you back the same one does not mean
>> that they are required to do so.
>>
>> The nice DHCP servers will remember your Ethernet address and/or identity
>> information and give you back your old IP address. Either with the left over
>> lease time or with a brand new lease time. There is really no need to store
>> this information on disk. If the lease expired the information on disk are
>> stale as well. And since our DHCP implementation is so fast, it makes really
>> no difference.
>>
>> It is safer start out with a brand new DHCP lease instead of having to deal
>> with renewal during boot. At least that way you know the DHCP server is still
>> there and you have a valid IP address. Just re-using a stored IP with a
>> left-over lease is not safe anyway. You never know what changed in the
>> network when you were off.
>
> I think there was some misunderstanding here. I don't want to keep the
> lease across reboots. I don't care about that. I think networkd should
> remember the lease when restarting networkd only and not send a new dhcp
> discover.

Right, I spoke too quickly. What I don't want is to preserve state
between reboots, preserving it between restarts of networkd would
indeed be fine. We already serialize the dhcp leases to /run, so I'd
be happy to take a patch to deserialize these again when networkd
starts.

That said, I'm not sure this will help you much in your case. It would
allow us to explicitly request the current IP address when restarting
networkd, but according to your previous email you already are getting
assigned the correct IP address at first, and then only later does
this change. What is causing your DHCP server to send out a different
IP address later on, I don't know, but it seems unlikely that this is
anything we can fix in the client.

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-24 Thread Michael Olbrich
On Wed, Jul 23, 2014 at 04:46:26PM +0200, Marcel Holtmann wrote:
> Hi Michael,
> 
> >>> I think the lease should be remembered and reused in this case.
> >> 
> >> Hm, this sounds like a bug somewhere. When the new discover is sent
> >> out it should send the same identifying information to the server, and
> >> hence be given the same lease back again. Wireshark should tell you if
> >> the fault is networkd's or the DHCP server.
> > 
> > I get the same address at first, but after several minutes the DHCP server
> > decides to offer a new address. I should note, that I have a 10 minute
> > lease time for debugging purposes, so that might make the problem more
> > prominent. I'll see if I can figure out what happens here.
> 
> look at your DHCP server and see what lease time it really hands out after 
> reboot.
> 
> However this is between you and your DHCP server. If you configure a lease
> time of 10 minutes, then that is the only guaranteed time for a given IP
> address. There is no mandate that the server has to give you the same address
> after 10 minutes when you ask again. It is valid to just get a different one.
> And that many home routers try to give you back the same one does not mean
> that they are required to do so.
> 
> The nice DHCP servers will remember your Ethernet address and/or identity
> information and give you back your old IP address. Either with the left over
> lease time or with a brand new lease time. There is really no need to store
> this information on disk. If the lease expired the information on disk are
> stale as well. And since our DHCP implementation is so fast, it makes really
> no difference.
> 
> It is safer start out with a brand new DHCP lease instead of having to deal
> with renewal during boot. At least that way you know the DHCP server is still
> there and you have a valid IP address. Just re-using a stored IP with a
> left-over lease is not safe anyway. You never know what changed in the
> network when you were off.

I think there was some misunderstanding here. I don't want to keep the
lease across reboots. I don't care about that. I think networkd should
remember the lease when restarting networkd only and not send a new dhcp
discover.

Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Changing configurations with networkd

2014-07-23 Thread poma

On 23.07.2014 16:46, Marcel Holtmann wrote:

Hi Michael,


I think the lease should be remembered and reused in this case.


Hm, this sounds like a bug somewhere. When the new discover is sent
out it should send the same identifying information to the server, and
hence be given the same lease back again. Wireshark should tell you if
the fault is networkd's or the DHCP server.


I get the same address at first, but after several minutes the DHCP server
decides to offer a new address. I should note, that I have a 10 minute
lease time for debugging purposes, so that might make the problem more
prominent. I'll see if I can figure out what happens here.


look at your DHCP server and see what lease time it really hands out after 
reboot.

However this is between you and your DHCP server. If you configure a lease time 
of 10 minutes, then that is the only guaranteed time for a given IP address. 
There is no mandate that the server has to give you the same address after 10 
minutes when you ask again. It is valid to just get a different one. And that 
many home routers try to give you back the same one does not mean that they are 
required to do so.

The nice DHCP servers will remember your Ethernet address and/or identity 
information and give you back your old IP address. Either with the left over 
lease time or with a brand new lease time. There is really no need to store 
this information on disk. If the lease expired the information on disk are 
stale as well. And since our DHCP implementation is so fast, it makes really no 
difference.

It is safer start out with a brand new DHCP lease instead of having to deal 
with renewal during boot. At least that way you know the DHCP server is still 
there and you have a valid IP address. Just re-using a stored IP with a 
left-over lease is not safe anyway. You never know what changed in the network 
when you were off.

Regards

Marcel



Exactly, let him configures static leases, and that's it.

http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol
   static allocation: The DHCP server allocates an IP address based on a 
preconfigured mapping to each client's MAC address.
   This feature is variously called static DHCP assignment by DD-WRT, 
fixed-address by the dhcpd documentation,
   address reservation by Netgear, DHCP reservation or static DHCP by Cisco and 
Linksys,
   and IP address reservation or MAC/IP address binding by various other router 
manufacturers.


networkd fan club


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


Re: [systemd-devel] Changing configurations with networkd

2014-07-23 Thread Marcel Holtmann
Hi Michael,

>>> I think the lease should be remembered and reused in this case.
>> 
>> Hm, this sounds like a bug somewhere. When the new discover is sent
>> out it should send the same identifying information to the server, and
>> hence be given the same lease back again. Wireshark should tell you if
>> the fault is networkd's or the DHCP server.
> 
> I get the same address at first, but after several minutes the DHCP server
> decides to offer a new address. I should note, that I have a 10 minute
> lease time for debugging purposes, so that might make the problem more
> prominent. I'll see if I can figure out what happens here.

look at your DHCP server and see what lease time it really hands out after 
reboot.

However this is between you and your DHCP server. If you configure a lease time 
of 10 minutes, then that is the only guaranteed time for a given IP address. 
There is no mandate that the server has to give you the same address after 10 
minutes when you ask again. It is valid to just get a different one. And that 
many home routers try to give you back the same one does not mean that they are 
required to do so.

The nice DHCP servers will remember your Ethernet address and/or identity 
information and give you back your old IP address. Either with the left over 
lease time or with a brand new lease time. There is really no need to store 
this information on disk. If the lease expired the information on disk are 
stale as well. And since our DHCP implementation is so fast, it makes really no 
difference.

It is safer start out with a brand new DHCP lease instead of having to deal 
with renewal during boot. At least that way you know the DHCP server is still 
there and you have a valid IP address. Just re-using a stored IP with a 
left-over lease is not safe anyway. You never know what changed in the network 
when you were off.

Regards

Marcel

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


Re: [systemd-devel] Changing configurations with networkd

2014-07-23 Thread Michael Olbrich
On Wed, Jul 23, 2014 at 12:47:37PM +0200, Tom Gundersen wrote:
> On Wed, Jul 23, 2014 at 9:50 AM, Michael Olbrich
>  wrote:
> > I've been experimenting with systemd-networkd to see where it fits my
> > use-cases. I'm looking for some insight if the issues I'm seeing are bugs,
> > features just not implemented yet or if my use-case is out of scope for
> > networkd.
> > The most common use-case I have is rather simple: One ethernet interface
> > that can be configured either with a static IP address or via DHCP. The
> > configuration usually comes from some custom configuration data, so I'll
> > probably have a default config as part of the rootfs and generate the real
> > config during startup in /run. This works rather well and is much nicer
> > than some custom shell scripts.
> > The interesting part is, when the configuration changes: I'm working with
> > embedded devices and network access is rarely part of the primary function
> > of the device. As a result, rebooting the device to change the network
> > config is not acceptable.
> >
> > So I tried to change a static IP address by changing the config and
> > restarting networkd. The result was an interface with two addresses. And
> > worse, the old address was still the preferred on.
> > I realize, that a smooth transition is probably impossible for complex
> > configuration possibilities of networkd. But I don't need smooth. How about
> > optionally shutting down an interface when networkd stops?
> > ShutdownWithNetworkd=yes or something like that in the config file?
> 
> Dynamic changing of settings has not been implemented yet, we are so
> far only focussing on the static setups. We definitely will cover more
> dynamic things in the future though, such as your usecase.
> 
> We'll have a dbus interface, and not use stop/restart as a
> configuration mechanism, so I don't think tearing things down on
> shutdown of the demon makes much sense.

That sounds interesting.

> In the meantime, you could hack this by doing:
> 
> systemctl stop systemd-networkd
> ip link address flush dev 
> systemctl start systemd-networkd

I know, but that's not very nice, and I need to handle nfs-root special
cases manually...

> > Another thing I noticed is with DHCP without changing the configuration:
> > Networkd forgets the lease during restart and sends a dhcp discover. Then
> > the server might offer a different address. The problem is, that the new
> > address is in the same subnet as the old address, so it is added as
> > secondary address. When the valid_lft of the old address expires then
> > _both_ addresses are removed :-/.
> 
> Thanks for this report, we should figure out a way that the new
> address is not lost when the first one is.

I looked at the code, but I need to learn more about netlink before I
understand the little details there.

> > I think the lease should be remembered and reused in this case.
> 
> Hm, this sounds like a bug somewhere. When the new discover is sent
> out it should send the same identifying information to the server, and
> hence be given the same lease back again. Wireshark should tell you if
> the fault is networkd's or the DHCP server.

I get the same address at first, but after several minutes the DHCP server
decides to offer a new address. I should note, that I have a 10 minute
lease time for debugging purposes, so that might make the problem more
prominent. I'll see if I can figure out what happens here.

Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Changing configurations with networkd

2014-07-23 Thread Reindl Harald

Am 23.07.2014 12:47, schrieb Tom Gundersen:
>> I think the lease should be remembered and reused in this case.
> In general, saving the lease to disk is probably not a good idea. We
> would need to store it on /var, and we may need to start the DHCP
> server before /var has been mounted. To the extent possible I would
> prefer to avoid that problem

wheren't such cases the reason to invent /run?



signature.asc
Description: OpenPGP digital signature
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Changing configurations with networkd

2014-07-23 Thread Tom Gundersen
On Wed, Jul 23, 2014 at 9:50 AM, Michael Olbrich
 wrote:
> I've been experimenting with systemd-networkd to see where it fits my
> use-cases. I'm looking for some insight if the issues I'm seeing are bugs,
> features just not implemented yet or if my use-case is out of scope for
> networkd.
> The most common use-case I have is rather simple: One ethernet interface
> that can be configured either with a static IP address or via DHCP. The
> configuration usually comes from some custom configuration data, so I'll
> probably have a default config as part of the rootfs and generate the real
> config during startup in /run. This works rather well and is much nicer
> than some custom shell scripts.
> The interesting part is, when the configuration changes: I'm working with
> embedded devices and network access is rarely part of the primary function
> of the device. As a result, rebooting the device to change the network
> config is not acceptable.
>
> So I tried to change a static IP address by changing the config and
> restarting networkd. The result was an interface with two addresses. And
> worse, the old address was still the preferred on.
> I realize, that a smooth transition is probably impossible for complex
> configuration possibilities of networkd. But I don't need smooth. How about
> optionally shutting down an interface when networkd stops?
> ShutdownWithNetworkd=yes or something like that in the config file?

Dynamic changing of settings has not been implemented yet, we are so
far only focussing on the static setups. We definitely will cover more
dynamic things in the future though, such as your usecase.

We'll have a dbus interface, and not use stop/restart as a
configuration mechanism, so I don't think tearing things down on
shutdown of the demon makes much sense.

In the meantime, you could hack this by doing:

systemctl stop systemd-networkd
ip link address flush dev 
systemctl start systemd-networkd

> Another thing I noticed is with DHCP without changing the configuration:
> Networkd forgets the lease during restart and sends a dhcp discover. Then
> the server might offer a different address. The problem is, that the new
> address is in the same subnet as the old address, so it is added as
> secondary address. When the valid_lft of the old address expires then
> _both_ addresses are removed :-/.

Thanks for this report, we should figure out a way that the new
address is not lost when the first one is.

> I think the lease should be remembered and reused in this case.

Hm, this sounds like a bug somewhere. When the new discover is sent
out it should send the same identifying information to the server, and
hence be given the same lease back again. Wireshark should tell you if
the fault is networkd's or the DHCP server.

In general, saving the lease to disk is probably not a good idea. We
would need to store it on /var, and we may need to start the DHCP
server before /var has been mounted. To the extent possible I would
prefer to avoid that problem.

Cheers

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


[systemd-devel] Changing configurations with networkd

2014-07-23 Thread Michael Olbrich
Hi,

I've been experimenting with systemd-networkd to see where it fits my
use-cases. I'm looking for some insight if the issues I'm seeing are bugs,
features just not implemented yet or if my use-case is out of scope for
networkd.
The most common use-case I have is rather simple: One ethernet interface
that can be configured either with a static IP address or via DHCP. The
configuration usually comes from some custom configuration data, so I'll
probably have a default config as part of the rootfs and generate the real
config during startup in /run. This works rather well and is much nicer
than some custom shell scripts.
The interesting part is, when the configuration changes: I'm working with
embedded devices and network access is rarely part of the primary function
of the device. As a result, rebooting the device to change the network
config is not acceptable.

So I tried to change a static IP address by changing the config and
restarting networkd. The result was an interface with two addresses. And
worse, the old address was still the preferred on.
I realize, that a smooth transition is probably impossible for complex
configuration possibilities of networkd. But I don't need smooth. How about
optionally shutting down an interface when networkd stops?
ShutdownWithNetworkd=yes or something like that in the config file?

Another thing I noticed is with DHCP without changing the configuration:
Networkd forgets the lease during restart and sends a dhcp discover. Then
the server might offer a different address. The problem is, that the new
address is in the same subnet as the old address, so it is added as
secondary address. When the valid_lft of the old address expires then
_both_ addresses are removed :-/.
I think the lease should be remembered and reused in this case.

Regards,
Michael

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel