aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/xfrm6_input.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/xfrm6_input.c')
-rw-r--r--net/ipv6/xfrm6_input.c55
1 files changed, 14 insertions, 41 deletions
diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index a4714d76ae6b..a71c7ddcb41e 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -59,9 +59,6 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
59 xfrm_address_t *saddr, u8 proto) 59 xfrm_address_t *saddr, u8 proto)
60{ 60{
61 struct xfrm_state *x = NULL; 61 struct xfrm_state *x = NULL;
62 int wildcard = 0;
63 xfrm_address_t *xany;
64 int nh = 0;
65 int i = 0; 62 int i = 0;
66 63
67 /* Allocate new secpath or COW existing one. */ 64 /* Allocate new secpath or COW existing one. */
@@ -83,10 +80,9 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
83 goto drop; 80 goto drop;
84 } 81 }
85 82
86 xany = (xfrm_address_t *)&in6addr_any;
87
88 for (i = 0; i < 3; i++) { 83 for (i = 0; i < 3; i++) {
89 xfrm_address_t *dst, *src; 84 xfrm_address_t *dst, *src;
85
90 switch (i) { 86 switch (i) {
91 case 0: 87 case 0:
92 dst = daddr; 88 dst = daddr;
@@ -94,16 +90,13 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
94 break; 90 break;
95 case 1: 91 case 1:
96 /* lookup state with wild-card source address */ 92 /* lookup state with wild-card source address */
97 wildcard = 1;
98 dst = daddr; 93 dst = daddr;
99 src = xany; 94 src = (xfrm_address_t *)&in6addr_any;
100 break; 95 break;
101 case 2:
102 default: 96 default:
103 /* lookup state with wild-card addresses */ 97 /* lookup state with wild-card addresses */
104 wildcard = 1; /* XXX */ 98 dst = (xfrm_address_t *)&in6addr_any;
105 dst = xany; 99 src = (xfrm_address_t *)&in6addr_any;
106 src = xany;
107 break; 100 break;
108 } 101 }
109 102
@@ -113,39 +106,19 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
113 106
114 spin_lock(&x->lock); 107 spin_lock(&x->lock);
115 108
116 if (wildcard) { 109 if ((!i || (x->props.flags & XFRM_STATE_WILDRECV)) &&
117 if ((x->props.flags & XFRM_STATE_WILDRECV) == 0) { 110 likely(x->km.state == XFRM_STATE_VALID) &&
118 spin_unlock(&x->lock); 111 !xfrm_state_check_expire(x)) {
119 xfrm_state_put(x);
120 x = NULL;
121 continue;
122 }
123 }
124
125 if (unlikely(x->km.state != XFRM_STATE_VALID)) {
126 spin_unlock(&x->lock); 112 spin_unlock(&x->lock);
127 xfrm_state_put(x); 113 if (x->type->input(x, skb) > 0) {
128 x = NULL; 114 /* found a valid state */
129 continue; 115 break;
130 } 116 }
131 if (xfrm_state_check_expire(x)) { 117 } else
132 spin_unlock(&x->lock); 118 spin_unlock(&x->lock);
133 xfrm_state_put(x);
134 x = NULL;
135 continue;
136 }
137
138 spin_unlock(&x->lock);
139
140 nh = x->type->input(x, skb);
141 if (nh <= 0) {
142 xfrm_state_put(x);
143 x = NULL;
144 continue;
145 }
146 119
147 /* Found a state */ 120 xfrm_state_put(x);
148 break; 121 x = NULL;
149 } 122 }
150 123
151 if (!x) { 124 if (!x) {