2.4.x ipt_REJECT bugfix for TCP RST packets + asymm. routing
Subsystems (2)
PATCH 1/1 2.4.x ipt_REJECT bugfix for TCP RST packets + asymm. routing
Hi Davem!
This fixes a bug (oops) in the generation of TCP RST packets in the ipt_REJECT target in the case of asymmetric routing, where the hardware header length of the outgoing interface is bigger than the hardware header length of the incoming interface.
Please apply to 2.4.x (2.5.x will follow), thanks.
net/ipv4/netfilter/ipt_REJECT.c +18 -12
@@ -42,6 +42,7 @@u_int16_t tmp_port;u_int32_t tmp_addr;int needs_ack; +int hh_len;/* IP header checks: fragment, too short. */ if (oldskb->nh.iph->frag_off & htons(IP_OFFSET)
@@ -61,13 +62,28 @@ csum_partial((char *)otcph, otcplen, 0)) != 0)return ; +/* Routing: if not headed for us, route won't like source */ +if (ip_route_output (&rt, oldskb->nh.iph->daddr, + local ? oldskb->nh.iph->saddr :0 , +RT_TOS (oldskb->nh.iph->tos) |RTO_CONN , +0 ) !=0 ) +return ; + + hh_len = (rt->u.dst.dev->hard_header_len +15 )&~15 ; + +/* Copy skb (even if skb is about to be dropped, we can't just clone it because there may be other things, such as tcpdump, -interested in it) */ - nskb =skb_copy (oldskb,GFP_ATOMIC ); +interested in it). We also need to expand headroom in case +hh_len of incoming interface < hh_len of outgoing interface */ + nskb =skb_copy_expand (oldskb, hh_len,skb_tailroom (oldskb), +GFP_ATOMIC );if (!nskb)return ; +dst_release (nskb->dst); + nskb->dst = &rt->u.dst; +/* This packet will not be the same as the other: clear nf fields */ nf_conntrack_put (nskb->nfct); nskb->nfct =NULL ;
@@ -129,16 +145,6 @@ nskb->nh.iph->check =0 ; nskb->nh.iph->check =ip_fast_csum ((unsigned char *)nskb->nh.iph, nskb->nh.iph->ihl); - -/* Routing: if not headed for us, route won't like source */ -if (ip_route_output (&rt, nskb->nh.iph->daddr, - local ? nskb->nh.iph->saddr :0 , -RT_TOS (nskb->nh.iph->tos) |RTO_CONN , -0 ) !=0 ) - goto free_nskb; - -dst_release (nskb->dst); - nskb->dst = &rt->u.dst;/* "Never happens" */ if (nskb->len > nskb->dst->pmtu)
Signature · 5 lines
- Harald Welte <[email protected]> http://www.netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
From: Harald Welte <[email protected]>
Date: Sun, 30 Mar 2003 21:44:02 +0200
This fixes a bug (oops) in the generation of TCP RST packets in the ipt_REJECT target in the case of asymmetric routing, where the hardware header length of the outgoing interface is bigger than the hardware header length of the incoming interface.
Both 2.4.x and 2.5.x patches applied, thank you.