dhcpcd-discuss

Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequence

Guy Yur

Thu Sep 01 21:59:09 2016

Hi Roy,

On Thu, Sep 1, 2016 at 4:24 PM, Roy Marples <roy@xxxxxxxxxxxx> wrote:
> On 01/09/2016 12:38, Roy Marples wrote:
>> On 30/08/2016 21:35, Guy Yur wrote:
>>> ... (trimmed)
>>
>> While I cannot work out the behaviour differences, I can say for sure
>> that FreeBSD sends RTM_DELADDR for each address on the interface when
>> marked down. You can see this using route monitor.
>>
>> This behaviour strikes me as incorrect as the address is clearly still
>> on the interface.
>>
>> For reference, NetBSD marks each address as IN{,6}_IFF_DETACHED and
>> sends RTM_NEWADDR (because the address is still there) while other BSD's
>> do nothing special.
>>
>> As FreeBSD isn't in the habit of fixing any kernel issues I've reported
>> over the years with dhcpcd I guess we'll have to add a workaround -
>> maybe check with getifaddrs if the address still exists or not.
>
> I don't know why, but the bogus RTM_DELADDR is only emitted for INET
> addresses, not INET6. That explains the behaviour difference. So I'd say
> it's definitely a bug in FreeBSD - it's inconsisent and for INET, wrong
> IMHO.

I tracked it down to rip_ctlinput in raw_ip.c, code added in r22672.
From the comment, it removes all non-static routes on interface down
and restores the routes on interface up.
in_scrub sends the RTM_DELADDR and rtinit sends the RTM_NEWADDR.

https://svnweb.freebsd.org/base/head/sys/netinet/raw_ip.c?revision=22672&view=markup

This is different from rip_ctlinput in NetBSD.
Also different from rip6_ctlinput in FreeBSD which
explains the different behavior between IPv4 and IPv6.

>
> Also, FreeBD (and OpenBSD so it's a good fix) don't set link down on
> interface down gratuitously.
>
> Worked around here:
> http://roy.marples.name/projects/dhcpcd/ci/ad1a4b349d68a82b?sbs=0
>
> Let me know how it works for you!
>
> Roy

With new patch, addresses are removed on if down too.
IPv4 is restored on if up but IPv6 RA addresses are not.

lan0: soliciting an IPv6 router
lan0: sending Router Solicitation
lan0: ipv6nd_sendrsprobe: sendmsg: Can't assign requested address

IPv6 addresses are restored correctly for link disconnect/reconnect.

I am running with a patched kernel for FreeBSD bug 195197
so I don't know if that is the reason for the failure.
I will test with an unpatched kernel until I finish porting your NetBSD
fix for the bug.  I need to find the correct locking to use in FreeBSD.

Thanks,
Guy

Follow-Ups:
Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequenceRoy Marples
References:
dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequenceGuy Yur
Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequenceRoy Marples
Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequenceGuy Yur
Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequenceRoy Marples
Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequenceGuy Yur
Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequenceRoy Marples
Re: dhcpcd 6.11.3 core dumps on FreeBSD with link disconnect/connect sequenceRoy Marples
Archive administrator: postmaster@marples.name