2.6.22.6 netfilter: sk_setup_caps in ip_make_route_harder
Subsystems (3)
RFC PATCH 1/1 2.6.22.6 netfilter: sk_setup_caps in ip_make_route_harder
Hi,
For local src packets, it is better to update sk_route_caps in ip_route_me_harder.
net/ipv4/netfilter.c +4 -0
@@ -37,6 +37,10 @@ int ip_route_me_harder(struct sk_buff **/* Drop old route. */ dst_release ((*pskb)->dst); (*pskb)->dst = &rt->u.dst; +if ((*pskb)->sk){ +dst_hold ((*pskb)->dst); +sk_setup_caps ((*pskb)->sk, (*pskb)->dst); + } }else {/* non-local src, find valid iif to satisfy * rp-filter when calling ip_route_input. */
Quoted 3 lines · lepton
Hi,
For local src packets, it is better to updatesk_route_capsinip_route_me_harder.
This seems like a good idea to me. But why only for local src (address) packets? This function can also be used for locally generated packet that have been (f.i.) NATed to a foreign address ...
Quoted 17 lines
Signed-off-by Lepton Wu <[email protected]>diff -pru -X linux-2.6.22.6/Documentation/dontdiff
linux-2.6.22.6/net/ipv4/netfilter.clinux-2.6.22.6-lepton/net/ipv4/netfilter.cnet/ipv4/netfilter.c +4
-0@@ -37,6 +37,10 @@ int ip_route_me_harder(struct sk_buff **/* Drop old route. */ dst_release ((*pskb)->dst); (*pskb)->dst = &rt->u.dst; +if ((*pskb)->sk){ +dst_hold ((*pskb)->dst); +sk_setup_caps ((*pskb)->sk, (*pskb)->dst); + } }else {/* non-local src, find valid iif to satisfy * rp-filter when calling ip_route_input. */
Quoted 8 lines · Patrick McHardy
Quoted 3 lines · lepton
Hi,
For local src packets, it is better to updatesk_route_capsinip_route_me_harder.
Quoted 4 lines
This seems like a good idea to me. But why only for local src (address) packets? This function can also be used for locally generated packet that have been (f.i.) NATed to a foreign address ...
Actually, I'm afraid it might break some setups. Rerouting is done per packet, but if we cache the dst_entry for the socket, all packets from that socket will be routed similar.
Yes, you are right.
What do you think about this:
For all packets can be sent out, we just disable
all things in sk_route_caps in ip_route_me_harder
net/ipv4/netfilter.c +4 -0
@@ -57,6 +57,10 @@ int ip_route_me_harder(struct sk_buff **if ((*pskb)->dst->error)return -1 ; +if ((*pskb)->sk&&sk->sk_route_caps) +/* This is overkill, but it is safe and simple */ + sk->sk_route_caps=0 ; +#ifdef CONFIG_XFRM if (!(IPCB (*pskb)->flags &IPSKB_XFRM_TRANSFORMED ) &&xfrm_decode_session (*pskb, &fl,AF_INET ) ==0 )
Quoted 19 lines · Patrick McHardy
Quoted 8 lines · Patrick McHardy
Quoted 3 lines · lepton
Hi,
For local src packets, it is better to updatesk_route_capsinip_route_me_harder.Quoted 4 lines
This seems like a good idea to me. But why only for local src (address) packets? This function can also be used for locally generated packet that have been (f.i.) NATed to a foreign address ...
Actually, I'm afraid it might break some setups. Rerouting is done per packet, but if we cache the
dst_entryfor the socket, all packets from that socket will be routed similar.
Quoted 4 lines · lepton
Yes, you are right.
What do you think about this:
For all packets can be sent out, we just disable
all things insk_route_capsinip_route_me_harder
Whats the point of doing that? Is rerouting breaking anything for you?
Yes.
My situation is:
The default route device is a e1000 network card that can do TSO. So the tcp stack will try send big skb to netfilter frame work. But after rerouting, the packtes will go out from a device that can not do TSO. the packet is just get dropped..
I thinks if we can't get a way to tell tcp stack the sk_route_caps of the real out device, we can just disable all things for safety.
Quoted 8 lines · Patrick McHardy
Quoted 4 lines · lepton
Yes, you are right.
What do you think about this:
For all packets can be sent out, we just disable
all things insk_route_capsinip_route_me_harderWhats the point of doing that? Is rerouting breaking anything for you?
Quoted 8 lines · lepton
My situation is:
The default route device is a e1000 network card that can do TSO. So the tcp stack will try send big skb to netfilter frame work. But after rerouting, the packtes will go out from a device that can not do TSO. the packet is just get dropped..I thinks if we can't get a way to tell tcp stack the
sk_route_capsof the real out device, we can just disable all things for safety.
As you already noticed yourself (in private email), this is handled properly in current kernels.