提交 10a19939 编写于 作者: S Simon Arlott 提交者: Patrick McHardy

netfilter: xt_TCPMSS: SYN packets are allowed to contain data

The TCPMSS target is dropping SYN packets where:
  1) There is data, or
  2) The data offset makes the TCP header larger than the packet.

Both of these result in an error level printk. This printk has been
removed.

This change avoids dropping SYN packets containing data. If there
is also no MSS option (as well as data), one will not be added
because of possible complications due to the increased packet size.
Signed-off-by: NSimon Arlott <simon@fire.lp0.eu>
Signed-off-by: NPatrick McHardy <kaber@trash.net>
上级 c30f540b
...@@ -60,17 +60,9 @@ tcpmss_mangle_packet(struct sk_buff *skb, ...@@ -60,17 +60,9 @@ tcpmss_mangle_packet(struct sk_buff *skb,
tcplen = skb->len - tcphoff; tcplen = skb->len - tcphoff;
tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
/* Since it passed flags test in tcp match, we know it is is /* Header cannot be larger than the packet */
not a fragment, and has data >= tcp header length. SYN if (tcplen < tcph->doff*4)
packets should not contain data: if they did, then we risk
running over MTU, sending Frag Needed and breaking things
badly. --RR */
if (tcplen != tcph->doff*4) {
if (net_ratelimit())
printk(KERN_ERR "xt_TCPMSS: bad length (%u bytes)\n",
skb->len);
return -1; return -1;
}
if (info->mss == XT_TCPMSS_CLAMP_PMTU) { if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
if (dst_mtu(skb_dst(skb)) <= minlen) { if (dst_mtu(skb_dst(skb)) <= minlen) {
...@@ -115,6 +107,12 @@ tcpmss_mangle_packet(struct sk_buff *skb, ...@@ -115,6 +107,12 @@ tcpmss_mangle_packet(struct sk_buff *skb,
} }
} }
/* There is data after the header so the option can't be added
without moving it, and doing so may make the SYN packet
itself too large. Accept the packet unmodified instead. */
if (tcplen > tcph->doff*4)
return 0;
/* /*
* MSS Option not found ?! add it.. * MSS Option not found ?! add it..
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册