From owner-p4-projects@FreeBSD.ORG Fri Sep 7 16:31:55 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2D91416A46B; Fri, 7 Sep 2007 16:31:55 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D07E716A468 for ; Fri, 7 Sep 2007 16:31:54 +0000 (UTC) (envelope-from mharvan@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C962F13C4B7 for ; Fri, 7 Sep 2007 16:31:54 +0000 (UTC) (envelope-from mharvan@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l87GVsfo038091 for ; Fri, 7 Sep 2007 16:31:54 GMT (envelope-from mharvan@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l87GVstB038083 for perforce@freebsd.org; Fri, 7 Sep 2007 16:31:54 GMT (envelope-from mharvan@FreeBSD.org) Date: Fri, 7 Sep 2007 16:31:54 GMT Message-Id: <200709071631.l87GVstB038083@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to mharvan@FreeBSD.org using -f From: Matus Harvan To: Perforce Change Reviews Cc: Subject: PERFORCE change 126156 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2007 16:31:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=126156 Change 126156 by mharvan@mharvan_peleus on 2007/09/07 16:31:10 udp catchall patch cleanup * TLFLAG_SECURE * debugging printf * move statically declared catchallr outside of udp_input() Affected files ... .. //depot/projects/soc2007/mharvan-mtund/sys.patches/sys.current.udp_catchall.patch#2 edit Differences ... ==== //depot/projects/soc2007/mharvan-mtund/sys.patches/sys.current.udp_catchall.patch#2 (text+ko) ==== @@ -2,49 +2,52 @@ =================================================================== RCS file: /home/ncvs/src/sys/netinet/udp_usrreq.c,v retrieving revision 1.216 -diff -u -r1.216 udp_usrreq.c +diff -d -u -r1.216 udp_usrreq.c --- udp_usrreq.c 10 Jul 2007 09:30:46 -0000 1.216 -+++ udp_usrreq.c 24 Aug 2007 17:29:33 -0000 ++++ udp_usrreq.c 6 Sep 2007 21:59:31 -0000 @@ -125,6 +125,15 @@ SYSCTL_ULONG(_net_inet_udp, UDPCTL_RECVSPACE, recvspace, CTLFLAG_RW, &udp_recvspace, 0, "Maximum space for incoming UDP datagrams"); +static int udp_catchall = 0; -+SYSCTL_INT(_net_inet_raw, OID_AUTO, udp_catchall, CTLFLAG_RW, ++SYSCTL_INT(_net_inet_raw, OID_AUTO, udp_catchall, CTLFLAG_RW | CTLFLAG_SECURE, + &udp_catchall, 0, "Raw IP UDP sockets receive unclaimed UDP datagrams"); + +static int catchalllim = 5; -+SYSCTL_INT(_net_inet_udp, OID_AUTO, catchalllim, CTLFLAG_RW, ++SYSCTL_INT(_net_inet_udp, OID_AUTO, catchalllim, CTLFLAG_RW | CTLFLAG_SECURE, + &catchalllim, 0, + "Rate limit on received UDP datagrams due to udp_catchall"); + struct inpcbhead udb; /* from udp_var.h */ struct inpcbinfo udbinfo; -@@ -261,6 +270,10 @@ - #ifdef IPFIREWALL_FORWARD - struct m_tag *fwd_tag; - #endif -+ static struct rate { -+ struct timeval lasttime; -+ int curpps; -+ } catchallr; +@@ -136,6 +145,11 @@ + SYSCTL_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW, &udpstat, + udpstat, "UDP statistics (struct udpstat, netinet/udp_var.h)"); - ifp = m->m_pkthdr.rcvif; - udpstat.udps_ipackets++; -@@ -515,6 +528,30 @@ ++static struct rate { ++ struct timeval lasttime; ++ int curpps; ++} catchallr; ++ + static void udp_detach(struct socket *so); + static int udp_output(struct inpcb *, struct mbuf *, struct sockaddr *, + struct mbuf *, struct thread *); +@@ -515,6 +529,35 @@ */ inp = in_pcblookup_hash(&udbinfo, ip->ip_src, uh->uh_sport, ip->ip_dst, uh->uh_dport, 1, ifp); + + /* catchall socket */ + if (inp == NULL && udp_catchall != 0) { ++#ifdef DIAGNOSTIC + printf("IP UDP catchall active\n"); -+ char dbuf[4*sizeof "123"], sbuf[4*sizeof "123"]; ++ char dbuf[INET_ADDRSTRLEN], sbuf[INET_ADDRSTRLEN]; + strcpy(dbuf, inet_ntoa(ip->ip_dst)); + strcpy(sbuf, inet_ntoa(ip->ip_src)); + printf("\tip_src: %s, sport: %hu\n\tip_dst: %s, dport: %hu\n", + sbuf, ntohs(uh->uh_sport), dbuf, ntohs(uh->uh_dport)); ++#endif + + /* rate limiting */ + if (catchalllim > 0) @@ -53,11 +56,14 @@ + rip_input(m, off); + INP_INFO_RUNLOCK(&udbinfo); + return; -+ } else -+ printf("ppsratecheck limited " ++ } ++#ifdef DIAGNOSTIC ++ else ++ printf("ppsratecheck limited " + "udp_catchall\n"); + else + printf("ppsratecheck limited udp_catchall\n"); ++#endif + } + if (inp == NULL) {