PERFORCE change 124981 for review
Matus Harvan
mharvan at FreeBSD.org
Thu Aug 9 15:47:04 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=124981
Change 124981 by mharvan at mharvan_bike-planet on 2007/08/09 22:46:07
working TCP_CATCHALL
Affected files ...
.. //depot/projects/soc2007/mharvan-mtund/sys.patches/tcp_catchall/sys.patch#2 edit
Differences ...
==== //depot/projects/soc2007/mharvan-mtund/sys.patches/tcp_catchall/sys.patch#2 (text+ko) ====
@@ -4,7 +4,7 @@
retrieving revision 1.31.2.2
diff -u -r1.31.2.2 tcp.h
--- tcp.h 5 Mar 2007 10:21:52 -0000 1.31.2.2
-+++ tcp.h 9 Aug 2007 17:12:31 -0000
++++ tcp.h 9 Aug 2007 22:41:16 -0000
@@ -160,6 +160,7 @@
#define TCP_NOOPT 0x08 /* don't use TCP options */
#define TCP_MD5SIG 0x10 /* use MD5 digests (RFC2385) */
@@ -19,35 +19,31 @@
retrieving revision 1.281.2.13
diff -u -r1.281.2.13 tcp_input.c
--- tcp_input.c 12 Jun 2007 18:53:32 -0000 1.281.2.13
-+++ tcp_input.c 9 Aug 2007 17:12:33 -0000
++++ tcp_input.c 9 Aug 2007 22:41:18 -0000
@@ -163,6 +163,7 @@
#define tcb6 tcb /* for KAME src sync over BSD*'s */
struct inpcbinfo tcbinfo;
struct mtx *tcbinfo_mtx;
-+struct inpcb *inp_catchall = NULL;
++struct inpcb *inp_catchall; /* binding to all unused TCP ports */
static void tcp_dooptions(struct tcpopt *, u_char *, int, int);
-@@ -690,6 +691,23 @@
+@@ -690,6 +691,19 @@
goto drop;
}
#endif /*IPSEC || FAST_IPSEC*/
+
+ /* catchall socket */
-+ if ((inp == NULL) && (inp_catchall != NULL) &&
-+ /* only the SYN flag shall be set */
-+ (thflags & TH_SYN) //&& (thflags ^ TH_SYN) == 0
-+ ) {
-+ printf("catchall socket used (0x%x)\n",
-+ (unsigned int)inp_catchall);
-+ char dbuf[4*sizeof "123"], sbuf[4*sizeof "123"];
-+ 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(th->th_sport),
-+ dbuf, ntohs(th->th_dport));
++ if ((inp == NULL) && (inp_catchall != NULL)) {
++ printf("catchall socket used (0x%x)\n",
++ (unsigned int)inp_catchall);
++ char dbuf[4*sizeof "123"], sbuf[4*sizeof "123"];
++ 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(th->th_sport), dbuf, ntohs(th->th_dport));
+
-+ inp = inp_catchall;
++ inp = inp_catchall;
+ }
/*
@@ -58,7 +54,7 @@
retrieving revision 1.228.2.14
diff -u -r1.228.2.14 tcp_subr.c
--- tcp_subr.c 30 Dec 2006 17:58:46 -0000 1.228.2.14
-+++ tcp_subr.c 9 Aug 2007 17:12:35 -0000
++++ tcp_subr.c 9 Aug 2007 22:41:19 -0000
@@ -324,6 +324,9 @@
tcp_rexmit_slop = TCPTV_CPU_VAR;
tcp_inflight_rttthresh = TCPTV_INFLIGHT_RTTTHRESH;
@@ -75,15 +71,15 @@
retrieving revision 1.124.2.6
diff -u -r1.124.2.6 tcp_usrreq.c
--- tcp_usrreq.c 8 Jan 2007 18:10:12 -0000 1.124.2.6
-+++ tcp_usrreq.c 9 Aug 2007 17:12:36 -0000
++++ tcp_usrreq.c 9 Aug 2007 22:41:21 -0000
@@ -162,6 +162,12 @@
INP_INFO_WUNLOCK(&tcbinfo);
return error;
}
+
+ if (inp == inp_catchall) {
-+ printf("deactivating TCP_CATCHALL - socket closed\n");
-+ inp_catchall = NULL;
++ printf("deactivating TCP_CATCHALL - socket closed\n");
++ inp_catchall = NULL;
+ }
+
INP_LOCK(inp);
@@ -94,46 +90,49 @@
break;
+ case TCP_CATCHALL:
-+ printf("TCP_CATCHALL option code\n");
++ printf("TCP_CATCHALL option code\n");
+ error = sooptcopyin(sopt, &optval, sizeof optval,
+ sizeof optval);
+ if (error)
+ break;
+
-+ printf("TCP_CATCHALL optval: %d\n", optval);
++ printf("TCP_CATCHALL optval: %d\n", optval);
+ if (optval > 0) { /* enable CATCHALL */
-+ printf("request to enable TCP_CATCHALL\n");
-+ if (inp_catchall == NULL) {
-+ printf("enabled TCP_CATCHALL\n");
-+ inp_catchall = inp;
-+ } else {
-+ printf("TCP_CATCHALL already enabled, "
-+ "ignoring setsockopt()\n");
-+ error = EINVAL;
-+ }
++ printf("request to enable TCP_CATCHALL\n");
++ if (inp_catchall == NULL) {
++ printf("enabled TCP_CATCHALL\n");
++ inp_catchall = inp;
++ } else {
++ printf("TCP_CATCHALL already enabled, "
++ "ignoring setsockopt()\n");
++ error = EINVAL;
++ }
+ } else {/* disable CATCHALL */
-+ printf("request to disable TCP_CATCHALL\n");
-+ if (inp_catchall == inp) {
-+ printf("disabled TCP_CATCHALL\n");
-+ inp_catchall = NULL;
-+ } else {
-+ printf("TCP_CATCHALL already disabled, "
-+ "ignoring setsockopt()\n");
-+ error = EINVAL;
-+ }
++ printf("request to disable TCP_CATCHALL\n");
++ if (inp_catchall == inp) {
++ printf("disabled TCP_CATCHALL\n");
++ inp_catchall = NULL;
++ } else {
++ printf("TCP_CATCHALL already disabled"
++ ", ignoring setsockopt()\n");
++ error = EINVAL;
++ }
+ }
+ break;
+
default:
error = ENOPROTOOPT;
break;
-@@ -1145,6 +1182,10 @@
+@@ -1145,6 +1182,13 @@
case TCP_INFO:
tcp_fill_info(tp, &ti);
error = sooptcopyout(sopt, &ti, sizeof ti);
+ break;
+ case TCP_CATCHALL:
-+ optval = 1;
++ if (inp == inp_catchall)
++ optval = 1;
++ else
++ optval = 0;
+ error = sooptcopyout(sopt, &optval, sizeof optval);
break;
default:
@@ -144,12 +143,12 @@
retrieving revision 1.126.2.3
diff -u -r1.126.2.3 tcp_var.h
--- tcp_var.h 19 Sep 2006 12:58:40 -0000 1.126.2.3
-+++ tcp_var.h 9 Aug 2007 17:12:37 -0000
++++ tcp_var.h 9 Aug 2007 22:41:22 -0000
@@ -504,6 +504,7 @@
extern struct inpcbhead tcb; /* head of queue of active tcpcb's */
extern struct inpcbinfo tcbinfo;
-+extern struct inpcb *inp_catchall;
++extern struct inpcb *inp_catchall; /* binding to all unused TCP ports */
extern struct tcpstat tcpstat; /* tcp statistics */
extern int tcp_mssdflt; /* XXX */
extern int tcp_minmss;
More information about the p4-projects
mailing list