aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/xfrm.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/xfrm.h')
-rw-r--r--include/net/xfrm.h104
1 files changed, 45 insertions, 59 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 2933d7474a79..11c890ad8ebb 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -117,12 +117,23 @@ 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 /* Note: bydst is re-used during gc */ 133 union {
124 struct list_head all; 134 struct hlist_node gclist;
125 struct hlist_node bydst; 135 struct hlist_node bydst;
136 };
126 struct hlist_node bysrc; 137 struct hlist_node bysrc;
127 struct hlist_node byspi; 138 struct hlist_node byspi;
128 139
@@ -134,12 +145,8 @@ struct xfrm_state
134 145
135 u32 genid; 146 u32 genid;
136 147
137 /* Key manger bits */ 148 /* Key manager bits */
138 struct { 149 struct xfrm_state_walk km;
139 u8 state;
140 u8 dying;
141 u32 seq;
142 } km;
143 150
144 /* Parameters of this state. */ 151 /* Parameters of this state. */
145 struct { 152 struct {
@@ -447,10 +454,20 @@ struct xfrm_tmpl
447 454
448#define XFRM_MAX_DEPTH 6 455#define XFRM_MAX_DEPTH 6
449 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
450struct xfrm_policy 468struct xfrm_policy
451{ 469{
452 struct xfrm_policy *next; 470 struct xfrm_policy *next;
453 struct list_head bytype;
454 struct hlist_node bydst; 471 struct hlist_node bydst;
455 struct hlist_node byidx; 472 struct hlist_node byidx;
456 473
@@ -465,17 +482,23 @@ struct xfrm_policy
465 struct xfrm_lifetime_cfg lft; 482 struct xfrm_lifetime_cfg lft;
466 struct xfrm_lifetime_cur curlft; 483 struct xfrm_lifetime_cur curlft;
467 struct dst_entry *bundles; 484 struct dst_entry *bundles;
468 u16 family; 485 struct xfrm_policy_walk_entry walk;
469 u8 type; 486 u8 type;
470 u8 action; 487 u8 action;
471 u8 flags; 488 u8 flags;
472 u8 dead;
473 u8 xfrm_nr; 489 u8 xfrm_nr;
474 /* XXX 1 byte hole, try to pack */ 490 u16 family;
475 struct xfrm_sec_ctx *security; 491 struct xfrm_sec_ctx *security;
476 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; 492 struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
477}; 493};
478 494
495struct xfrm_kmaddress {
496 xfrm_address_t local;
497 xfrm_address_t remote;
498 u32 reserved;
499 u16 family;
500};
501
479struct xfrm_migrate { 502struct xfrm_migrate {
480 xfrm_address_t old_daddr; 503 xfrm_address_t old_daddr;
481 xfrm_address_t old_saddr; 504 xfrm_address_t old_saddr;
@@ -515,7 +538,7 @@ struct xfrm_mgr
515 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); 538 int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport);
516 int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c); 539 int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c);
517 int (*report)(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); 540 int (*report)(u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr);
518 int (*migrate)(struct xfrm_selector *sel, u8 dir, u8 type, struct xfrm_migrate *m, int num_bundles); 541 int (*migrate)(struct xfrm_selector *sel, u8 dir, u8 type, struct xfrm_migrate *m, int num_bundles, struct xfrm_kmaddress *k);
519}; 542};
520 543
521extern int xfrm_register_km(struct xfrm_mgr *km); 544extern int xfrm_register_km(struct xfrm_mgr *km);
@@ -1243,18 +1266,6 @@ struct xfrm6_tunnel {
1243 int priority; 1266 int priority;
1244}; 1267};
1245 1268
1246struct xfrm_state_walk {
1247 struct xfrm_state *state;
1248 int count;
1249 u8 proto;
1250};
1251
1252struct xfrm_policy_walk {
1253 struct xfrm_policy *policy;
1254 int count;
1255 u8 type, cur_type;
1256};
1257
1258extern void xfrm_init(void); 1269extern void xfrm_init(void);
1259extern void xfrm4_init(void); 1270extern void xfrm4_init(void);
1260extern void xfrm_state_init(void); 1271extern void xfrm_state_init(void);
@@ -1279,23 +1290,10 @@ static inline void xfrm6_fini(void)
1279extern int xfrm_proc_init(void); 1290extern int xfrm_proc_init(void);
1280#endif 1291#endif
1281 1292
1282static inline void xfrm_state_walk_init(struct xfrm_state_walk *walk, u8 proto) 1293extern void xfrm_state_walk_init(struct xfrm_state_walk *walk, u8 proto);
1283{
1284 walk->proto = proto;
1285 walk->state = NULL;
1286 walk->count = 0;
1287}
1288
1289static inline void xfrm_state_walk_done(struct xfrm_state_walk *walk)
1290{
1291 if (walk->state != NULL) {
1292 xfrm_state_put(walk->state);
1293 walk->state = NULL;
1294 }
1295}
1296
1297extern int xfrm_state_walk(struct xfrm_state_walk *walk, 1294extern int xfrm_state_walk(struct xfrm_state_walk *walk,
1298 int (*func)(struct xfrm_state *, int, void*), void *); 1295 int (*func)(struct xfrm_state *, int, void*), void *);
1296extern void xfrm_state_walk_done(struct xfrm_state_walk *walk);
1299extern struct xfrm_state *xfrm_state_alloc(void); 1297extern struct xfrm_state *xfrm_state_alloc(void);
1300extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, 1298extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
1301 struct flowi *fl, struct xfrm_tmpl *tmpl, 1299 struct flowi *fl, struct xfrm_tmpl *tmpl,
@@ -1419,24 +1417,10 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb)
1419 1417
1420struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); 1418struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp);
1421 1419
1422static inline void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type) 1420extern void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type);
1423{
1424 walk->cur_type = XFRM_POLICY_TYPE_MAIN;
1425 walk->type = type;
1426 walk->policy = NULL;
1427 walk->count = 0;
1428}
1429
1430static inline void xfrm_policy_walk_done(struct xfrm_policy_walk *walk)
1431{
1432 if (walk->policy != NULL) {
1433 xfrm_pol_put(walk->policy);
1434 walk->policy = NULL;
1435 }
1436}
1437
1438extern int xfrm_policy_walk(struct xfrm_policy_walk *walk, 1421extern int xfrm_policy_walk(struct xfrm_policy_walk *walk,
1439 int (*func)(struct xfrm_policy *, int, int, void*), void *); 1422 int (*func)(struct xfrm_policy *, int, int, void*), void *);
1423extern void xfrm_policy_walk_done(struct xfrm_policy_walk *walk);
1440int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); 1424int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl);
1441struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir, 1425struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir,
1442 struct xfrm_selector *sel, 1426 struct xfrm_selector *sel,
@@ -1455,12 +1439,14 @@ extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
1455 1439
1456#ifdef CONFIG_XFRM_MIGRATE 1440#ifdef CONFIG_XFRM_MIGRATE
1457extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1441extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
1458 struct xfrm_migrate *m, int num_bundles); 1442 struct xfrm_migrate *m, int num_bundles,
1443 struct xfrm_kmaddress *k);
1459extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m); 1444extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m);
1460extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x, 1445extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x,
1461 struct xfrm_migrate *m); 1446 struct xfrm_migrate *m);
1462extern int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1447extern int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
1463 struct xfrm_migrate *m, int num_bundles); 1448 struct xfrm_migrate *m, int num_bundles,
1449 struct xfrm_kmaddress *k);
1464#endif 1450#endif
1465 1451
1466extern wait_queue_head_t km_waitq; 1452extern wait_queue_head_t km_waitq;