NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/53705: dhcpcd spams syslogd



>Number:         53705
>Category:       bin
>Synopsis:       dhcpcd spams syslogd
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 07 04:25:00 +0000 2018
>Originator:     Robert Elz
>Release:        NetBSD 8.99.25
>Organization:
>Environment:
System: NetBSD jinx.noi.kre.to 8.99.25 NetBSD 8.99.25 (GENERIC) #0: Thu Sep 13 23:55:24 ICT 2018 kre%onyx.coe.psu.ac.th@localhost:/usr/obj/testing/amd64/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	I am at the IETF meeting in Bangkok.   The network here is
	configured to assign v6 addresses using SLAAC, but has
	DHCPv6 configured to supply the "other" info (DNS servers,...)

	This all works fine.

	But it appears that twice (why twice) every 30 seconds or so
	dhcpcd sends (as extracted from the syslog log file):

Nov  7 10:37:04 jinx dhcpcd[211]: iwm0: DHCPv6 REPLY: No addresses available for
 this interface.

	That's not true, dhcpcd has assigned an IPv6 address to
	the interface (and v4) ...

iwm0: flags=0x8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        ssid ietf-legacy103
        powersave off
        bssid 70:70:8b:08:3d:0f chan 161
        address: 34:13:e8:2f:bb:c4
        media: IEEE802.11 autoselect (OFDM24 mode 11a)
        status: active
        inet 31.133.137.213/20 broadcast 31.133.143.255 flags 0x0
        inet6 fe80::3613:e8ff:fe2f:bbc4%iwm0/64 flags 0x0 scopeid 0x2
        inet6 2001:67c:370:128:1f6d:85c6:2217:387c/64 flags 0x0

	It just did not come in the DHCPv6 reply packet, but via
	SLAAC.

	The errors reports repeat, two of them identified as being at the
	same second, that pair seems to repeat every 30 secs.

>How-To-Repeat:
	Come to the IETF meeting ...

	Alternatively config DHCPv6 to not supply an address, and
	use RAs from the local router to assign v6 addresses (but
	keep the DHCPv6 server running. a DHCPv6-lite server will
	work fine for this I think).

>Fix:
	I added the following patch.   It helps for me.   However,
	this is all wrong, and should not be installed in general.

	Wrong with it:

	1. it still logs the message occasionally, when ideally when
	   SLAAC is being used, this message should not appear at all,
	   it is confusing...

	2. the coding is NetBSD specific ( uses __arraycount() )

	3. it has a built in (inline code) 2 hour noise supression
	   which should not be needed at all if (1) above is addressed,
	   and if it is needed, should come from the config file (or
	   an option, or both) or at worst from a #define somewhere.

	4. It assumes that the first DHCPv6 reply will not be seen
	   before 02:00 Jan 1, 1970, UTC (ie: that time(NULL) > 7200
	   always...)   This one is unlikely to be a serious problem
	   until we invent time travel...

	5. The "now = time(NULL)" line could be moved inside the
	   following "if", but that always seems to be true in
	   normal use, so really makes no difference in practice.

Index: src/dhcp6.c
===================================================================
RCS file: /cvsroot/src/external/bsd/dhcpcd/dist/src/dhcp6.c,v
retrieving revision 1.2
diff -u -r1.2 dhcp6.c
--- src/dhcp6.c	4 Nov 2018 16:30:28 -0000	1.2
+++ src/dhcp6.c	7 Nov 2018 04:02:28 -0000
@@ -43,6 +43,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <time.h>
 
 #define ELOOP_QUEUE 4
 #include "config.h"
@@ -1916,6 +1917,8 @@
 	void * (*f)(void *, size_t, uint16_t, uint16_t *), *farg;
 	char buf[32], *sbuf;
 	const char *status;
+	time_t now;
+	static time_t reported[__arraycount(dhcp6_statuses)];
 
 	f = p ? dhcp6_findoption : dhcp6_findmoption;
 	if (p)
@@ -1936,6 +1939,13 @@
 	if (code == D6_STATUS_OK)
 		return 1;
 
+	now = time(NULL);
+	if (code < __arraycount(reported)) {
+		if (reported[code] + (3600 * 2) < now)
+			return -1;
+		reported[code] = now;
+	}
+
 	/* Anything after the code is a message. */
 	opt += sizeof(code);
 	mlen = opt_len - sizeof(code);



Home | Main Index | Thread Index | Old Index