NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/51622: npf startup failure when using dhcpcd inet4 and inet6
The following reply was made to PR bin/51622; it has been noted by GNATS.
From: Timshel Knoll-Miller <timshel%fluentdevelopment.com.au@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/51622: npf startup failure when using dhcpcd inet4 and inet6
Date: Sun, 13 Nov 2016 17:57:44 +1100
--94eb2c09538e8d35ca0541293d61
Content-Type: multipart/alternative; boundary=94eb2c09538e8d35c10541293d5f
--94eb2c09538e8d35c10541293d5f
Content-Type: text/plain; charset=UTF-8
I've discovered a few more details since I logged this.
It seems that this NPF failure only occurs when dhcpcd(8) is acquiring
addresses for more than one interface.
Contrary to what I've written before, when dhcpcd(8) is bound to a SINGLE
interface, and "--waitip 4 --waitip 6" arguments are given, it does seem to
wait until both IPv4 and IPv6 addresses have been assigned before forking
to the background.
However, when used with multiple interfaces, dhcpcd will fork after ANY one
interface gets an IPv4 address, and ANY one interface gets an IPv6 address.
NPF then gets enabled, and if npf.conf includes an inet4() or inet6() call
for an interface that doesn't have any addresses of that type, it fails as
described in my original PR.
The servers I've been experiencing this issue with have two interfaces - an
external-facing one on a public IP, and an internal one on a private IP.
Hence why this was occuring for me. Even though I only had my npf.conf
looking for addresses on my public interface, I was passing "-qM vioif0
vioif1" and dhcpcd was forking to the background before it had assigned an
IPv4 address to vioif0. It seems the DHCP server on vioif1 is a bit quicker
as this was happening pretty consistently.
I found you can work around this by running dhcpcd separately for each
interface. Adding "!dhcpcd -q --waitip 4 --waitip 6 $int" to each
/etc/ifconfig.<interface> and setting dhcpcd=NO in /etc/rc.conf does work.
However it also makes the startup take quite a lot longer, as it has to run
DHCP requests separately for each interface, rather than in parallel. And
dhcpcd can't really be used in master mode in this circumstance.
I've looked through the NetBSD dhcpcd commits to -current and noticed that
there a fix to this issue was committed in May 2015 when dhcpcd was updated
to version 6.9.0. (see the new dhcpcd_ifipwaited() function and changes to
dhcpcd_ipwaited() in `cvs diff -r1.24 -r1.25
external/bsd/dhcpcd/dist/dhcpcd.c').
I've backported the relevant changes from dhcpcd 6.9.0 and attached a
patch. I've built 7.0_STABLE and 7.0.2_PATCH releases locally with this
patch applied. With "dhcpcd_args="-qM --waitip 4 --waitip6 vioif0 vioif1"
in my /etc/rc.conf, npf successfully enables on boot.
While this isn't a show-stopper, it significantly limits npf's usefulness
on NetBSD 7 and would be good to see this issue fixed on the netbsd-7
branch prior to 7.1 please.
Cheers,
Timshel
--94eb2c09538e8d35c10541293d5f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I've discovered a few more details since I logged this=
.<div><br></div><div>It seems that this NPF failure only occurs when dhcpcd=
(8) is acquiring addresses for more than one interface.</div><div><br></div=
><div>Contrary to what I've written before, when dhcpcd(8) is bound to =
a SINGLE interface, and "--waitip 4 --waitip 6" arguments are giv=
en, it does seem to wait until both IPv4 and IPv6 addresses have been assig=
ned before forking to the background.</div><div><br></div><div>However, whe=
n used with multiple interfaces, dhcpcd will fork after ANY one interface g=
ets an IPv4 address, and ANY one interface gets an IPv6 address. NPF then g=
ets enabled, and if npf.conf includes an inet4() or inet6() call for an int=
erface that doesn't have any addresses of that type, it fails as descri=
bed in my original PR.</div><div><div><br class=3D"gmail-Apple-interchange-=
newline">The servers I've been experiencing this issue with have two in=
terfaces - an external-facing one on a public IP, and an internal one on a =
private IP. Hence why this was occuring for me. Even though I only had my n=
pf.conf looking for addresses on my public interface, I was passing "-=
qM vioif0 vioif1" and dhcpcd was forking to the background before it h=
ad assigned an IPv4 address to vioif0. It seems the DHCP server on vioif1 i=
s a bit quicker as this was happening pretty consistently.</div></div><div>=
<br></div><div>I found you can work around this by running dhcpcd separatel=
y for each interface. Adding "!dhcpcd -q --waitip 4 --waitip 6 $int&qu=
ot; to each /etc/ifconfig.<interface> and setting dhcpcd=3DNO in /etc=
/rc.conf does work. However it also makes the startup take quite a lot long=
er, as it has to run DHCP requests separately for each interface, rather th=
an in parallel. And dhcpcd can't really be used in master mode in this =
circumstance.</div><div><br></div><div>I've looked through the NetBSD d=
hcpcd commits to -current and noticed that there a fix to this issue was co=
mmitted in May 2015 when dhcpcd was updated to version 6.9.0. (see the new =
dhcpcd_ifipwaited() function and changes to dhcpcd_ipwaited() in =C2=A0`cvs=
diff -r1.24 -r1.25 external/bsd/dhcpcd/dist/dhcpcd.c').</div><div><br>=
</div><div>I've backported the relevant changes from dhcpcd 6.9.0 and a=
ttached a patch. I've built 7.0_STABLE and 7.0.2_PATCH releases locally=
with this patch applied. With "dhcpcd_args=3D"-qM --waitip 4 --w=
aitip6 vioif0 vioif1" in my /etc/rc.conf, npf successfully enables on =
boot.<br></div><div><br></div><div>While this isn't a show-stopper, it =
significantly limits npf's usefulness on NetBSD 7 and would be good to =
see this issue fixed on the netbsd-7 branch prior to 7.1 please.=C2=A0<br><=
/div><div><div class=3D"gmail_extra"><div><div class=3D"gmail_signature"><d=
iv dir=3D"ltr">
<div dir=3D"ltr">
<p style=3D"font-family:verdana,sans-serif">Cheers,</p><p style=3D"font=
-family:verdana,sans-serif">Timshel</p></div></div></div></div></div></div>=
</div>
--94eb2c09538e8d35c10541293d5f--
--94eb2c09538e8d35ca0541293d61
Content-Type: application/octet-stream;
name="netbsd-7-dhcpcd-wait-all-ifs.patch"
Content-Disposition: attachment;
filename="netbsd-7-dhcpcd-wait-all-ifs.patch"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_ivg9w23i0
ZGlmZiAtLWdpdCBhL2V4dGVybmFsL2JzZC9kaGNwY2QvZGlzdC9kaGNwY2QuYyBiL2V4dGVybmFs
L2JzZC9kaGNwY2QvZGlzdC9kaGNwY2QuYwppbmRleCAwYjg1YWExLi5hZjU0MDMxIDEwMDY0NAot
LS0gYS9leHRlcm5hbC9ic2QvZGhjcGNkL2Rpc3QvZGhjcGNkLmMKKysrIGIvZXh0ZXJuYWwvYnNk
L2RoY3BjZC9kaXN0L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