Fri Nov 6 08:38:43 2015 UTC ()
Fix inappropriate rt_flags check

It depended on either RTF_CLONED or RTF_CLONING must be set, however,
the assumption didn't meet for userland problems that create a route
via RTM_ADD.

This fixes an issue that running rarpd causes the following kernel panic
reported by nonaka@:
  panic: kernel diagnostic assertion "(la->la_flags & LLE_STATIC) == 0"
  failed: file "/usr/src/sys/netinet/if_arp.c", line 1339


(ozaki-r)
diff -r1.191 -r1.192 src/sys/netinet/if_arp.c

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

--- src/sys/netinet/if_arp.c 2015/10/20 07:46:59 1.191
+++ src/sys/netinet/if_arp.c 2015/11/06 08:38:43 1.192
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_arp.c,v 1.191 2015/10/20 07:46:59 ozaki-r Exp $ */ 1/* $NetBSD: if_arp.c,v 1.192 2015/11/06 08:38:43 ozaki-r 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.191 2015/10/20 07:46:59 ozaki-r Exp $"); 71__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.192 2015/11/06 08:38:43 ozaki-r 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#endif 76#endif
77 77
78#ifdef INET 78#ifdef INET
79 79
80#include "bridge.h" 80#include "bridge.h"
81 81
82#include <sys/param.h> 82#include <sys/param.h>
83#include <sys/systm.h> 83#include <sys/systm.h>
84#include <sys/callout.h> 84#include <sys/callout.h>
@@ -611,27 +611,27 @@ arp_rtrequest(int req, struct rtentry *r @@ -611,27 +611,27 @@ arp_rtrequest(int req, struct rtentry *r
611 * address we are using, otherwise we will have trouble 611 * address we are using, otherwise we will have trouble
612 * with source address selection. 612 * with source address selection.
613 */ 613 */
614 ifa = &ia->ia_ifa; 614 ifa = &ia->ia_ifa;
615 if (ifa != rt->rt_ifa) 615 if (ifa != rt->rt_ifa)
616 rt_replace_ifa(rt, ifa); 616 rt_replace_ifa(rt, ifa);
617 } 617 }
618 618
619 /* 619 /*
620 * Case 2: This route may come from cloning, or a manual route 620 * Case 2: This route may come from cloning, or a manual route
621 * add with a LL address. 621 * add with a LL address.
622 */ 622 */
623 flags = LLE_EXCLUSIVE; 623 flags = LLE_EXCLUSIVE;
624 if ((rt->rt_flags & RTF_CLONED) == 0) 624 if ((rt->rt_flags & RTF_CLONING) != 0)
625 flags |= LLE_IFADDR; 625 flags |= LLE_IFADDR;
626 626
627 IF_AFDATA_WLOCK(ifp); 627 IF_AFDATA_WLOCK(ifp);
628 la = lla_create(LLTABLE(ifp), flags, rt_getkey(rt)); 628 la = lla_create(LLTABLE(ifp), flags, rt_getkey(rt));
629 IF_AFDATA_WUNLOCK(ifp); 629 IF_AFDATA_WUNLOCK(ifp);
630 630
631 if (la == NULL) { 631 if (la == NULL) {
632 log(LOG_DEBUG, "%s: lla_create failed\n", 632 log(LOG_DEBUG, "%s: lla_create failed\n",
633 __func__); 633 __func__);
634 rt->rt_llinfo = NULL; 634 rt->rt_llinfo = NULL;
635 break; 635 break;
636 } 636 }
637 rt->rt_llinfo = la; 637 rt->rt_llinfo = la;