aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/xfrm.h6
-rw-r--r--net/xfrm/xfrm_state.c6
2 files changed, 9 insertions, 3 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 762795624b10..5b364b0a6a28 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -9,6 +9,7 @@
9#include <linux/skbuff.h> 9#include <linux/skbuff.h>
10#include <linux/socket.h> 10#include <linux/socket.h>
11#include <linux/pfkeyv2.h> 11#include <linux/pfkeyv2.h>
12#include <linux/ipsec.h>
12#include <linux/in6.h> 13#include <linux/in6.h>
13#include <linux/mutex.h> 14#include <linux/mutex.h>
14 15
@@ -835,6 +836,11 @@ static inline int xfrm_state_kern(struct xfrm_state *x)
835 return atomic_read(&x->tunnel_users); 836 return atomic_read(&x->tunnel_users);
836} 837}
837 838
839static inline int xfrm_id_proto_match(u8 proto, u8 userproto)
840{
841 return (userproto == IPSEC_PROTO_ANY || proto == userproto);
842}
843
838/* 844/*
839 * xfrm algorithm information 845 * xfrm algorithm information
840 */ 846 */
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 1c796087ee78..34c038cbdf46 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -294,7 +294,7 @@ void xfrm_state_flush(u8 proto)
294restart: 294restart:
295 list_for_each_entry(x, xfrm_state_bydst+i, bydst) { 295 list_for_each_entry(x, xfrm_state_bydst+i, bydst) {
296 if (!xfrm_state_kern(x) && 296 if (!xfrm_state_kern(x) &&
297 (proto == IPSEC_PROTO_ANY || x->id.proto == proto)) { 297 xfrm_id_proto_match(x->id.proto, proto)) {
298 xfrm_state_hold(x); 298 xfrm_state_hold(x);
299 spin_unlock_bh(&xfrm_state_lock); 299 spin_unlock_bh(&xfrm_state_lock);
300 300
@@ -772,7 +772,7 @@ int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*),
772 spin_lock_bh(&xfrm_state_lock); 772 spin_lock_bh(&xfrm_state_lock);
773 for (i = 0; i < XFRM_DST_HSIZE; i++) { 773 for (i = 0; i < XFRM_DST_HSIZE; i++) {
774 list_for_each_entry(x, xfrm_state_bydst+i, bydst) { 774 list_for_each_entry(x, xfrm_state_bydst+i, bydst) {
775 if (proto == IPSEC_PROTO_ANY || x->id.proto == proto) 775 if (xfrm_id_proto_match(x->id.proto, proto))
776 count++; 776 count++;
777 } 777 }
778 } 778 }
@@ -783,7 +783,7 @@ int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*),
783 783
784 for (i = 0; i < XFRM_DST_HSIZE; i++) { 784 for (i = 0; i < XFRM_DST_HSIZE; i++) {
785 list_for_each_entry(x, xfrm_state_bydst+i, bydst) { 785 list_for_each_entry(x, xfrm_state_bydst+i, bydst) {
786 if (proto != IPSEC_PROTO_ANY && x->id.proto != proto) 786 if (!xfrm_id_proto_match(x->id.proto, proto))
787 continue; 787 continue;
788 err = func(x, --count, data); 788 err = func(x, --count, data);
789 if (err) 789 if (err)