Skip to contentSkip to conversation

xfrm: Simplify SA looking up when using wildcard source

PATCH Applied Fan Du 2 participants 2 messages Sep 27, 2013 – Oct 1, 2013

Subsystems (3)
lore
Share & tools
lore

Fan Du

author
#0 lore raw

PATCH v2 1/1 xfrm: Simplify SA looking up when using wildcard source

__xfrm4/6_state_addr_check is a four steps check, all we need to do is checking whether the destination address match when looking SA using wildcard source address. Passing saddr from flow is worst option, as the checking needs to reach the fourth step while actually only one time checking will do the work.

So, simplify this process by only checking destination address when using wildcard source address for looking up SAs.

---
v2:
- Rewrite a good qualified commit log message
- Use xfrm_addr_equal instead of remaking wheel

---
 net/xfrm/xfrm_state.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/xfrm_state.c +1 -1
index e1373d5..3fad928 100644
@@ -824,7 +824,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
 		    x->props.reqid == tmpl->reqid &&
 		    (mark & x->mark.m) == x->mark.v &&
 		    !(x->props.flags & XFRM_STATE_WILDRECV) &&
-		    xfrm_state_addr_check(x, daddr, saddr, encap_family) &&
+		    xfrm_addr_equal(&x->id.daddr, daddr, encap_family) &&
 		    tmpl->mode == x->props.mode &&
 		    tmpl->id.proto == x->id.proto &&
 		    (tmpl->id.spi == x->id.spi || !tmpl->id.spi))
Signature · 1 line
1.7.9.5
maintainer Applied
#1 lore raw
Quoted 10 lines · Fan Du

__xfrm4/6_state_addr_check is a four steps check, all we need to do is checking whether the destination address match when looking SA using wildcard source address. Passing saddr from flow is worst option, as the checking needs to reach the fourth step while actually only one time checking will do the work.

So, simplify this process by only checking destination address when using wildcard source address for looking up SAs.

Applied to ipsec-next, thanks a lot!