summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_usrreq.c
diff options
context:
space:
mode:
authorcmetz <cmetz@openbsd.org>1999-07-02 20:39:07 +0000
committercmetz <cmetz@openbsd.org>1999-07-02 20:39:07 +0000
commita237783bf990a3ac2cc58476b3870547b43fe612 (patch)
tree0acf8b74d0292849eda10f49c5ef75b13d813006 /sys/netinet/tcp_usrreq.c
parentconsistent .Dd usage; proper format is: .Dd Month DD, YYYY (diff)
downloadwireguard-openbsd-a237783bf990a3ac2cc58476b3870547b43fe612.tar.xz
wireguard-openbsd-a237783bf990a3ac2cc58476b3870547b43fe612.zip
Significant cleanups in the way TCP is made to handle multiple network
protocols. "struct tcpiphdr" is now gone from much of the code, as are separate pointers for ti and ti6. The result is fewer variables, which is generally a good thing. Simple if(is_ipv6) ... else ... tests are gone in favor of a switch(protocol family), which allows future new protocols to be added easily. This also makes it possible for someone so inclined to re-implement TUBA (TCP over CLNP?) and do it right instead of the kluged way it was done in 4.4. The TCP header template is now referenced through a mbuf rather than done through a data pointer and dtom()ed as needed. This is partly because dtom() is evil and partly because max_linkhdr + IPv6 + TCP + MSS/TS/SACK opts won't fit inside a packet header mbuf, so we need to grab a cluster for that (which the code now does, if needed).
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r--sys/netinet/tcp_usrreq.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 38e82edc26c..de6ee75474f 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.33 1999/03/24 02:28:21 cmetz Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.34 1999/07/02 20:39:08 cmetz Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -466,7 +466,7 @@ tcp_usrreq(so, req, m, nam, control)
panic("tcp_usrreq");
}
if (tp && (so->so_options & SO_DEBUG))
- tcp_trace(TA_USER, ostate, tp, (struct tcpiphdr *)0, req, 0);
+ tcp_trace(TA_USER, ostate, tp, (caddr_t)0, req, 0);
splx(s);
return (error);
}
@@ -531,7 +531,13 @@ tcp_ctloutput(op, so, level, optname, mp)
break;
case TCP_MAXSEG:
- if (m && (i = *mtod(m, int *)) > 0 && i <= tp->t_maxseg)
+ if (m == NULL || m->m_len < sizeof (int)) {
+ error = EINVAL;
+ break;
+ }
+
+ i = *mtod(m, int *);
+ if (i > 0 && i <= tp->t_maxseg)
tp->t_maxseg = i;
else
error = EINVAL;
@@ -539,8 +545,20 @@ tcp_ctloutput(op, so, level, optname, mp)
#ifdef TCP_SACK
case TCP_SACK_DISABLE:
- i = *mtod(m, int *);
- tp->sack_disable = i;
+ if (m == NULL || m->m_len < sizeof (int)) {
+ error = EINVAL;
+ break;
+ }
+
+ if (TCPS_HAVEESTABLISHED(tp->t_state)) {
+ error = EPERM;
+ break;
+ }
+
+ if (*mtod(m, int *))
+ tp->sack_disable = 1;
+ else
+ tp->sack_disable = 0;
break;
#endif
default: