aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPhil Oester <kernel@linuxace.com>2013-06-12 04:44:51 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2013-06-12 05:04:41 -0400
commit70d19f805f8c047fc0a28dec9306b3773971c8d9 (patch)
tree9cd85b27999ef58f1679e64f2f88e4240ee4dc5c /net
parented82c437320c48a4032492f4a55a7e2c934158b6 (diff)
netfilter: xt_TCPMSS: Fix IPv6 default MSS too
As a followup to commit 409b545a ("netfilter: xt_TCPMSS: Fix violation of RFC879 in absence of MSS option"), John Heffner points out that IPv6 has a higher MTU than IPv4, and thus a higher minimum MSS. Update TCPMSS target to account for this, and update RFC comment. While at it, point to more recent reference RFC1122 instead of RFC879. Signed-off-by: Phil Oester <kernel@linuxace.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/xt_TCPMSS.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index afaebc766933..6640a224f9fb 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -45,11 +45,12 @@ optlen(const u_int8_t *opt, unsigned int offset)
45 45
46static int 46static int
47tcpmss_mangle_packet(struct sk_buff *skb, 47tcpmss_mangle_packet(struct sk_buff *skb,
48 const struct xt_tcpmss_info *info, 48 const struct xt_action_param *par,
49 unsigned int in_mtu, 49 unsigned int in_mtu,
50 unsigned int tcphoff, 50 unsigned int tcphoff,
51 unsigned int minlen) 51 unsigned int minlen)
52{ 52{
53 const struct xt_tcpmss_info *info = par->targinfo;
53 struct tcphdr *tcph; 54 struct tcphdr *tcph;
54 unsigned int tcplen, i; 55 unsigned int tcplen, i;
55 __be16 oldval; 56 __be16 oldval;
@@ -125,11 +126,17 @@ tcpmss_mangle_packet(struct sk_buff *skb,
125 126
126 skb_put(skb, TCPOLEN_MSS); 127 skb_put(skb, TCPOLEN_MSS);
127 128
128 /* RFC 879 states that the default MSS is 536 without specific 129 /*
129 * knowledge that the destination host is prepared to accept larger. 130 * IPv4: RFC 1122 states "If an MSS option is not received at
130 * Since no MSS was provided, we MUST NOT set a value > 536. 131 * connection setup, TCP MUST assume a default send MSS of 536".
132 * IPv6: RFC 2460 states IPv6 has a minimum MTU of 1280 and a minimum
133 * length IPv6 header of 60, ergo the default MSS value is 1220
134 * Since no MSS was provided, we must use the default values
131 */ 135 */
132 newmss = min(newmss, (u16)536); 136 if (par->family == NFPROTO_IPV4)
137 newmss = min(newmss, (u16)536);
138 else
139 newmss = min(newmss, (u16)1220);
133 140
134 opt = (u_int8_t *)tcph + sizeof(struct tcphdr); 141 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
135 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr)); 142 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
@@ -188,7 +195,7 @@ tcpmss_tg4(struct sk_buff *skb, const struct xt_action_param *par)
188 __be16 newlen; 195 __be16 newlen;
189 int ret; 196 int ret;
190 197
191 ret = tcpmss_mangle_packet(skb, par->targinfo, 198 ret = tcpmss_mangle_packet(skb, par,
192 tcpmss_reverse_mtu(skb, PF_INET), 199 tcpmss_reverse_mtu(skb, PF_INET),
193 iph->ihl * 4, 200 iph->ihl * 4,
194 sizeof(*iph) + sizeof(struct tcphdr)); 201 sizeof(*iph) + sizeof(struct tcphdr));
@@ -217,7 +224,7 @@ tcpmss_tg6(struct sk_buff *skb, const struct xt_action_param *par)
217 tcphoff = ipv6_skip_exthdr(skb, sizeof(*ipv6h), &nexthdr, &frag_off); 224 tcphoff = ipv6_skip_exthdr(skb, sizeof(*ipv6h), &nexthdr, &frag_off);
218 if (tcphoff < 0) 225 if (tcphoff < 0)
219 return NF_DROP; 226 return NF_DROP;
220 ret = tcpmss_mangle_packet(skb, par->targinfo, 227 ret = tcpmss_mangle_packet(skb, par,
221 tcpmss_reverse_mtu(skb, PF_INET6), 228 tcpmss_reverse_mtu(skb, PF_INET6),
222 tcphoff, 229 tcphoff,
223 sizeof(*ipv6h) + sizeof(struct tcphdr)); 230 sizeof(*ipv6h) + sizeof(struct tcphdr));