Index: tcp_input.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/tcp_input.c,v retrieving revision 1.128 diff -u -r1.128 tcp_input.c --- tcp_input.c 2001/04/20 11:58:55 1.128 +++ tcp_input.c 2001/05/26 19:20:12 @@ -2758,6 +2758,21 @@ if ((bufsize = rt->rt_rmx.rmx_sendpipe) == 0) #endif bufsize = so->so_snd.sb_hiwat; + /* + * If src or dst port is listed in tcp_override_port, adjust the + * socket buffers to the size's specified by tcp_override_sendspace + * and tcp_override_recvspace.send. + */ + if ((tcp_override_port != 0) && + ((ntohs(inp->inp_lport) == tcp_override_port) || + (ntohs(inp->inp_fport) == tcp_override_port))) { + printf("override: lport %d fport %d ntohs(lport) %d ntohs(fport) %d sendspace %d\n", + inp->inp_lport, inp->inp_fport, ntohs(inp->inp_lport), ntohs(inp->inp_fport), + tcp_override_sendspace); + + bufsize = tcp_override_sendspace; + } + if (bufsize < mss) mss = bufsize; else { @@ -2772,6 +2787,12 @@ if ((bufsize = rt->rt_rmx.rmx_recvpipe) == 0) #endif bufsize = so->so_rcv.sb_hiwat; + + if ((tcp_override_port != 0) && + ((ntohs(inp->inp_lport) == tcp_override_port) || + (ntohs(inp->inp_fport) == tcp_override_port))) + bufsize = tcp_override_recvspace; + if (bufsize > mss) { bufsize = roundup(bufsize, mss); if (bufsize > sb_max) Index: tcp_subr.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/tcp_subr.c,v retrieving revision 1.99 diff -u -r1.99 tcp_subr.c --- tcp_subr.c 2001/04/20 11:58:56 1.99 +++ tcp_subr.c 2001/05/26 13:33:15 @@ -513,7 +513,7 @@ tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT; tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT; tp->t_rcvtime = ticks; - /* + /* * IPv4 TTL initialization is necessary for an IPv6 socket as well, * because the socket may be bound to an IPv6 wildcard address, * which may match an IPv4-mapped IPv6 address. Index: tcp_usrreq.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/tcp_usrreq.c,v retrieving revision 1.59 diff -u -r1.59 tcp_usrreq.c --- tcp_usrreq.c 2001/04/20 11:58:56 1.59 +++ tcp_usrreq.c 2001/05/26 17:24:19 @@ -1012,6 +1012,30 @@ &tcp_recvspace , 0, "Maximum incoming TCP datagram size"); /* + * override_sendspace and override_recvspace will override the default + * send and receive window sizes (as specified above) as well as the + * sendpipe and recvpipe learned from the route table, if the source or + * destination port number is listed in override_port + * + * One use of this is a ftp server, where all the control sessions will + * transfer very little data, and the data sessions will transfer lots + * of data, here one will probably increase sendspace to allow for higher + * transfer rates for the data sessions, but there is no need to allocate + * a increased amount of buffers for the data sessions, so one would list + * port 21 in override_port, and configure override_sendspace and + * override_recvspace for a lower number. + */ +u_long tcp_override_sendspace = 1024*16; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, override_sendspace, CTLFLAG_RW, + &tcp_override_sendspace , 0, ""); +u_long tcp_override_recvspace = 1024*16; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, override_recvspace, CTLFLAG_RW, + &tcp_override_recvspace , 0, ""); +u_short tcp_override_port = 0; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, override_port, CTLFLAG_RW, + &tcp_override_port , 0, ""); + +/* * Attach TCP protocol to socket, allocating * internet protocol control block, tcp control block, * bufer space, and entering LISTEN state if to accept connections. Index: tcp_var.h =================================================================== RCS file: /home/ncvs/src/sys/netinet/tcp_var.h,v retrieving revision 1.68 diff -u -r1.68 tcp_var.h --- tcp_var.h 2001/04/17 18:14:37 1.68 +++ tcp_var.h 2001/05/26 16:34:58 @@ -351,6 +351,9 @@ { "keepintvl", CTLTYPE_INT }, \ { "sendspace", CTLTYPE_INT }, \ { "recvspace", CTLTYPE_INT }, \ + { "override_sendspace", CTLTYPE_INT }, \ + { "override_recvspace", CTLTYPE_INT }, \ + { "override_port", CTLTYPE_INT }, \ { "keepinit", CTLTYPE_INT }, \ { "pcblist", CTLTYPE_STRUCT }, \ { "delacktime", CTLTYPE_INT }, \ @@ -409,6 +412,9 @@ extern struct pr_usrreqs tcp_usrreqs; extern u_long tcp_sendspace; extern u_long tcp_recvspace; +extern u_long tcp_override_sendspace; +extern u_long tcp_override_recvspace; +extern u_short tcp_override_port; void tcp_rndiss_init __P((void)); tcp_seq tcp_rndiss_next __P((void)); u_int16_t