Bug 235909 - net/dual-dhclient: does not survive a netif restart
Summary: net/dual-dhclient: does not survive a netif restart
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Colin Percival
URL: https://www.freshports.org/net/dual-d...
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-21 07:29 UTC by Christopher Hall
Modified: 2023-10-01 16:55 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (cperciva)


Attachments
replacement dual-dhclient (265 bytes, application/x-shellscript)
2019-02-21 07:29 UTC, Christopher Hall
no flags Details
patch to fix restart and host.conf corruption (19.30 KB, patch)
2019-04-15 07:04 UTC, Christopher Hall
no flags Details | Diff
New port: dual-dhclient-daemon (3.67 KB, patch)
2019-09-28 17:24 UTC, Colin Percival
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Hall 2019-02-21 07:29:19 UTC
Created attachment 202219 [details]
replacement dual-dhclient

when using net/dual-dhclient and doing a service netif restart the DHPv6 address is lost.  This is because the dhclient6 is not killed during the stop process since the base dhclient is unaware of the /var/run/dhclient6.pid file to terminate the second dhclient.

As a quick workaround replace the installed /usr/local/sbin/dual-dhclient with the attached script.  The script just adds these two lines just befor starting the dhclients

    pid6=/var/run/dhclient6.pid
    [ -n "${pid6}" ] && kill $(cat "${pid6}")
Comment 1 Christopher Hall 2019-02-22 07:03:44 UTC
also the /etc/resolv.conf is replaced by single nameserver line with only IPv6 address.  (which breaks DNS if local_unbound is selected and has special local config)
Comment 2 Christopher Hall 2019-04-15 07:04:20 UTC
Created attachment 203684 [details]
patch to fix restart and host.conf corruption

This adds fixes for:
  1. service netif restart i.e. it ensures that the dhclient6 is killed and restarted properly
  2. that /etc/host.conf is updated by both IPv4 and IPv6 client
  3. updates to host.conf occur with a lock to prevent corruption
  4. updates to IPv4 does not remove IPv6 config and vice versa
Comment 3 Christopher Hall 2019-04-15 07:07:57 UTC
The latest patch does not fix the "service netif stop" bug, which is the fact that the rc.d system will only stop the v4 dhclient because the dual-dhclient script is only called on a start.  The rc.d system only appears to stop the v4 dhclient and even adding the pid of the v6 client to the v4 pidfiel is not sufficient.
Comment 4 Christopher Hall 2019-04-15 08:56:10 UTC
for reference updates to net/dhcpcd which would likely make the above patch redundant is blocked by:

bug #194485  see also: review D15404 and review D15405
Comment 5 Colin Percival freebsd_committer freebsd_triage 2019-09-28 17:24:26 UTC
Created attachment 207922 [details]
New port: dual-dhclient-daemon
Comment 6 Colin Percival freebsd_committer freebsd_triage 2019-09-28 17:25:57 UTC
Christopher, can you try this new port (dual-dhclient-daemon, patch above)?  It should handle the service stop/restart properly since it replaces the shell script with a daemon which catches SIGTERM and relays it to the two "child" dhclient daemons.
Comment 7 Christopher Hall 2019-10-01 05:09:50 UTC
I get this error during make:
make[1]: "/usr/share/mk/bsd.opts.mk" line 101: warning: "NO_MAN is defined, but deprecated. Please use MK_MAN=no instead."

but it does install though it might need the same depends as the original:

RUN_DEPENDS=	${LOCALBASE}/sbin/dhclient:net/isc-dhcp44-client

after adding the run depend I was able to get both IPv4 and IPv6 addresses
though I think I must be missing some configuration as it never gets an IPv6 default route.

I ran service netif restart several times and the IPv4/IPv6 addresses are restored and only IPv4 default route is ok.

Also it appears to overwrite /etc/resolv.conf with just the IPv6 nameserver
ignoring the settings in /etc/resolvconf.conf - just the net/isc-dhcp44-client problem I expect
Comment 8 Christopher Hall 2019-10-01 05:21:00 UTC
the default route likely need these to be sorted first:

https://reviews.freebsd.org/D15404
https://reviews.freebsd.org/D15405
https://reviews.freebsd.org/D15406
Comment 9 Colin Percival freebsd_committer freebsd_triage 2019-10-02 04:32:49 UTC
Good catch on the missing RUN_DEPENDS, thanks!

I don't know why "service netif restart" breaks IPv6; running "service dhclient restart xn0" in EC2 works just fine.

In any case, since the daemon doesn't seem to have any problems which the shell script doesn't already have, I'll add this new port and switch the EC2 builds over to use it.
Comment 10 Christopher Hall 2019-10-02 05:33:54 UTC
it does not break, I never get a default route for IPv6.
the server is pfsense in assisted mode so that could be the problem.

I will try in a vnet jail when the pkg is ready
Comment 11 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:40:49 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>
Comment 12 Colin Percival freebsd_committer freebsd_triage 2023-10-01 16:55:29 UTC
Closing this PR; the problem is effectively unsolvable in dual-dhclient, but goes away if people use dual-dhclient-daemon (which they should be doing).