Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/sys/netinet Pullup rev 1.107 (requested by itojun in ti...
details: https://anonhg.NetBSD.org/src/rev/d0f41f725c77
branches: netbsd-1-6
changeset: 531071:d0f41f725c77
user: jmc <jmc%NetBSD.org@localhost>
date: Sat Feb 07 20:06:58 2004 +0000
description:
Pullup rev 1.107 (requested by itojun in ticket #1605)
Deal with IPv6 path MTU < 1280 (RFC2460 section 5 last paragraph)
Check if there really is room for TCP data.
diffstat:
sys/netinet/tcp_output.c | 33 +++++++++++++++++++++++++++------
1 files changed, 27 insertions(+), 6 deletions(-)
diffs (83 lines):
diff -r 0ec7342fa27d -r d0f41f725c77 sys/netinet/tcp_output.c
--- a/sys/netinet/tcp_output.c Sat Feb 07 20:06:04 2004 +0000
+++ b/sys/netinet/tcp_output.c Sat Feb 07 20:06:58 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_output.c,v 1.79.4.4 2003/09/05 13:42:39 tron Exp $ */
+/* $NetBSD: tcp_output.c,v 1.79.4.5 2004/02/07 20:06:58 jmc Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -142,7 +142,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.79.4.4 2003/09/05 13:42:39 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.79.4.5 2004/02/07 20:06:58 jmc Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -219,7 +219,7 @@
#ifndef GPROF
__inline
#endif
-void
+int
tcp_segsize(struct tcpcb *tp, int *txsegsizep, int *rxsegsizep)
{
#ifdef INET
@@ -276,9 +276,23 @@
ifp = rt->rt_ifp;
size = tcp_mssdflt;
- if (tp->t_mtudisc && rt->rt_rmx.rmx_mtu != 0)
+ if (tp->t_mtudisc && rt->rt_rmx.rmx_mtu != 0) {
+#ifdef INET6
+ if (in6p && rt->rt_rmx.rmx_mtu < IPV6_MMTU) {
+ /*
+ * RFC2460 section 5, last paragraph: if path MTU is
+ * smaller than 1280, use 1280 as packet size and
+ * attach fragment header.
+ */
+ size = IPV6_MMTU - iphlen - sizeof(struct ip6_frag) -
+ sizeof(struct tcphdr);
+ } else
+ size = rt->rt_rmx.rmx_mtu - iphlen -
+ sizeof(struct tcphdr);
+#else
size = rt->rt_rmx.rmx_mtu - iphlen - sizeof(struct tcphdr);
- else if (ifp->if_flags & IFF_LOOPBACK)
+#endif
+ } else if (ifp->if_flags & IFF_LOOPBACK)
size = ifp->if_mtu - iphlen - sizeof(struct tcphdr);
#ifdef INET
else if (inp && tp->t_mtudisc)
@@ -344,6 +358,10 @@
#endif
size -= optlen;
+ /* there may not be any room for data if mtu is too small */
+ if (size < 0)
+ return (EMSGSIZE);
+
/*
* *rxsegsizep holds *estimated* inbound segment size (estimation
* assumes that path MTU is the same for both ways). this is only
@@ -381,6 +399,8 @@
}
tp->t_segsz = *txsegsizep;
}
+
+ return (0);
}
static
@@ -520,7 +540,8 @@
return EAFNOSUPPORT;
}
- tcp_segsize(tp, &txsegsize, &rxsegsize);
+ if (tcp_segsize(tp, &txsegsize, &rxsegsize))
+ return EMSGSIZE;
idle = (tp->snd_max == tp->snd_una);
Home |
Main Index |
Thread Index |
Old Index