summaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2000-10-10 15:16:03 +0000
committerNiels Provos <provos@cvs.openbsd.org>2000-10-10 15:16:03 +0000
commit1d636161f37140388ade4d9ea5330dfb5b4b67ff (patch)
tree9c47202050f53eaaad4151623e41a4e9fcd1dc61 /sys/netinet/tcp_subr.c
parentef16d0a0f532446d30ea972a1c4d35e4c1caab5c (diff)
verify payload of the icmp need fragment message at the tcp layer. okay itojun@
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 836bda2197e..308e7f28a7a 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_subr.c,v 1.33 2000/09/25 09:41:03 provos Exp $ */
+/* $OpenBSD: tcp_subr.c,v 1.34 2000/10/10 15:16:02 provos Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@@ -87,6 +87,10 @@ didn't get a copy, you may request one from <license@ipv6.nrl.navy.mil>.
#include <sys/md5k.h>
#endif /* TCP_SIGNATURE */
+#ifndef offsetof
+#define offsetof(type, member) ((size_t)(&((type *)0)->member))
+#endif
+
/* patchable/settable parameters for tcp */
int tcp_mssdflt = TCP_MSS;
int tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
@@ -809,9 +813,25 @@ tcp_ctlinput(cmd, sa, v)
notify = tcp_quench;
else if (PRC_IS_REDIRECT(cmd))
notify = in_rtchange, ip = 0;
- else if (cmd == PRC_MSGSIZE && ip_mtudisc)
+ else if (cmd == PRC_MSGSIZE && ip_mtudisc) {
+ th = (struct tcphdr *)((caddr_t)ip + (ip->ip_hl << 2));
+ /*
+ * Verify that the packet in the icmp payload refers
+ * to an existing TCP connection.
+ */
+ if (in_pcblookup(&tcbtable,
+ &ip->ip_dst, th->th_dport,
+ &ip->ip_src, th->th_sport,
+ INPLOOKUP_WILDCARD)) {
+ struct icmp *icp;
+ icp = (struct icmp *)((caddr_t)ip -
+ offsetof(struct icmp, icmp_ip));
+
+ /* Calculate new mtu and create corresponding route */
+ icmp_mtudisc(icp);
+ }
notify = tcp_mtudisc, ip = 0;
- else if (cmd == PRC_MTUINC)
+ } else if (cmd == PRC_MTUINC)
notify = tcp_mtudisc_increase, ip = 0;
else if (cmd == PRC_HOSTDEAD)
ip = 0;