Module Name:    src
Committed By:   riz
Date:           Fri Nov  6 00:46:50 UTC 2015

Modified Files:
        src/sys/netinet [netbsd-7]: if_arp.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #985):
        sys/netinet/if_arp.c: revision 1.160
Add sysctl to selectively log arp packets from unknown network. (Adrien URBAN).


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.158.2.1 src/sys/netinet/if_arp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.158 src/sys/netinet/if_arp.c:1.158.2.1
--- src/sys/netinet/if_arp.c:1.158	Tue Jun  3 01:24:32 2014
+++ src/sys/netinet/if_arp.c	Fri Nov  6 00:46:50 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.158 2014/06/03 01:24:32 ozaki-r Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.158.2.1 2015/11/06 00:46:50 riz Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.158 2014/06/03 01:24:32 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.158.2.1 2015/11/06 00:46:50 riz Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -194,6 +194,7 @@ static int arp_drainwanted;
 static int log_movements = 1;
 static int log_permanent_modify = 1;
 static int log_wrong_iface = 1;
+static int log_unknown_network = 1;
 
 /*
  * this should be elsewhere.
@@ -1305,17 +1306,20 @@ arplookup1(struct mbuf *m, const struct 
 		return (struct llinfo_arp *)rt->rt_llinfo;
 
 	if (create) {
-		if (rt->rt_flags & RTF_GATEWAY)
-			why = "host is not on local network";
-		else if ((rt->rt_flags & RTF_LLINFO) == 0) {
+		if (rt->rt_flags & RTF_GATEWAY) {
+			if (log_unknown_network)
+				why = "host is not on local network";
+		} else if ((rt->rt_flags & RTF_LLINFO) == 0) {
 			ARP_STATINC(ARP_STAT_ALLOCFAIL);
 			why = "could not allocate llinfo";
 		} else
 			why = "gateway route is not ours";
-		log(LOG_DEBUG, "arplookup: unable to enter address"
-		    " for %s@%s on %s (%s)\n",
-		    in_fmtaddr(*addr), lla_snprintf(ar_sha(ah), ah->ar_hln),
-		    (ifp) ? ifp->if_xname : "null", why);
+		if (why) {
+			log(LOG_DEBUG, "arplookup: unable to enter address"
+			    " for %s@%s on %s (%s)\n", in_fmtaddr(*addr),
+			    lla_snprintf(ar_sha(ah), ah->ar_hln),
+			    (ifp) ? ifp->if_xname : "null", why);
+		}
 		if (rt->rt_refcnt <= 0 && (rt->rt_flags & RTF_CLONED) != 0) {
 			rtrequest(RTM_DELETE, rt_getkey(rt),
 		    	    rt->rt_gateway, rt_mask(rt), rt->rt_flags, NULL);
@@ -1704,6 +1708,13 @@ sysctl_net_inet_arp_setup(struct sysctll
 			    " interface"),
 			NULL, 0, &log_wrong_iface, 0,
 			CTL_NET,PF_INET, node->sysctl_num, CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(clog, 0, NULL, NULL,
+			CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+			CTLTYPE_INT, "log_unknown_network",
+			SYSCTL_DESCR("log ARP packets from non-local network"),
+			NULL, 0, &log_unknown_network, 0,
+			CTL_NET,PF_INET, node->sysctl_num, CTL_CREATE, CTL_EOL);
 }
 
 #endif /* INET */

Reply via email to