aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_state.c
diff options
context:
space:
mode:
authorWei Yongjun <yjwei@cn.fujitsu.com>2009-06-28 14:42:53 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-29 22:41:46 -0400
commit1802571b9865c0fc1d8d0fa39cf73275f3a75af3 (patch)
treec26651ac2d19ecb5aa633d6a550fbddf7094fee5 /net/xfrm/xfrm_state.c
parent6828b92bd21acd65113dfe0541f19f5df0d9668f (diff)
xfrm: use xfrm_addr_cmp() instead of compare addresses directly
Clean up to use xfrm_addr_cmp() instead of compare addresses directly. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-rw-r--r--net/xfrm/xfrm_state.c57
1 files changed, 8 insertions, 49 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 5f1f86565f16..f2f7c638083e 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -668,22 +668,10 @@ static struct xfrm_state *__xfrm_state_lookup(struct net *net, xfrm_address_t *d
668 hlist_for_each_entry(x, entry, net->xfrm.state_byspi+h, byspi) { 668 hlist_for_each_entry(x, entry, net->xfrm.state_byspi+h, byspi) {
669 if (x->props.family != family || 669 if (x->props.family != family ||
670 x->id.spi != spi || 670 x->id.spi != spi ||
671 x->id.proto != proto) 671 x->id.proto != proto ||
672 xfrm_addr_cmp(&x->id.daddr, daddr, family))
672 continue; 673 continue;
673 674
674 switch (family) {
675 case AF_INET:
676 if (x->id.daddr.a4 != daddr->a4)
677 continue;
678 break;
679 case AF_INET6:
680 if (!ipv6_addr_equal((struct in6_addr *)daddr,
681 (struct in6_addr *)
682 x->id.daddr.a6))
683 continue;
684 break;
685 }
686
687 xfrm_state_hold(x); 675 xfrm_state_hold(x);
688 return x; 676 return x;
689 } 677 }
@@ -699,26 +687,11 @@ static struct xfrm_state *__xfrm_state_lookup_byaddr(struct net *net, xfrm_addre
699 687
700 hlist_for_each_entry(x, entry, net->xfrm.state_bysrc+h, bysrc) { 688 hlist_for_each_entry(x, entry, net->xfrm.state_bysrc+h, bysrc) {
701 if (x->props.family != family || 689 if (x->props.family != family ||
702 x->id.proto != proto) 690 x->id.proto != proto ||
691 xfrm_addr_cmp(&x->id.daddr, daddr, family) ||
692 xfrm_addr_cmp(&x->props.saddr, saddr, family))
703 continue; 693 continue;
704 694
705 switch (family) {
706 case AF_INET:
707 if (x->id.daddr.a4 != daddr->a4 ||
708 x->props.saddr.a4 != saddr->a4)
709 continue;
710 break;
711 case AF_INET6:
712 if (!ipv6_addr_equal((struct in6_addr *)daddr,
713 (struct in6_addr *)
714 x->id.daddr.a6) ||
715 !ipv6_addr_equal((struct in6_addr *)saddr,
716 (struct in6_addr *)
717 x->props.saddr.a6))
718 continue;
719 break;
720 }
721
722 xfrm_state_hold(x); 695 xfrm_state_hold(x);
723 return x; 696 return x;
724 } 697 }
@@ -1001,25 +974,11 @@ static struct xfrm_state *__find_acq_core(struct net *net, unsigned short family
1001 x->props.family != family || 974 x->props.family != family ||
1002 x->km.state != XFRM_STATE_ACQ || 975 x->km.state != XFRM_STATE_ACQ ||
1003 x->id.spi != 0 || 976 x->id.spi != 0 ||
1004 x->id.proto != proto) 977 x->id.proto != proto ||
978 xfrm_addr_cmp(&x->id.daddr, daddr, family) ||
979 xfrm_addr_cmp(&x->props.saddr, saddr, family))
1005 continue; 980 continue;
1006 981
1007 switch (family) {
1008 case AF_INET:
1009 if (x->id.daddr.a4 != daddr->a4 ||
1010 x->props.saddr.a4 != saddr->a4)
1011 continue;
1012 break;
1013 case AF_INET6:
1014 if (!ipv6_addr_equal((struct in6_addr *)x->id.daddr.a6,
1015 (struct in6_addr *)daddr) ||
1016 !ipv6_addr_equal((struct in6_addr *)
1017 x->props.saddr.a6,
1018 (struct in6_addr *)saddr))
1019 continue;
1020 break;
1021 }
1022
1023 xfrm_state_hold(x); 982 xfrm_state_hold(x);
1024 return x; 983 return x;
1025 } 984 }