diff options
Diffstat (limited to 'include/net/xfrm.h')
-rw-r--r-- | include/net/xfrm.h | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 0d255ae008b6..b56b6a10fe5e 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -121,6 +121,7 @@ extern struct mutex xfrm_cfg_mutex; | |||
121 | struct xfrm_state | 121 | struct xfrm_state |
122 | { | 122 | { |
123 | /* Note: bydst is re-used during gc */ | 123 | /* Note: bydst is re-used during gc */ |
124 | struct list_head all; | ||
124 | struct hlist_node bydst; | 125 | struct hlist_node bydst; |
125 | struct hlist_node bysrc; | 126 | struct hlist_node bysrc; |
126 | struct hlist_node byspi; | 127 | struct hlist_node byspi; |
@@ -446,6 +447,7 @@ struct xfrm_tmpl | |||
446 | struct xfrm_policy | 447 | struct xfrm_policy |
447 | { | 448 | { |
448 | struct xfrm_policy *next; | 449 | struct xfrm_policy *next; |
450 | struct list_head bytype; | ||
449 | struct hlist_node bydst; | 451 | struct hlist_node bydst; |
450 | struct hlist_node byidx; | 452 | struct hlist_node byidx; |
451 | 453 | ||
@@ -1071,6 +1073,23 @@ xfrm_address_t *xfrm_flowi_saddr(struct flowi *fl, unsigned short family) | |||
1071 | return NULL; | 1073 | return NULL; |
1072 | } | 1074 | } |
1073 | 1075 | ||
1076 | static __inline__ | ||
1077 | void xfrm_flowi_addr_get(struct flowi *fl, | ||
1078 | xfrm_address_t *saddr, xfrm_address_t *daddr, | ||
1079 | unsigned short family) | ||
1080 | { | ||
1081 | switch(family) { | ||
1082 | case AF_INET: | ||
1083 | memcpy(&saddr->a4, &fl->fl4_src, sizeof(saddr->a4)); | ||
1084 | memcpy(&daddr->a4, &fl->fl4_dst, sizeof(daddr->a4)); | ||
1085 | break; | ||
1086 | case AF_INET6: | ||
1087 | ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->fl6_src); | ||
1088 | ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->fl6_dst); | ||
1089 | break; | ||
1090 | } | ||
1091 | } | ||
1092 | |||
1074 | static __inline__ int | 1093 | static __inline__ int |
1075 | __xfrm4_state_addr_check(struct xfrm_state *x, | 1094 | __xfrm4_state_addr_check(struct xfrm_state *x, |
1076 | xfrm_address_t *daddr, xfrm_address_t *saddr) | 1095 | xfrm_address_t *daddr, xfrm_address_t *saddr) |
@@ -1188,6 +1207,18 @@ struct xfrm6_tunnel { | |||
1188 | int priority; | 1207 | int priority; |
1189 | }; | 1208 | }; |
1190 | 1209 | ||
1210 | struct xfrm_state_walk { | ||
1211 | struct xfrm_state *state; | ||
1212 | int count; | ||
1213 | u8 proto; | ||
1214 | }; | ||
1215 | |||
1216 | struct xfrm_policy_walk { | ||
1217 | struct xfrm_policy *policy; | ||
1218 | int count; | ||
1219 | u8 type, cur_type; | ||
1220 | }; | ||
1221 | |||
1191 | extern void xfrm_init(void); | 1222 | extern void xfrm_init(void); |
1192 | extern void xfrm4_init(void); | 1223 | extern void xfrm4_init(void); |
1193 | extern void xfrm_state_init(void); | 1224 | extern void xfrm_state_init(void); |
@@ -1212,7 +1243,23 @@ static inline void xfrm6_fini(void) | |||
1212 | extern int xfrm_proc_init(void); | 1243 | extern int xfrm_proc_init(void); |
1213 | #endif | 1244 | #endif |
1214 | 1245 | ||
1215 | extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); | 1246 | static inline void xfrm_state_walk_init(struct xfrm_state_walk *walk, u8 proto) |
1247 | { | ||
1248 | walk->proto = proto; | ||
1249 | walk->state = NULL; | ||
1250 | walk->count = 0; | ||
1251 | } | ||
1252 | |||
1253 | static inline void xfrm_state_walk_done(struct xfrm_state_walk *walk) | ||
1254 | { | ||
1255 | if (walk->state != NULL) { | ||
1256 | xfrm_state_put(walk->state); | ||
1257 | walk->state = NULL; | ||
1258 | } | ||
1259 | } | ||
1260 | |||
1261 | extern int xfrm_state_walk(struct xfrm_state_walk *walk, | ||
1262 | int (*func)(struct xfrm_state *, int, void*), void *); | ||
1216 | extern struct xfrm_state *xfrm_state_alloc(void); | 1263 | extern struct xfrm_state *xfrm_state_alloc(void); |
1217 | extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | 1264 | extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, |
1218 | struct flowi *fl, struct xfrm_tmpl *tmpl, | 1265 | struct flowi *fl, struct xfrm_tmpl *tmpl, |
@@ -1335,7 +1382,25 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb) | |||
1335 | #endif | 1382 | #endif |
1336 | 1383 | ||
1337 | struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); | 1384 | struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); |
1338 | extern int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, void*), void *); | 1385 | |
1386 | static inline void xfrm_policy_walk_init(struct xfrm_policy_walk *walk, u8 type) | ||
1387 | { | ||
1388 | walk->cur_type = XFRM_POLICY_TYPE_MAIN; | ||
1389 | walk->type = type; | ||
1390 | walk->policy = NULL; | ||
1391 | walk->count = 0; | ||
1392 | } | ||
1393 | |||
1394 | static inline void xfrm_policy_walk_done(struct xfrm_policy_walk *walk) | ||
1395 | { | ||
1396 | if (walk->policy != NULL) { | ||
1397 | xfrm_pol_put(walk->policy); | ||
1398 | walk->policy = NULL; | ||
1399 | } | ||
1400 | } | ||
1401 | |||
1402 | extern int xfrm_policy_walk(struct xfrm_policy_walk *walk, | ||
1403 | int (*func)(struct xfrm_policy *, int, int, void*), void *); | ||
1339 | int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); | 1404 | int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); |
1340 | struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir, | 1405 | struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir, |
1341 | struct xfrm_selector *sel, | 1406 | struct xfrm_selector *sel, |