diff options
author | Jamal Hadi Salim <hadi@cyberus.ca> | 2006-12-04 23:03:35 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-06 21:38:45 -0500 |
commit | 94b9bb5480e73cec4552b19fc3f809742b4ebf67 (patch) | |
tree | ac0186acb0edcae0ee0d134b5bf816513d0d440a /net/xfrm/xfrm_state.c | |
parent | baf5d743d1b8783fdbd5c1260ada2926e5bbaaee (diff) |
[XFRM] Optimize SA dumping
Same comments as in "[XFRM] Optimize policy dumping"
The numbers are (20K SAs):
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-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; |