aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c76
1 files changed, 64 insertions, 12 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 8558464fb70a..eea64bb08ab1 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)tcp_subr.c 7.20 (Berkeley) 12/1/90
- * $Id: tcp_subr.c,v 1.2 1993/10/16 18:26:31 rgrimes Exp $
+ * $Id: tcp_subr.c,v 1.6 1993/12/19 00:52:50 wollman Exp $
*/
#include "param.h"
@@ -50,6 +50,7 @@
#include "in_systm.h"
#include "ip.h"
#include "in_pcb.h"
+#include "in_var.h"
#include "ip_var.h"
#include "ip_icmp.h"
#include "tcp.h"
@@ -59,16 +60,18 @@
#include "tcp_var.h"
#include "tcpip.h"
-/* patchable/settable parameters for tcp */
-int tcp_ttl = TCP_TTL;
-int tcp_mssdflt = TCP_MSS;
-int tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
+tcp_seq tcp_iss;
+struct inpcb tcb;
+struct tcpstat tcpstat;
-extern struct inpcb *tcp_last_inpcb;
+#ifdef MTUDISC
+int tcp_mtuchanged(struct inpcb *, int);
+#endif
/*
* Tcp initialization
*/
+void
tcp_init()
{
@@ -133,6 +136,7 @@ tcp_template(tp)
* In any case the ack and sequence number of the transmitted
* segment are as specified by the parameters.
*/
+void
tcp_respond(tp, ti, m, ack, seq, flags)
struct tcpcb *tp;
register struct tcpiphdr *ti;
@@ -227,6 +231,13 @@ tcp_newtcpcb(inp)
tp->snd_ssthresh = TCP_MAXWIN;
inp->inp_ip.ip_ttl = tcp_ttl;
inp->inp_ppcb = (caddr_t)tp;
+#ifdef MTUDISC
+ /*
+ * Enable Path MTU Discovery on this PCB.
+ */
+ inp->inp_mtunotify = tcp_mtuchanged;
+ inp->inp_flags |= INP_DISCOVERMTU;
+#endif /* MTUDISC */
return (tp);
}
@@ -286,7 +297,7 @@ tcp_close(tp)
if (SEQ_LT(tp->iss + so->so_snd.sb_hiwat * 16, tp->snd_max) &&
(rt = inp->inp_route.ro_rt) &&
((struct sockaddr_in *)rt_key(rt))->sin_addr.s_addr != INADDR_ANY) {
- register u_long i;
+ register u_long i = 0;
if ((rt->rt_rmx.rmx_locks & RTV_RTT) == 0) {
i = tp->t_srtt *
@@ -337,7 +348,7 @@ tcp_close(tp)
rt->rt_rmx.rmx_ssthresh = i;
}
}
-#endif RTV_RTT
+#endif /* RTV_RTT */
/* free the reassembly queue, if any */
t = tp->seg_next;
while (t != (struct tcpiphdr *)tp) {
@@ -359,6 +370,7 @@ tcp_close(tp)
return ((struct tcpcb *)0);
}
+void
tcp_drain()
{
@@ -369,6 +381,7 @@ tcp_drain()
* store error as soft error, but wake up user
* (for now, won't do anything until can select for soft error).
*/
+void
tcp_notify(inp, error)
register struct inpcb *inp;
int error;
@@ -380,18 +393,55 @@ tcp_notify(inp, error)
sowwakeup(inp->inp_socket);
}
+/*
+ * When we get a PRC_MSGSIZE error (generated by the ICMP layer upon
+ * receipt of an ICMP_UNREACH_NEEDFRAG message), we need to get the
+ * IP layer to check the cached MTU data that it has in its PCBs.
+ * If things have changed, this will cause us to receive a
+ * PRC_MTUCHANGED message for /every/ connection to the same
+ * destination; that is handled by he tcp_mtuchanged() function,
+ * below.
+ *
+ * In the immortal words of Ken and Dennis, ``You are not expected to
+ * understand this.''
+ */
+void
+tcp_checkmtu(struct inpcb *inp, int error) {
+#ifdef MTUDISC
+ /*
+ * XXX - this should also cause an immediate retransmission and
+ * slow start, since we know for a fact that the message we just sent
+ * got dropped on the floor. For now, just do what tcp_quench does.
+ */
+ tcp_quench(inp);
+ in_pcbmtu(inp);
+#endif /* MTUDISC */
+}
+
+#ifdef MTUDISC
+int /* grrr... should be void... */
+tcp_mtuchanged(struct inpcb *inp, int error) {
+ /* don't do anything just yet... */;
+}
+#endif /* MTUDISC */
+
+void
tcp_ctlinput(cmd, sa, ip)
int cmd;
struct sockaddr *sa;
register struct ip *ip;
{
register struct tcphdr *th;
- extern struct in_addr zeroin_addr;
- extern u_char inetctlerrmap[];
- int (*notify)() = tcp_notify, tcp_quench();
+ void (*notify)(struct inpcb *, int) = tcp_notify;
if (cmd == PRC_QUENCH)
notify = tcp_quench;
+#ifdef MTUDISC
+ else if (cmd == PRC_MSGSIZE)
+ notify = tcp_checkmtu;
+ else if (cmd == PRC_MTUCHANGED) /* just in case */
+ notify = tcp_mtuchanged;
+#endif /* MTUDISC */
else if ((unsigned)cmd > PRC_NCMDS || inetctlerrmap[cmd] == 0)
return;
if (ip) {
@@ -406,8 +456,10 @@ tcp_ctlinput(cmd, sa, ip)
* When a source quench is received, close congestion window
* to one segment. We will gradually open it again as we proceed.
*/
-tcp_quench(inp)
+void
+tcp_quench(inp, errno)
struct inpcb *inp;
+ int errno;
{
struct tcpcb *tp = intotcpcb(inp);