diff options
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_state.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index da54a64ccfa3..a14c88bf17f0 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -1099,7 +1099,7 @@ int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), | |||
1099 | void *data) | 1099 | void *data) |
1100 | { | 1100 | { |
1101 | int i; | 1101 | int i; |
1102 | struct xfrm_state *x; | 1102 | struct xfrm_state *x, *last = NULL; |
1103 | struct hlist_node *entry; | 1103 | struct hlist_node *entry; |
1104 | int count = 0; | 1104 | int count = 0; |
1105 | int err = 0; | 1105 | int err = 0; |
@@ -1107,24 +1107,22 @@ int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), | |||
1107 | spin_lock_bh(&xfrm_state_lock); | 1107 | spin_lock_bh(&xfrm_state_lock); |
1108 | for (i = 0; i <= xfrm_state_hmask; i++) { | 1108 | for (i = 0; i <= xfrm_state_hmask; i++) { |
1109 | hlist_for_each_entry(x, entry, xfrm_state_bydst+i, bydst) { | 1109 | hlist_for_each_entry(x, entry, xfrm_state_bydst+i, bydst) { |
1110 | if (xfrm_id_proto_match(x->id.proto, proto)) | 1110 | if (!xfrm_id_proto_match(x->id.proto, proto)) |
1111 | count++; | 1111 | continue; |
1112 | if (last) { | ||
1113 | err = func(last, count, data); | ||
1114 | if (err) | ||
1115 | goto out; | ||
1116 | } | ||
1117 | last = x; | ||
1118 | count++; | ||
1112 | } | 1119 | } |
1113 | } | 1120 | } |
1114 | if (count == 0) { | 1121 | if (count == 0) { |
1115 | err = -ENOENT; | 1122 | err = -ENOENT; |
1116 | goto out; | 1123 | goto out; |
1117 | } | 1124 | } |
1118 | 1125 | err = func(last, 0, data); | |
1119 | for (i = 0; i <= xfrm_state_hmask; i++) { | ||
1120 | hlist_for_each_entry(x, entry, xfrm_state_bydst+i, bydst) { | ||
1121 | if (!xfrm_id_proto_match(x->id.proto, proto)) | ||
1122 | continue; | ||
1123 | err = func(x, --count, data); | ||
1124 | if (err) | ||
1125 | goto out; | ||
1126 | } | ||
1127 | } | ||
1128 | out: | 1126 | out: |
1129 | spin_unlock_bh(&xfrm_state_lock); | 1127 | spin_unlock_bh(&xfrm_state_lock); |
1130 | return err; | 1128 | return err; |