All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] [NET] Do pmtu check in transport layer
@ 2007-03-24  0:06 John Heffner
  2007-03-24  0:06 ` [PATCH 2/3] [NET] Move DF check to ip_forward John Heffner
                   ` (4 more replies)
  0 siblings, 5 replies; 26+ messages in thread
From: John Heffner @ 2007-03-24  0:06 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, John Heffner

Check the pmtu check at the transport layer (for UDP, ICMP and raw), and
send a local error if socket is PMTUDISC_DO and packet is too big.  This is
actually a pure bugfix for ipv6.  For ipv4, it allows us to do pmtu checks
in the same way as for ipv6.

Signed-off-by: John Heffner <jheffner@psc.edu>
---
 net/ipv4/ip_output.c  |    4 +++-
 net/ipv4/raw.c        |    8 +++++---
 net/ipv6/ip6_output.c |   11 ++++++-----
 net/ipv6/raw.c        |    7 +++++--
 4 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index d096332..593acf7 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -822,7 +822,9 @@ int ip_append_data(struct sock *sk,
 	fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0);
 	maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen;
 
-	if (inet->cork.length + length > 0xFFFF - fragheaderlen) {
+	if (inet->cork.length + length > 0xFFFF - fragheaderlen ||
+	    (inet->pmtudisc >= IP_PMTUDISC_DO &&
+	     inet->cork.length + length > mtu)) {
 		ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport, mtu-exthdrlen);
 		return -EMSGSIZE;
 	}
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 87e9c16..f252f4e 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -271,10 +271,12 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
 	struct iphdr *iph;
 	struct sk_buff *skb;
 	int err;
+	int mtu;
 
-	if (length > rt->u.dst.dev->mtu) {
-		ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport,
-			       rt->u.dst.dev->mtu);
+	mtu = inet->pmtudisc == IP_PMTUDISC_DO ? dst_mtu(&rt->u.dst) :
+	                                         rt->u.dst.dev->mtu;
+	if (length > mtu) {
+		ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport, mtu);
 		return -EMSGSIZE;
 	}
 	if (flags&MSG_PROBE)
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 3055169..711dfc3 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1044,11 +1044,12 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
 	fragheaderlen = sizeof(struct ipv6hdr) + rt->u.dst.nfheader_len + (opt ? opt->opt_nflen : 0);
 	maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - sizeof(struct frag_hdr);
 
-	if (mtu <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) {
-		if (inet->cork.length + length > sizeof(struct ipv6hdr) + IPV6_MAXPLEN - fragheaderlen) {
-			ipv6_local_error(sk, EMSGSIZE, fl, mtu-exthdrlen);
-			return -EMSGSIZE;
-		}
+	if ((mtu <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN &&
+	     inet->cork.length + length > sizeof(struct ipv6hdr) + IPV6_MAXPLEN - fragheaderlen) ||
+	    (np->pmtudisc >= IPV6_PMTUDISC_DO &&
+	     inet->cork.length + length > mtu)) {
+		ipv6_local_error(sk, EMSGSIZE, fl, mtu-exthdrlen);
+		return -EMSGSIZE;
 	}
 
 	/*
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 306d5d8..75db277 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -556,9 +556,12 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
 	struct sk_buff *skb;
 	unsigned int hh_len;
 	int err;
+	int mtu;
 
-	if (length > rt->u.dst.dev->mtu) {
-		ipv6_local_error(sk, EMSGSIZE, fl, rt->u.dst.dev->mtu);
+	mtu = np->pmtudisc == IPV6_PMTUDISC_DO ? dst_mtu(&rt->u.dst) :
+	                                         rt->u.dst.dev->mtu;
+	if (length > mtu) {
+		ipv6_local_error(sk, EMSGSIZE, fl, mtu);
 		return -EMSGSIZE;
 	}
 	if (flags&MSG_PROBE)
-- 
1.5.0.2.gc260-dirty


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2007-04-20 22:55 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-24  0:06 [PATCH 1/3] [NET] Do pmtu check in transport layer John Heffner
2007-03-24  0:06 ` [PATCH 2/3] [NET] Move DF check to ip_forward John Heffner
2007-03-24  0:06   ` [PATCH 3/3] [NET] Add IP(V6)_PMTUDISC_RPOBE John Heffner
2007-03-25  4:23     ` David Miller
2007-03-27 14:18     ` Andi Kleen
     [not found]       ` <4609640D.7010709@psc.edu>
     [not found]         ` <20070327193115.GA28138@one.firstfloor.org>
2007-03-27 19:52           ` [PATCH] ip(7) IP_PMTUDISC_PROBE John Heffner
2007-04-08 18:08             ` Michael Kerrisk
2007-03-25  4:17   ` [PATCH 2/3] [NET] Move DF check to ip_forward David Miller
2007-03-25 13:37   ` [NET]: Fix breakage, use ip_hdr() for DF check in ip_forward Thomas Graf
2007-03-25 20:27     ` David Miller
2007-03-25  4:14 ` [PATCH 1/3] [NET] Do pmtu check in transport layer David Miller
2007-04-09  8:40 ` Patrick McHardy
2007-04-09 16:23   ` John Heffner
2007-04-09 16:40     ` Patrick McHardy
2007-04-19  1:07   ` [PATCH 0/0] Re-try changes for PMTUDISC_PROBE John Heffner
2007-04-20 22:55     ` David Miller
2007-04-19  1:07 ` [PATCH] Revert "[NET] Add IP(V6)_PMTUDISC_RPOBE" John Heffner
2007-04-19  1:07   ` [PATCH] Revert "[NET] Do pmtu check in transport layer" John Heffner
2007-04-19  1:07     ` [PATCH] [NET] MTU discovery check in ip6_fragment() John Heffner
2007-04-19  1:07       ` [PATCH] [NET] Add IP(V6)_PMTUDISC_RPOBE John Heffner
2007-04-19  1:11         ` John Heffner
2007-04-19  1:25           ` David Miller
2007-04-19  1:09 ` [PATCH 1/4] Revert "[NET] Add IP(V6)_PMTUDISC_RPOBE" John Heffner
2007-04-19  1:09   ` [PATCH 2/4] Revert "[NET] Do pmtu check in transport layer" John Heffner
2007-04-19  1:09     ` [PATCH 3/4] [NET] MTU discovery check in ip6_fragment() John Heffner
2007-04-19  1:09       ` [PATCH 4/4] [NET] Add IP(V6)_PMTUDISC_RPOBE John Heffner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.