Fix sending broken RTM_DELADDR message in some operations.

Here is mininum reproduction operation.
====================
# ifconfig ixg0 172.16.0.1/29
# route monitor &
# ifconfig pppoe0 172.16.0.1/32 0.0.0.1
====================

The broken RTM_DELADDR is the following.
====================
got message of size 72 on Thu Nov 17 12:50:42 2022
#13: len 72, got message of size 80 on Thu Nov 17 12:50:42 2022
RTM_DELADDR: address being removed from iface: len 80, pid 3552, metric 0, addrflags: 0
sockaddrs: 0xb4<NETMASK,IFP,IFA,BRD>
 Q00.00.ff.ff.ff.ff.00.00.00.00.00.00.00.00 pppoe0 default default
====================

This problem is related to the following two commit.

(1) b021021468
    that is, sys/netinet/in.c:r1.183

(2) 61bad33c44
    that is, sys/netinet/in.c:r1.185

(1) adds in_scrubaddr() for old addresses to in_ifinit() without checking
IFA_ROUTE.
And then, (2) removes in_ifscrub() for POINTTOPOINT interface in in_control0.
The removed in_ifscrub() is called with checking IFA_ROUTE.
It seems these modifications about checking IFA_ROUTE logic causes this
problem, however the real reason is calling in_ifscrub() for the interface
which does not have IPv4 address.  So, scrubbing old address processing
should be done only if the interface already has IPv4 address.
This commit is contained in:
knakahara 2022-11-17 05:02:11 +00:00
parent cd2e09c9fd
commit 77dab346ef
1 changed files with 7 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: in.c,v 1.244 2022/11/04 09:03:20 ozaki-r Exp $ */
/* $NetBSD: in.c,v 1.245 2022/11/17 05:02:11 knakahara Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.244 2022/11/04 09:03:20 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.245 2022/11/17 05:02:11 knakahara Exp $");
#include "arp.h"
@ -1194,7 +1194,11 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia,
return error;
}
if (scrub || hostIsNew) {
/*
* The interface which does not have IPv4 address is not required
* to scrub old address. So, skip scrub such cases.
*/
if (oldaddr.sin_family == AF_INET && (scrub || hostIsNew)) {
int newflags = ia->ia4_flags;
ia->ia_ifa.ifa_addr = sintosa(&oldaddr);