PERFORCE change 126156 for review
Matus Harvan
mharvan at FreeBSD.org
Fri Sep 7 09:31:56 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=126156
Change 126156 by mharvan at 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) {
More information about the p4-projects
mailing list