: [NETFILTER]: Fix xfrm lookup in ip_route_me_harder
Subsystems (4)
PATCH 7/10 : [NETFILTER]: Fix xfrm lookup in ip_route_me_harder
[NETFILTER]: Fix xfrm lookup in ip_route_me_harder
ip_route_me_harder uses ip_route_input for non-local addresses, which doesn't do a xfrm lookup, and doesn't use the port numbers for the lookup for local addresses. Use xfrm_decode_session and do the lookup manually.
Signed-off-by Patrick McHardy <[email protected]>
---
commit 909b664477ab16fc04f2bf24ef92676117ccbc26
tree 7085763e2f28f37ffc7f5ce4af044e92f835d03e
parent d14a36982a14bb6695a6ce44fd4f3f4c9aaa6a0c
author Patrick McHardy <[email protected]> Fri, 11 Nov 2005 03:02:17 +0100 committer Patrick McHardy <[email protected]> Fri, 11 Nov 2005 03:02:17 +0100
include/net/xfrm.h | 2 +- net/ipv4/netfilter.c | 7 ++++++- net/xfrm/xfrm_policy.c | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-)
include/net/xfrm.h +1 -1
@@ -644,7 +644,7 @@ static inline int xfrm6_policy_check(strreturn xfrm_policy_check (sk, dir, skb,AF_INET6 ); } - +extern int xfrm_decode_session (struct sk_buff *skb,struct flowi *fl,unsigned short family);extern int __xfrm_route_forward (struct sk_buff *skb,unsigned short family);static inline int xfrm_route_forward (struct sk_buff *skb,unsigned short family)
net/ipv4/netfilter.c +6 -1
@@ -34,7 +34,6 @@ int ip_route_me_harder(struct sk_buff **#ifdef CONFIG_IP_ROUTE_FWMARK fl.nl_u.ip4_u.fwmark = (*pskb)->nfmark;#endif - fl.proto = iph->protocol;if (ip_route_output_key (&rt, &fl) !=0 )return -1 ;
@@ -61,6 +60,12 @@ int ip_route_me_harder(struct sk_buff **if ((*pskb)->dst->error)return -1 ; +#ifdef CONFIG_XFRM +if (xfrm_decode_session (*pskb, &fl,AF_INET ) ==0 ) +if (xfrm_lookup (&(*pskb)->dst, &fl, (*pskb)->sk,0 )) +return -1 ; +#endif +/* Change in oif may mean change in hh_len. */ hh_len = (*pskb)->dst->dev->hard_header_len;if (skb_headroom (*pskb) < hh_len) {
net/xfrm/xfrm_policy.c +4 -4
@@ -906,8 +906,8 @@ xfrm_policy_ok(struct xfrm_tmpl *tmpl, sreturn start; } -static int -_decode_session (struct sk_buff *skb,struct flowi *fl,unsigned short family) +int xfrm_decode_session (struct sk_buff *skb,struct flowi *fl, +unsigned short family) {struct xfrm_policy_afinfo *afinfo =xfrm_policy_get_afinfo (family);
@@ -935,7 +935,7 @@ int __xfrm_policy_check(struct sock *sk,struct xfrm_policy *pol;struct flowi fl; -if (_decode_session (skb, &fl, family) <0 ) +if (xfrm_decode_session (skb, &fl, family) <0 )return 0 ;/* First, check used SA against their selectors. */
@@ -1007,7 +1007,7 @@ int __xfrm_route_forward(struct sk_buff {struct flowi fl; -if (_decode_session (skb, &fl, family) <0 ) +if (xfrm_decode_session (skb, &fl, family) <0 )return 0 ;return xfrm_lookup (&skb->dst, &fl,NULL ,0 ) ==0 ;