Mon Mar 9 17:57:19 2020 UTC ()
arp: report RTM_MISS when removing an unresolved entry in the arp table

Otherwise we only get it when renewing and we've sent too many requests.
This mirrors INET6 behaviour.


(roy)
diff -r1.292 -r1.293 src/sys/netinet/if_arp.c

cvs diff -r1.292 -r1.293 src/sys/netinet/if_arp.c (expand / switch to unified diff)

--- src/sys/netinet/if_arp.c 2020/01/23 17:27:35 1.292
+++ src/sys/netinet/if_arp.c 2020/03/09 17:57:19 1.293
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_arp.c,v 1.292 2020/01/23 17:27:35 roy Exp $ */ 1/* $NetBSD: if_arp.c,v 1.293 2020/03/09 17:57:19 roy Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Public Access Networks Corporation ("Panix"). It was developed under 8 * by Public Access Networks Corporation ("Panix"). It was developed under
9 * contract to Panix by Eric Haszlakiewicz and Thor Lancelot Simon. 9 * contract to Panix by Eric Haszlakiewicz and Thor Lancelot Simon.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -58,27 +58,27 @@ @@ -58,27 +58,27 @@
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE. 59 * SUCH DAMAGE.
60 * 60 *
61 * @(#)if_ether.c 8.2 (Berkeley) 9/26/94 61 * @(#)if_ether.c 8.2 (Berkeley) 9/26/94
62 */ 62 */
63 63
64/* 64/*
65 * Ethernet address resolution protocol. 65 * Ethernet address resolution protocol.
66 * TODO: 66 * TODO:
67 * add "inuse/lock" bit (or ref. count) along with valid bit 67 * add "inuse/lock" bit (or ref. count) along with valid bit
68 */ 68 */
69 69
70#include <sys/cdefs.h> 70#include <sys/cdefs.h>
71__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.292 2020/01/23 17:27:35 roy Exp $"); 71__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.293 2020/03/09 17:57:19 roy Exp $");
72 72
73#ifdef _KERNEL_OPT 73#ifdef _KERNEL_OPT
74#include "opt_ddb.h" 74#include "opt_ddb.h"
75#include "opt_inet.h" 75#include "opt_inet.h"
76#include "opt_net_mpsafe.h" 76#include "opt_net_mpsafe.h"
77#endif 77#endif
78 78
79#ifdef INET 79#ifdef INET
80 80
81#include "arp.h" 81#include "arp.h"
82#include "bridge.h" 82#include "bridge.h"
83 83
84#include <sys/param.h> 84#include <sys/param.h>
@@ -297,38 +297,42 @@ arptimer(void *arg) @@ -297,38 +297,42 @@ arptimer(void *arg)
297 return; 297 return;
298 } 298 }
299 299
300 ifp = lle->lle_tbl->llt_ifp; 300 ifp = lle->lle_tbl->llt_ifp;
301 301
302 /* XXX: LOR avoidance. We still have ref on lle. */ 302 /* XXX: LOR avoidance. We still have ref on lle. */
303 LLE_WUNLOCK(lle); 303 LLE_WUNLOCK(lle);
304 304
305 IF_AFDATA_LOCK(ifp); 305 IF_AFDATA_LOCK(ifp);
306 LLE_WLOCK(lle); 306 LLE_WLOCK(lle);
307 307
308 /* Guard against race with other llentry_free(). */ 308 /* Guard against race with other llentry_free(). */
309 if (lle->la_flags & LLE_LINKED) { 309 if (lle->la_flags & LLE_LINKED) {
 310 int rt_cmd;
 311 struct in_addr *in;
 312 struct sockaddr_in sin;
 313 const char *lladdr;
310 size_t pkts_dropped; 314 size_t pkts_dropped;
311 315
 316 in = &lle->r_l3addr.addr4;
 317 sockaddr_in_init(&sin, in, 0);
312 if (lle->la_flags & LLE_VALID) { 318 if (lle->la_flags & LLE_VALID) {
313 struct in_addr *in; 319 rt_cmd = RTM_DELETE;
314 struct sockaddr_in sin; 
315 const char *lladdr; 
316 
317 in = &lle->r_l3addr.addr4; 
318 sockaddr_in_init(&sin, in, 0); 
319 lladdr = (const char *)&lle->ll_addr; 320 lladdr = (const char *)&lle->ll_addr;
320 rt_clonedmsg(RTM_DELETE, sintosa(&sin), lladdr, ifp); 321 } else {
 322 rt_cmd = RTM_MISS;
 323 lladdr = NULL;
321 } 324 }
 325 rt_clonedmsg(rt_cmd, sintosa(&sin), lladdr, ifp);
322 326
323 LLE_REMREF(lle); 327 LLE_REMREF(lle);
324 pkts_dropped = llentry_free(lle); 328 pkts_dropped = llentry_free(lle);
325 ARP_STATADD(ARP_STAT_DFRDROPPED, pkts_dropped); 329 ARP_STATADD(ARP_STAT_DFRDROPPED, pkts_dropped);
326 ARP_STATADD(ARP_STAT_DFRTOTAL, pkts_dropped); 330 ARP_STATADD(ARP_STAT_DFRTOTAL, pkts_dropped);
327 } else { 331 } else {
328 LLE_FREE_LOCKED(lle); 332 LLE_FREE_LOCKED(lle);
329 } 333 }
330 334
331 IF_AFDATA_UNLOCK(ifp); 335 IF_AFDATA_UNLOCK(ifp);
332} 336}
333 337
334static void 338static void