Bug 195191 - rtadvd(8): Retry on NET_RT_IFLIST sysctl failure like getifaddrs
Summary: rtadvd(8): Retry on NET_RT_IFLIST sysctl failure like getifaddrs
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Mark Johnston
URL:
Keywords: feature
Depends on:
Blocks:
 
Reported: 2014-11-19 23:35 UTC by guyyur
Modified: 2019-05-10 08:58 UTC (History)
7 users (show)

See Also:
koobs: mfc-stable12+
koobs: mfc-stable11+


Attachments
Retry NET_RT_IFLIST sysctl. (2.12 KB, patch)
2014-11-19 23:35 UTC, guyyur
no flags Details | Diff
Retry NET_RT_IFLIST sysctl (2.04 KB, patch)
2019-04-17 18:48 UTC, guyyur
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description guyyur 2014-11-19 23:35:29 UTC
Created attachment 149611 [details]
Retry NET_RT_IFLIST sysctl.

rtadvd exits after printing the message:
rtadvd[41840]: <update_ifinfo> sysctl: NET_RT_IFLIST get failed

The NET_RT_IFLIST sysctl required buffer size can change between the request for the size and the request for the data.
getifaddrs handles this by retrying the sysctl several times.

I copied the comment and looping from lib/libc/net/getifaddrs.c to have rtadvd behave like getifaddrs.

rtadvd should probably also be changed to not need to call the sysctl for every message if the required info can be obtained by other means.


Issue replicated in an environment with dhcpcd for DHCPv6-PD giving an address to a lan interface and a tun interface.
Restarting dhcpcd can sometimes trigger the problem.

dhcpcd adds a global ipv6 addresses and routes to the interfaces triggering RTM_NEWADDR and RTM_ADD.
rtadvd calls update_ifinfo on RTM_NEWADDR and RTM_ADD.

The likely scenario is:
dhcpcd adds an address for the lan interface.
rtadvd receives RTM_NEWADDR for the lan interface.
rtadvd calls the sysctl to get the required size.
dhcpcd adds an address for the tun interface.
size changed.
rtadvd calls the sysctl to get the data size with small buffer.
Comment 1 Eugene M. Kim 2017-01-16 19:42:29 UTC
+1 on this one.  This happens with a near consistency when new epair devices get created on my 11.0-RELEASE-p7 system.
Comment 2 Delta Regeer 2018-03-28 06:58:51 UTC
This is happening on startup for me when dhcp6c is pulling addresses from Comcast and assirgning them to vlan interfaces, thereby shutting down rtadvd entirely and leaving me without any IPv6 connectivity at all.
Comment 3 mickey242 2019-02-14 12:16:46 UTC
+1 also happening for me on 12.0-RELEASE-p3 amd64:
rtadvd[62952]: <update_ifinfo> sysctl: NET_RT_IFLIST get failed

Seems to be happening quite frequently as I'm on a DSL line with forced reconnect by ISP every 24 hours, which triggers dhcp6c and getting a new dynamic IPv6 prefix which is then assigned to the re0 and tun0 interfaces on which rtadvd operates.
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2019-04-16 22:13:02 UTC
Reset assignee, timeout (2 years)

@Hiroki If you can still take care of this issue, please re-assign yourself

@All If the existing patch (attachment 149611 [details]) no longer applies against CURRENT, it would be great if someone could rebase it to HEAD and confirm that it still resolves the issue for their use case
Comment 5 guyyur 2019-04-17 18:48:07 UTC
Created attachment 203750 [details]
Retry NET_RT_IFLIST sysctl

The original patch still applies to 12-RELEASE and 13-CURRENT (r346321).

I uploaded an updated patch that defines the "ntry" variable in the same line as "error" instead of on a separate line.
The rest of the changes are the same.
Comment 6 Philipp Erbelding 2019-04-25 20:02:40 UTC
I've applied the original patch against 12.0-RELEASE eight days ago and did not have another rtadvd outage since then. Before this, the process seemedt to never make it more than 3 days in my VDSL dialup setting with 24h disconnects from ISP side.
Comment 7 commit-hook freebsd_committer freebsd_triage 2019-04-30 14:45:40 UTC
A commit references this bug:

Author: markj
Date: Tue Apr 30 14:44:40 UTC 2019
New revision: 346960
URL: https://svnweb.freebsd.org/changeset/base/346960

Log:
  Retry upon NET_RT_IFLIST sysctl failure.

  Port the logic used by getifaddrs(3) to handle the case where
  NET_RT_IFLIST returns ENOMEM, which can occur if the list size changes
  between the buffer allocation and sysctl read.

  PR:		195191
  Submitted by:	Guy Yur <guyyur@gmail.com> (original version)
  MFC after:	1 week

Changes:
  head/usr.sbin/rtadvd/if.c
Comment 8 commit-hook freebsd_committer freebsd_triage 2019-05-08 16:04:49 UTC
A commit references this bug:

Author: markj
Date: Wed May  8 16:04:33 UTC 2019
New revision: 347349
URL: https://svnweb.freebsd.org/changeset/base/347349

Log:
  MFC r346960:
  Retry upon NET_RT_IFLIST sysctl failure.

  PR:	195191

Changes:
_U  stable/12/
  stable/12/usr.sbin/rtadvd/if.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2019-05-08 16:07:58 UTC
A commit references this bug:

Author: markj
Date: Wed May  8 16:07:43 UTC 2019
New revision: 347353
URL: https://svnweb.freebsd.org/changeset/base/347353

Log:
  MFC r346960:
  Retry upon NET_RT_IFLIST sysctl failure.

  PR:	195191

Changes:
_U  stable/11/
  stable/11/usr.sbin/rtadvd/if.c
Comment 10 Mark Johnston freebsd_committer freebsd_triage 2019-05-08 16:08:19 UTC
Thanks for the report.