: Introduce a helper to compare id protocol.
Subsystems (3)
PATCH 2/23 : Introduce a helper to compare id protocol.
Put the helper to header for future use.
--- include/net/xfrm.h | 6 ++++++ net/xfrm/xfrm_state.c | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-)
include/net/xfrm.h +6 -0
@@ -10,6 +10,7 @@ #include <linux/skbuff.h>#include <linux/socket.h> #include <linux/crypto.h> #include <linux/pfkeyv2.h> +#include <linux/ipsec.h> #include <linux/in6.h> #include <linux/mutex.h>
@@ -826,6 +827,11 @@ static inline int xfrm_state_kern(structreturn atomic_read (&x->tunnel_users); } +static inline int xfrm_id_proto_match (u8 proto,u8 userproto) +{ +return (userproto ==IPSEC_PROTO_ANY || proto == userproto); +} +/* * xfrm algorithm information */
net/xfrm/xfrm_state.c +3 -3
@@ -293,7 +293,7 @@ void xfrm_state_flush(u8 proto) restart:list_for_each_entry (x, xfrm_state_bydst+i, bydst) {if (!xfrm_state_kern (x) && - (proto ==IPSEC_PROTO_ANY || x->id.proto == proto)) { +xfrm_id_proto_match (x->id.proto, proto)) {xfrm_state_hold (x);spin_unlock_bh (&xfrm_state_lock);
@@ -763,7 +763,7 @@ int xfrm_state_walk(u8 proto, int (*funcspin_lock_bh (&xfrm_state_lock);for (i =0 ; i <XFRM_DST_HSIZE ; i++) {list_for_each_entry (x, xfrm_state_bydst+i, bydst) { -if (proto ==IPSEC_PROTO_ANY || x->id.proto == proto) +if (xfrm_id_proto_match (x->id.proto, proto)) count++; } }
@@ -774,7 +774,7 @@ int xfrm_state_walk(u8 proto, int (*funcfor (i =0 ; i <XFRM_DST_HSIZE ; i++) {list_for_each_entry (x, xfrm_state_bydst+i, bydst) { -if (proto !=IPSEC_PROTO_ANY && x->id.proto != proto) +if (!xfrm_id_proto_match (x->id.proto, proto))continue ; err =func (x, --count, data);if (err)
Signature · 1 line
1.4.1
David Miller
maintainerFrom: Masahide NAKAMURA <[email protected]>
Date: Sat, 29 Jul 2006 18:29:56 +0900
Quoted 1 line
Put the helper to header for future use.
This change is fine.