From: philipc@snapgear.com
To: netfilter-devel@lists.netfilter.org
Subject: [PATCH 2/4] TCPMSS: clamp to input interface MTU too
Date: Wed, 24 May 2006 14:04:43 +1000 [thread overview]
Message-ID: <20060524040950.965615000@snapgear.com> (raw)
In-Reply-To: 20060524040441.111049000@snapgear.com
[-- Attachment #1: tcpmssin.patch --]
[-- Type: text/plain, Size: 2017 bytes --]
Ideally we would clamp the MSS based on the PMTU from src to dst.
Currently we use the PMTU from the packet filter to the dst.
This patch better approximates the full PTMU by using the input
interface MTU too.
Signed-off-by: Philip Craig <philipc@snapgear.com>
Index: linux-2.6.17-rc4.orig/net/ipv4/netfilter/ipt_TCPMSS.c
===================================================================
--- linux-2.6.17-rc4.orig.orig/net/ipv4/netfilter/ipt_TCPMSS.c 2006-05-24 11:57:22.000000000 +1000
+++ linux-2.6.17-rc4.orig/net/ipv4/netfilter/ipt_TCPMSS.c 2006-05-24 11:57:23.000000000 +1000
@@ -27,6 +27,8 @@ MODULE_DESCRIPTION("iptables TCP MSS mod
#define DEBUGP(format, args...)
#endif
+#define HDRSIZE (sizeof(struct iphdr) + sizeof(struct tcphdr))
+
static u_int16_t
cheat_check(u_int32_t oldvalinv, u_int32_t newval, u_int16_t oldcheck)
{
@@ -55,7 +57,7 @@ ipt_tcpmss_target(struct sk_buff **pskb,
const struct ipt_tcpmss_info *tcpmssinfo = targinfo;
struct tcphdr *tcph;
struct iphdr *iph;
- u_int16_t tcplen, newtotlen, oldval, newmss;
+ u_int16_t tcplen, newtotlen, oldval, newmss, mtu;
unsigned int i;
u_int8_t *opt;
@@ -92,14 +94,27 @@ ipt_tcpmss_target(struct sk_buff **pskb,
return IPT_CONTINUE;
}
- if(dst_mtu((*pskb)->dst) <= (sizeof(struct iphdr) + sizeof(struct tcphdr))) {
+ mtu = dst_mtu((*pskb)->dst);
+ if (mtu <= HDRSIZE) {
if (net_ratelimit())
printk(KERN_ERR
- "ipt_tcpmss_target: unknown or invalid path-MTU (%d)\n", dst_mtu((*pskb)->dst));
+ "ipt_tcpmss_target: unknown or "
+ "invalid path-MTU (%d)\n", mtu);
return IPT_CONTINUE;
}
- newmss = dst_mtu((*pskb)->dst) - sizeof(struct iphdr) - sizeof(struct tcphdr);
+ if (in && in->mtu < mtu) {
+ mtu = in->mtu;
+ if (mtu <= HDRSIZE) {
+ if (net_ratelimit())
+ printk(KERN_ERR
+ "ipt_tcpmss_target: invalid "
+ "interface MTU (%d)\n", mtu);
+ return IPT_CONTINUE;
+ }
+ }
+
+ newmss = mtu - HDRSIZE;
} else
newmss = tcpmssinfo->mss;
--
next prev parent reply other threads:[~2006-05-24 4:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-24 4:04 [PATCH 0/4] netfilter patches for consideration philipc
2006-05-24 4:04 ` [PATCH 1/4] TCPMSS: dont drop packets philipc
2006-05-24 16:16 ` Patrick McHardy
2006-05-24 23:42 ` Philip Craig
2006-05-26 14:40 ` Patrick McHardy
2006-05-24 4:04 ` philipc [this message]
2006-05-24 16:18 ` [PATCH 2/4] TCPMSS: clamp to input interface MTU too Patrick McHardy
2006-05-24 4:04 ` [PATCH 3/4] log dropped ICMP redirects philipc
2006-05-24 16:26 ` Patrick McHardy
2006-05-25 2:34 ` Philip Craig
2006-05-26 14:49 ` Patrick McHardy
2006-05-24 4:04 ` [PATCH 4/4] drop ftp bounce attacks philipc
2006-05-24 16:31 ` Patrick McHardy
2006-05-25 2:55 ` Philip Craig
2006-05-26 14:51 ` Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060524040950.965615000@snapgear.com \
--to=philipc@snapgear.com \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.