aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2008-10-01 10:03:24 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-01 10:03:24 -0400
commit12a169e7d8f4b1c95252d8b04ed0f1033ed7cfe2 (patch)
tree9630d7798d4fdfc06d6001ccd057aff68f39f908 /include/net
parentb262e60309e1b0eb25d300c7e739427d5316abb1 (diff)
ipsec: Put dumpers on the dump list
Herbert Xu came up with the idea and the original patch to make xfrm_state dump list contain also dumpers: As it is we go to extraordinary lengths to ensure that states don't go away while dumpers go to sleep. It's much easier if we just put the dumpers themselves on the list since they can't go away while they're going. I've also changed the order of addition on new states to prevent a never-ending dump. Timo Teräs improved the patch to apply cleanly to latest tree, modified iteration code to be more readable by using a common struct for entries in the list, implemented the same idea for xfrm_policy dumping and moved the af_key specific "last" entry caching to af_key. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Timo Teras <timo.teras@iki.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/xfrm.h70
1 files changed, 28 insertions, 42 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 48630b266593..b98d2056f27f 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -117,12 +117,21 @@ extern struct mutex xfrm_cfg_mutex;
117 metrics. Plus, it will be made via sk->sk_dst_cache. Solved. 117 metrics. Plus, it will be made via sk->sk_dst_cache. Solved.
118 */ 118 */
119 119
120struct xfrm_state_walk {
121 struct list_head all;
122 u8 state;
123 union {
124 u8 dying;
125 u8 proto;
126 };
127 u32 seq;
128};
129
120/* Full description of state of transformer. */ 130/* Full description of state of transformer. */
121struct xfrm_state 131struct xfrm_state
122{ 132{
123 struct list_head all;
124 union { 133 union {
125 struct list_head gclist; 134 struct hlist_node gclist;
126 struct hlist_node bydst; 135 struct hlist_node bydst;
127 }; 136 };
128 struct hlist_node bysrc; 137 struct hlist_node bysrc;
@@ -136,12 +145,8 @@ struct xfrm_state
136 145
137 u32 genid; 146 u32 genid;
138 147
139 /* Key manger bits */ 148 /* Key manager bits */
140 struct { 149 struct xfrm_state_walk km;
141 u8 state;
142 u8 dying;
143 u32 seq;
144 } km;
145 150
146 /* Parameters of this state. */ 151 /* Parameters of this state. */
147 struct { 152 struct {
@@ -449,10 +454,20 @@ struct xfrm_tmpl
449 454
450#define XFRM_MAX_DEPTH 6 455#define XFRM_MAX_DEPTH 6
451 456
457struct xfrm_policy_walk_entry {
458 struct list_head all;
459 u8 dead;
460};
461
462struct xfrm_policy_walk {
463 struct xfrm_policy_walk_entry walk;
464 u8 type;
465 u32 seq;
466};
467
452struct xfrm_policy 468struct xfrm_policy
453{ 469{
454 struct xfrm_policy *next; 470 struct xfrm_policy *next;
455 struct list_head bytype;
456 struct hlist_node bydst; 471 struct hlist_node bydst;
457 struct hlist_node byidx; 472 struct hlist_node byidx;
458 473
@@ -467,13 +482,12 @@ struct xfrm_policy
467 struct xfrm_lifetime_cfg lft; 482 struct xfrm_lifetime_cfg lft;
468 struct xfrm_lifetime_cur curlft; 483 struct xfrm_lifetime_cur curlft;
469 struct dst_entry *bundles; 484 struct dst_entry *bundles;
470 u16 family; 485 struct xfrm_policy_walk_entry walk;
471 u8 type; 486 u8 type;
472 u8 action; 487 u8 action;
473 u8 flags; 488 u8 flags;
474 u8 dead;
475 u8 xfrm_nr; 489 u8 xfrm_nr;
476 /* XXX 1 byte hole, try to pack */ 490 u16 family;
477 struct xfrm_sec_ctx *security; 491 struct xfrm_sec_ctx *security;
478 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; 492 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
479}; 493};
@@ -1245,20 +1259,6 @@ struct xfrm6_tunnel {
1245 int priority; 1259 int priority;
1246}; 1260};
1247 1261
1248struct xfrm_state_walk {
1249 struct list_head list;
1250 unsigned long genid;
1251 struct xfrm_state *state;
1252 int count;
1253 u8 proto;
1254};
1255
1256struct xfrm_policy_walk {
1257 struct xfrm_policy *policy;
1258 int count;
1259 u8 type, cur_type;
1260};
1261
1262extern void xfrm_init(void); 1262extern void xfrm_init(void);
1263extern void xfrm4_init(void); 1263extern void xfrm4_init(void);
1264extern void xfrm_state_init(void); 1264extern void xfrm_state_init(void);
@@ -1410,24 +1410,10 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb)
1410 1410
1411struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); 1411struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp);
1412 1412
1413static inline void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type) 1413extern void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type);
1414{
1415 walk->cur_type = XFRM_POLICY_TYPE_MAIN;
1416 walk->type = type;
1417 walk->policy = NULL;
1418 walk->count = 0;
1419}
1420
1421static inline void xfrm_policy_walk_done(struct xfrm_policy_walk *walk)
1422{
1423 if (walk->policy != NULL) {
1424 xfrm_pol_put(walk->policy);
1425 walk->policy = NULL;
1426 }
1427}
1428
1429extern int xfrm_policy_walk(struct xfrm_policy_walk *walk, 1414extern int xfrm_policy_walk(struct xfrm_policy_walk *walk,
1430 int (*func)(struct xfrm_policy *, int, int, void*), void *); 1415 int (*func)(struct xfrm_policy *, int, int, void*), void *);
1416extern void xfrm_policy_walk_done(struct xfrm_policy_walk *walk);
1431int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); 1417int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl);
1432struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir, 1418struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir,
1433 struct xfrm_selector *sel, 1419 struct xfrm_selector *sel,