Module Name: src Committed By: bouyer Date: Sun Nov 15 17:51:52 UTC 2015
Modified Files: src/sys/netinet [netbsd-6]: if_arp.c Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #1328): 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.154.2.1 -r1.154.2.2 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.154.2.1 src/sys/netinet/if_arp.c:1.154.2.2 --- src/sys/netinet/if_arp.c:1.154.2.1 Tue Jun 3 15:34:00 2014 +++ src/sys/netinet/if_arp.c Sun Nov 15 17:51:52 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.154.2.1 2014/06/03 15:34:00 msaitoh Exp $ */ +/* $NetBSD: if_arp.c,v 1.154.2.2 2015/11/15 17:51:52 bouyer 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.154.2.1 2014/06/03 15:34:00 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.154.2.2 2015/11/15 17:51:52 bouyer 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. @@ -1306,17 +1307,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); @@ -1708,6 +1712,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 */