diff options
Diffstat (limited to 'include/net/xfrm.h')
-rw-r--r-- | include/net/xfrm.h | 284 |
1 files changed, 242 insertions, 42 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 1dd20cf17982..5ebb9ba479b1 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -19,6 +19,9 @@ | |||
19 | #include <net/route.h> | 19 | #include <net/route.h> |
20 | #include <net/ipv6.h> | 20 | #include <net/ipv6.h> |
21 | #include <net/ip6_fib.h> | 21 | #include <net/ip6_fib.h> |
22 | #ifdef CONFIG_XFRM_STATISTICS | ||
23 | #include <net/snmp.h> | ||
24 | #endif | ||
22 | 25 | ||
23 | #define XFRM_PROTO_ESP 50 | 26 | #define XFRM_PROTO_ESP 50 |
24 | #define XFRM_PROTO_AH 51 | 27 | #define XFRM_PROTO_AH 51 |
@@ -34,6 +37,17 @@ | |||
34 | #define MODULE_ALIAS_XFRM_TYPE(family, proto) \ | 37 | #define MODULE_ALIAS_XFRM_TYPE(family, proto) \ |
35 | MODULE_ALIAS("xfrm-type-" __stringify(family) "-" __stringify(proto)) | 38 | MODULE_ALIAS("xfrm-type-" __stringify(family) "-" __stringify(proto)) |
36 | 39 | ||
40 | #ifdef CONFIG_XFRM_STATISTICS | ||
41 | DECLARE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); | ||
42 | #define XFRM_INC_STATS(field) SNMP_INC_STATS(xfrm_statistics, field) | ||
43 | #define XFRM_INC_STATS_BH(field) SNMP_INC_STATS_BH(xfrm_statistics, field) | ||
44 | #define XFRM_INC_STATS_USER(field) SNMP_INC_STATS_USER(xfrm_statistics, field) | ||
45 | #else | ||
46 | #define XFRM_INC_STATS(field) | ||
47 | #define XFRM_INC_STATS_BH(field) | ||
48 | #define XFRM_INC_STATS_USER(field) | ||
49 | #endif | ||
50 | |||
37 | extern struct sock *xfrm_nl; | 51 | extern struct sock *xfrm_nl; |
38 | extern u32 sysctl_xfrm_aevent_etime; | 52 | extern u32 sysctl_xfrm_aevent_etime; |
39 | extern u32 sysctl_xfrm_aevent_rseqth; | 53 | extern u32 sysctl_xfrm_aevent_rseqth; |
@@ -183,7 +197,7 @@ struct xfrm_state | |||
183 | struct timer_list timer; | 197 | struct timer_list timer; |
184 | 198 | ||
185 | /* Last used time */ | 199 | /* Last used time */ |
186 | u64 lastused; | 200 | unsigned long lastused; |
187 | 201 | ||
188 | /* Reference to data common to all the instances of this | 202 | /* Reference to data common to all the instances of this |
189 | * transformer. */ | 203 | * transformer. */ |
@@ -227,22 +241,26 @@ struct km_event | |||
227 | u32 event; | 241 | u32 event; |
228 | }; | 242 | }; |
229 | 243 | ||
244 | struct net_device; | ||
230 | struct xfrm_type; | 245 | struct xfrm_type; |
231 | struct xfrm_dst; | 246 | struct xfrm_dst; |
232 | struct xfrm_policy_afinfo { | 247 | struct xfrm_policy_afinfo { |
233 | unsigned short family; | 248 | unsigned short family; |
234 | struct dst_ops *dst_ops; | 249 | struct dst_ops *dst_ops; |
235 | void (*garbage_collect)(void); | 250 | void (*garbage_collect)(void); |
236 | int (*dst_lookup)(struct xfrm_dst **dst, struct flowi *fl); | 251 | struct dst_entry *(*dst_lookup)(int tos, xfrm_address_t *saddr, |
252 | xfrm_address_t *daddr); | ||
237 | int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr); | 253 | int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr); |
238 | struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy); | 254 | struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy); |
239 | int (*bundle_create)(struct xfrm_policy *policy, | ||
240 | struct xfrm_state **xfrm, | ||
241 | int nx, | ||
242 | struct flowi *fl, | ||
243 | struct dst_entry **dst_p); | ||
244 | void (*decode_session)(struct sk_buff *skb, | 255 | void (*decode_session)(struct sk_buff *skb, |
245 | struct flowi *fl); | 256 | struct flowi *fl, |
257 | int reverse); | ||
258 | int (*get_tos)(struct flowi *fl); | ||
259 | int (*init_path)(struct xfrm_dst *path, | ||
260 | struct dst_entry *dst, | ||
261 | int nfheader_len); | ||
262 | int (*fill_dst)(struct xfrm_dst *xdst, | ||
263 | struct net_device *dev); | ||
246 | }; | 264 | }; |
247 | 265 | ||
248 | extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); | 266 | extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); |
@@ -257,6 +275,8 @@ extern int __xfrm_state_delete(struct xfrm_state *x); | |||
257 | 275 | ||
258 | struct xfrm_state_afinfo { | 276 | struct xfrm_state_afinfo { |
259 | unsigned int family; | 277 | unsigned int family; |
278 | unsigned int proto; | ||
279 | unsigned int eth_proto; | ||
260 | struct module *owner; | 280 | struct module *owner; |
261 | struct xfrm_type *type_map[IPPROTO_MAX]; | 281 | struct xfrm_type *type_map[IPPROTO_MAX]; |
262 | struct xfrm_mode *mode_map[XFRM_MODE_MAX]; | 282 | struct xfrm_mode *mode_map[XFRM_MODE_MAX]; |
@@ -267,6 +287,12 @@ struct xfrm_state_afinfo { | |||
267 | int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); | 287 | int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); |
268 | int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); | 288 | int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); |
269 | int (*output)(struct sk_buff *skb); | 289 | int (*output)(struct sk_buff *skb); |
290 | int (*extract_input)(struct xfrm_state *x, | ||
291 | struct sk_buff *skb); | ||
292 | int (*extract_output)(struct xfrm_state *x, | ||
293 | struct sk_buff *skb); | ||
294 | int (*transport_finish)(struct sk_buff *skb, | ||
295 | int async); | ||
270 | }; | 296 | }; |
271 | 297 | ||
272 | extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo); | 298 | extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo); |
@@ -282,6 +308,8 @@ struct xfrm_type | |||
282 | __u8 flags; | 308 | __u8 flags; |
283 | #define XFRM_TYPE_NON_FRAGMENT 1 | 309 | #define XFRM_TYPE_NON_FRAGMENT 1 |
284 | #define XFRM_TYPE_REPLAY_PROT 2 | 310 | #define XFRM_TYPE_REPLAY_PROT 2 |
311 | #define XFRM_TYPE_LOCAL_COADDR 4 | ||
312 | #define XFRM_TYPE_REMOTE_COADDR 8 | ||
285 | 313 | ||
286 | int (*init_state)(struct xfrm_state *x); | 314 | int (*init_state)(struct xfrm_state *x); |
287 | void (*destructor)(struct xfrm_state *); | 315 | void (*destructor)(struct xfrm_state *); |
@@ -289,8 +317,6 @@ struct xfrm_type | |||
289 | int (*output)(struct xfrm_state *, struct sk_buff *pskb); | 317 | int (*output)(struct xfrm_state *, struct sk_buff *pskb); |
290 | int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); | 318 | int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); |
291 | int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); | 319 | int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); |
292 | xfrm_address_t *(*local_addr)(struct xfrm_state *, xfrm_address_t *); | ||
293 | xfrm_address_t *(*remote_addr)(struct xfrm_state *, xfrm_address_t *); | ||
294 | /* Estimate maximal size of result of transformation of a dgram */ | 320 | /* Estimate maximal size of result of transformation of a dgram */ |
295 | u32 (*get_mtu)(struct xfrm_state *, int size); | 321 | u32 (*get_mtu)(struct xfrm_state *, int size); |
296 | }; | 322 | }; |
@@ -299,6 +325,27 @@ extern int xfrm_register_type(struct xfrm_type *type, unsigned short family); | |||
299 | extern int xfrm_unregister_type(struct xfrm_type *type, unsigned short family); | 325 | extern int xfrm_unregister_type(struct xfrm_type *type, unsigned short family); |
300 | 326 | ||
301 | struct xfrm_mode { | 327 | struct xfrm_mode { |
328 | /* | ||
329 | * Remove encapsulation header. | ||
330 | * | ||
331 | * The IP header will be moved over the top of the encapsulation | ||
332 | * header. | ||
333 | * | ||
334 | * On entry, the transport header shall point to where the IP header | ||
335 | * should be and the network header shall be set to where the IP | ||
336 | * header currently is. skb->data shall point to the start of the | ||
337 | * payload. | ||
338 | */ | ||
339 | int (*input2)(struct xfrm_state *x, struct sk_buff *skb); | ||
340 | |||
341 | /* | ||
342 | * This is the actual input entry point. | ||
343 | * | ||
344 | * For transport mode and equivalent this would be identical to | ||
345 | * input2 (which does not need to be set). While tunnel mode | ||
346 | * and equivalent would set this to the tunnel encapsulation function | ||
347 | * xfrm4_prepare_input that would in turn call input2. | ||
348 | */ | ||
302 | int (*input)(struct xfrm_state *x, struct sk_buff *skb); | 349 | int (*input)(struct xfrm_state *x, struct sk_buff *skb); |
303 | 350 | ||
304 | /* | 351 | /* |
@@ -312,7 +359,18 @@ struct xfrm_mode { | |||
312 | * header. The value of the network header will always point | 359 | * header. The value of the network header will always point |
313 | * to the top IP header while skb->data will point to the payload. | 360 | * to the top IP header while skb->data will point to the payload. |
314 | */ | 361 | */ |
315 | int (*output)(struct xfrm_state *x,struct sk_buff *skb); | 362 | int (*output2)(struct xfrm_state *x,struct sk_buff *skb); |
363 | |||
364 | /* | ||
365 | * This is the actual output entry point. | ||
366 | * | ||
367 | * For transport mode and equivalent this would be identical to | ||
368 | * output2 (which does not need to be set). While tunnel mode | ||
369 | * and equivalent would set this to a tunnel encapsulation function | ||
370 | * (xfrm4_prepare_output or xfrm6_prepare_output) that would in turn | ||
371 | * call output2. | ||
372 | */ | ||
373 | int (*output)(struct xfrm_state *x, struct sk_buff *skb); | ||
316 | 374 | ||
317 | struct xfrm_state_afinfo *afinfo; | 375 | struct xfrm_state_afinfo *afinfo; |
318 | struct module *owner; | 376 | struct module *owner; |
@@ -454,6 +512,51 @@ struct xfrm_skb_cb { | |||
454 | 512 | ||
455 | #define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0])) | 513 | #define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0])) |
456 | 514 | ||
515 | /* | ||
516 | * This structure is used by the afinfo prepare_input/prepare_output functions | ||
517 | * to transmit header information to the mode input/output functions. | ||
518 | */ | ||
519 | struct xfrm_mode_skb_cb { | ||
520 | union { | ||
521 | struct inet_skb_parm h4; | ||
522 | struct inet6_skb_parm h6; | ||
523 | } header; | ||
524 | |||
525 | /* Copied from header for IPv4, always set to zero and DF for IPv6. */ | ||
526 | __be16 id; | ||
527 | __be16 frag_off; | ||
528 | |||
529 | /* TOS for IPv4, class for IPv6. */ | ||
530 | u8 tos; | ||
531 | |||
532 | /* TTL for IPv4, hop limitfor IPv6. */ | ||
533 | u8 ttl; | ||
534 | |||
535 | /* Protocol for IPv4, NH for IPv6. */ | ||
536 | u8 protocol; | ||
537 | |||
538 | /* Used by IPv6 only, zero for IPv4. */ | ||
539 | u8 flow_lbl[3]; | ||
540 | }; | ||
541 | |||
542 | #define XFRM_MODE_SKB_CB(__skb) ((struct xfrm_mode_skb_cb *)&((__skb)->cb[0])) | ||
543 | |||
544 | /* | ||
545 | * This structure is used by the input processing to locate the SPI and | ||
546 | * related information. | ||
547 | */ | ||
548 | struct xfrm_spi_skb_cb { | ||
549 | union { | ||
550 | struct inet_skb_parm h4; | ||
551 | struct inet6_skb_parm h6; | ||
552 | } header; | ||
553 | |||
554 | unsigned int daddroff; | ||
555 | unsigned int family; | ||
556 | }; | ||
557 | |||
558 | #define XFRM_SPI_SKB_CB(__skb) ((struct xfrm_spi_skb_cb *)&((__skb)->cb[0])) | ||
559 | |||
457 | /* Audit Information */ | 560 | /* Audit Information */ |
458 | struct xfrm_audit | 561 | struct xfrm_audit |
459 | { | 562 | { |
@@ -462,41 +565,59 @@ struct xfrm_audit | |||
462 | }; | 565 | }; |
463 | 566 | ||
464 | #ifdef CONFIG_AUDITSYSCALL | 567 | #ifdef CONFIG_AUDITSYSCALL |
465 | static inline struct audit_buffer *xfrm_audit_start(u32 auid, u32 sid) | 568 | static inline struct audit_buffer *xfrm_audit_start(const char *op) |
466 | { | 569 | { |
467 | struct audit_buffer *audit_buf = NULL; | 570 | struct audit_buffer *audit_buf = NULL; |
468 | char *secctx; | ||
469 | u32 secctx_len; | ||
470 | 571 | ||
572 | if (audit_enabled == 0) | ||
573 | return NULL; | ||
471 | audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, | 574 | audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, |
472 | AUDIT_MAC_IPSEC_EVENT); | 575 | AUDIT_MAC_IPSEC_EVENT); |
473 | if (audit_buf == NULL) | 576 | if (audit_buf == NULL) |
474 | return NULL; | 577 | return NULL; |
578 | audit_log_format(audit_buf, "op=%s", op); | ||
579 | return audit_buf; | ||
580 | } | ||
475 | 581 | ||
476 | audit_log_format(audit_buf, "auid=%u", auid); | 582 | static inline void xfrm_audit_helper_usrinfo(u32 auid, u32 secid, |
583 | struct audit_buffer *audit_buf) | ||
584 | { | ||
585 | char *secctx; | ||
586 | u32 secctx_len; | ||
477 | 587 | ||
478 | if (sid != 0 && | 588 | audit_log_format(audit_buf, " auid=%u", auid); |
479 | security_secid_to_secctx(sid, &secctx, &secctx_len) == 0) { | 589 | if (secid != 0 && |
590 | security_secid_to_secctx(secid, &secctx, &secctx_len) == 0) { | ||
480 | audit_log_format(audit_buf, " subj=%s", secctx); | 591 | audit_log_format(audit_buf, " subj=%s", secctx); |
481 | security_release_secctx(secctx, secctx_len); | 592 | security_release_secctx(secctx, secctx_len); |
482 | } else | 593 | } else |
483 | audit_log_task_context(audit_buf); | 594 | audit_log_task_context(audit_buf); |
484 | return audit_buf; | ||
485 | } | 595 | } |
486 | 596 | ||
487 | extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, | 597 | extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, |
488 | u32 auid, u32 sid); | 598 | u32 auid, u32 secid); |
489 | extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, | 599 | extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, |
490 | u32 auid, u32 sid); | 600 | u32 auid, u32 secid); |
491 | extern void xfrm_audit_state_add(struct xfrm_state *x, int result, | 601 | extern void xfrm_audit_state_add(struct xfrm_state *x, int result, |
492 | u32 auid, u32 sid); | 602 | u32 auid, u32 secid); |
493 | extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, | 603 | extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, |
494 | u32 auid, u32 sid); | 604 | u32 auid, u32 secid); |
605 | extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, | ||
606 | struct sk_buff *skb); | ||
607 | extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family); | ||
608 | extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family, | ||
609 | __be32 net_spi, __be32 net_seq); | ||
610 | extern void xfrm_audit_state_icvfail(struct xfrm_state *x, | ||
611 | struct sk_buff *skb, u8 proto); | ||
495 | #else | 612 | #else |
496 | #define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0) | 613 | #define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0) |
497 | #define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0) | 614 | #define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0) |
498 | #define xfrm_audit_state_add(x, r, a, s) do { ; } while (0) | 615 | #define xfrm_audit_state_add(x, r, a, s) do { ; } while (0) |
499 | #define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0) | 616 | #define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0) |
617 | #define xfrm_audit_state_replay_overflow(x, s) do { ; } while (0) | ||
618 | #define xfrm_audit_state_notfound_simple(s, f) do { ; } while (0) | ||
619 | #define xfrm_audit_state_notfound(s, f, sp, sq) do { ; } while (0) | ||
620 | #define xfrm_audit_state_icvfail(x, s, p) do { ; } while (0) | ||
500 | #endif /* CONFIG_AUDITSYSCALL */ | 621 | #endif /* CONFIG_AUDITSYSCALL */ |
501 | 622 | ||
502 | static inline void xfrm_pol_hold(struct xfrm_policy *policy) | 623 | static inline void xfrm_pol_hold(struct xfrm_policy *policy) |
@@ -505,12 +626,12 @@ static inline void xfrm_pol_hold(struct xfrm_policy *policy) | |||
505 | atomic_inc(&policy->refcnt); | 626 | atomic_inc(&policy->refcnt); |
506 | } | 627 | } |
507 | 628 | ||
508 | extern void __xfrm_policy_destroy(struct xfrm_policy *policy); | 629 | extern void xfrm_policy_destroy(struct xfrm_policy *policy); |
509 | 630 | ||
510 | static inline void xfrm_pol_put(struct xfrm_policy *policy) | 631 | static inline void xfrm_pol_put(struct xfrm_policy *policy) |
511 | { | 632 | { |
512 | if (atomic_dec_and_test(&policy->refcnt)) | 633 | if (atomic_dec_and_test(&policy->refcnt)) |
513 | __xfrm_policy_destroy(policy); | 634 | xfrm_policy_destroy(policy); |
514 | } | 635 | } |
515 | 636 | ||
516 | #ifdef CONFIG_XFRM_SUB_POLICY | 637 | #ifdef CONFIG_XFRM_SUB_POLICY |
@@ -757,17 +878,25 @@ xfrm_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x, unsigned short | |||
757 | } | 878 | } |
758 | 879 | ||
759 | #ifdef CONFIG_XFRM | 880 | #ifdef CONFIG_XFRM |
760 | |||
761 | extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family); | 881 | extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family); |
762 | 882 | ||
763 | static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family) | 883 | static inline int __xfrm_policy_check2(struct sock *sk, int dir, |
884 | struct sk_buff *skb, | ||
885 | unsigned int family, int reverse) | ||
764 | { | 886 | { |
887 | int ndir = dir | (reverse ? XFRM_POLICY_MASK + 1 : 0); | ||
888 | |||
765 | if (sk && sk->sk_policy[XFRM_POLICY_IN]) | 889 | if (sk && sk->sk_policy[XFRM_POLICY_IN]) |
766 | return __xfrm_policy_check(sk, dir, skb, family); | 890 | return __xfrm_policy_check(sk, ndir, skb, family); |
767 | 891 | ||
768 | return (!xfrm_policy_count[dir] && !skb->sp) || | 892 | return (!xfrm_policy_count[dir] && !skb->sp) || |
769 | (skb->dst->flags & DST_NOPOLICY) || | 893 | (skb->dst->flags & DST_NOPOLICY) || |
770 | __xfrm_policy_check(sk, dir, skb, family); | 894 | __xfrm_policy_check(sk, ndir, skb, family); |
895 | } | ||
896 | |||
897 | static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family) | ||
898 | { | ||
899 | return __xfrm_policy_check2(sk, dir, skb, family, 0); | ||
771 | } | 900 | } |
772 | 901 | ||
773 | static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb) | 902 | static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb) |
@@ -780,7 +909,34 @@ static inline int xfrm6_policy_check(struct sock *sk, int dir, struct sk_buff *s | |||
780 | return xfrm_policy_check(sk, dir, skb, AF_INET6); | 909 | return xfrm_policy_check(sk, dir, skb, AF_INET6); |
781 | } | 910 | } |
782 | 911 | ||
783 | extern int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, unsigned short family); | 912 | static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir, |
913 | struct sk_buff *skb) | ||
914 | { | ||
915 | return __xfrm_policy_check2(sk, dir, skb, AF_INET, 1); | ||
916 | } | ||
917 | |||
918 | static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir, | ||
919 | struct sk_buff *skb) | ||
920 | { | ||
921 | return __xfrm_policy_check2(sk, dir, skb, AF_INET6, 1); | ||
922 | } | ||
923 | |||
924 | extern int __xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, | ||
925 | unsigned int family, int reverse); | ||
926 | |||
927 | static inline int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, | ||
928 | unsigned int family) | ||
929 | { | ||
930 | return __xfrm_decode_session(skb, fl, family, 0); | ||
931 | } | ||
932 | |||
933 | static inline int xfrm_decode_session_reverse(struct sk_buff *skb, | ||
934 | struct flowi *fl, | ||
935 | unsigned int family) | ||
936 | { | ||
937 | return __xfrm_decode_session(skb, fl, family, 1); | ||
938 | } | ||
939 | |||
784 | extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family); | 940 | extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family); |
785 | 941 | ||
786 | static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) | 942 | static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) |
@@ -841,6 +997,22 @@ static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *sk | |||
841 | { | 997 | { |
842 | return 1; | 998 | return 1; |
843 | } | 999 | } |
1000 | static inline int xfrm_decode_session_reverse(struct sk_buff *skb, | ||
1001 | struct flowi *fl, | ||
1002 | unsigned int family) | ||
1003 | { | ||
1004 | return -ENOSYS; | ||
1005 | } | ||
1006 | static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir, | ||
1007 | struct sk_buff *skb) | ||
1008 | { | ||
1009 | return 1; | ||
1010 | } | ||
1011 | static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir, | ||
1012 | struct sk_buff *skb) | ||
1013 | { | ||
1014 | return 1; | ||
1015 | } | ||
844 | #endif | 1016 | #endif |
845 | 1017 | ||
846 | static __inline__ | 1018 | static __inline__ |
@@ -981,12 +1153,27 @@ struct xfrm6_tunnel { | |||
981 | 1153 | ||
982 | extern void xfrm_init(void); | 1154 | extern void xfrm_init(void); |
983 | extern void xfrm4_init(void); | 1155 | extern void xfrm4_init(void); |
984 | extern void xfrm6_init(void); | ||
985 | extern void xfrm6_fini(void); | ||
986 | extern void xfrm_state_init(void); | 1156 | extern void xfrm_state_init(void); |
987 | extern void xfrm4_state_init(void); | 1157 | extern void xfrm4_state_init(void); |
988 | extern void xfrm6_state_init(void); | 1158 | #ifdef CONFIG_XFRM |
1159 | extern int xfrm6_init(void); | ||
1160 | extern void xfrm6_fini(void); | ||
1161 | extern int xfrm6_state_init(void); | ||
989 | extern void xfrm6_state_fini(void); | 1162 | extern void xfrm6_state_fini(void); |
1163 | #else | ||
1164 | static inline int xfrm6_init(void) | ||
1165 | { | ||
1166 | return 0; | ||
1167 | } | ||
1168 | static inline void xfrm6_fini(void) | ||
1169 | { | ||
1170 | ; | ||
1171 | } | ||
1172 | #endif | ||
1173 | |||
1174 | #ifdef CONFIG_XFRM_STATISTICS | ||
1175 | extern int xfrm_proc_init(void); | ||
1176 | #endif | ||
990 | 1177 | ||
991 | extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); | 1178 | extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); |
992 | extern struct xfrm_state *xfrm_state_alloc(void); | 1179 | extern struct xfrm_state *xfrm_state_alloc(void); |
@@ -1045,14 +1232,23 @@ extern int xfrm_state_delete(struct xfrm_state *x); | |||
1045 | extern int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info); | 1232 | extern int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info); |
1046 | extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si); | 1233 | extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si); |
1047 | extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si); | 1234 | extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si); |
1048 | extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq); | 1235 | extern int xfrm_replay_check(struct xfrm_state *x, |
1236 | struct sk_buff *skb, __be32 seq); | ||
1049 | extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); | 1237 | extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); |
1050 | extern void xfrm_replay_notify(struct xfrm_state *x, int event); | 1238 | extern void xfrm_replay_notify(struct xfrm_state *x, int event); |
1051 | extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); | 1239 | extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); |
1052 | extern int xfrm_init_state(struct xfrm_state *x); | 1240 | extern int xfrm_init_state(struct xfrm_state *x); |
1241 | extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb); | ||
1242 | extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, | ||
1243 | int encap_type); | ||
1244 | extern int xfrm_input_resume(struct sk_buff *skb, int nexthdr); | ||
1245 | extern int xfrm_output_resume(struct sk_buff *skb, int err); | ||
1053 | extern int xfrm_output(struct sk_buff *skb); | 1246 | extern int xfrm_output(struct sk_buff *skb); |
1247 | extern int xfrm4_extract_header(struct sk_buff *skb); | ||
1248 | extern int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb); | ||
1054 | extern int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, | 1249 | extern int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, |
1055 | int encap_type); | 1250 | int encap_type); |
1251 | extern int xfrm4_transport_finish(struct sk_buff *skb, int async); | ||
1056 | extern int xfrm4_rcv(struct sk_buff *skb); | 1252 | extern int xfrm4_rcv(struct sk_buff *skb); |
1057 | 1253 | ||
1058 | static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) | 1254 | static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) |
@@ -1060,10 +1256,15 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) | |||
1060 | return xfrm4_rcv_encap(skb, nexthdr, spi, 0); | 1256 | return xfrm4_rcv_encap(skb, nexthdr, spi, 0); |
1061 | } | 1257 | } |
1062 | 1258 | ||
1259 | extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); | ||
1260 | extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); | ||
1063 | extern int xfrm4_output(struct sk_buff *skb); | 1261 | extern int xfrm4_output(struct sk_buff *skb); |
1064 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); | 1262 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); |
1065 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); | 1263 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); |
1264 | extern int xfrm6_extract_header(struct sk_buff *skb); | ||
1265 | extern int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb); | ||
1066 | extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi); | 1266 | extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi); |
1267 | extern int xfrm6_transport_finish(struct sk_buff *skb, int async); | ||
1067 | extern int xfrm6_rcv(struct sk_buff *skb); | 1268 | extern int xfrm6_rcv(struct sk_buff *skb); |
1068 | extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, | 1269 | extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, |
1069 | xfrm_address_t *saddr, u8 proto); | 1270 | xfrm_address_t *saddr, u8 proto); |
@@ -1072,6 +1273,8 @@ extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short | |||
1072 | extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr); | 1273 | extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr); |
1073 | extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr); | 1274 | extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr); |
1074 | extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr); | 1275 | extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr); |
1276 | extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); | ||
1277 | extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); | ||
1075 | extern int xfrm6_output(struct sk_buff *skb); | 1278 | extern int xfrm6_output(struct sk_buff *skb); |
1076 | extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, | 1279 | extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, |
1077 | u8 **prevhdr); | 1280 | u8 **prevhdr); |
@@ -1079,7 +1282,6 @@ extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, | |||
1079 | #ifdef CONFIG_XFRM | 1282 | #ifdef CONFIG_XFRM |
1080 | extern int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); | 1283 | extern int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); |
1081 | extern int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen); | 1284 | extern int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen); |
1082 | extern int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsigned short family); | ||
1083 | #else | 1285 | #else |
1084 | static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) | 1286 | static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) |
1085 | { | 1287 | { |
@@ -1092,11 +1294,6 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb) | |||
1092 | kfree_skb(skb); | 1294 | kfree_skb(skb); |
1093 | return 0; | 1295 | return 0; |
1094 | } | 1296 | } |
1095 | |||
1096 | static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsigned short family) | ||
1097 | { | ||
1098 | return -EINVAL; | ||
1099 | } | ||
1100 | #endif | 1297 | #endif |
1101 | 1298 | ||
1102 | struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); | 1299 | struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); |
@@ -1113,11 +1310,9 @@ extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); | |||
1113 | struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, | 1310 | struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, |
1114 | xfrm_address_t *daddr, xfrm_address_t *saddr, | 1311 | xfrm_address_t *daddr, xfrm_address_t *saddr, |
1115 | int create, unsigned short family); | 1312 | int create, unsigned short family); |
1116 | extern int xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info); | ||
1117 | extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); | 1313 | extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); |
1118 | extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, | 1314 | extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, |
1119 | struct flowi *fl, int family, int strict); | 1315 | struct flowi *fl, int family, int strict); |
1120 | extern void xfrm_init_pmtu(struct dst_entry *dst); | ||
1121 | 1316 | ||
1122 | #ifdef CONFIG_XFRM_MIGRATE | 1317 | #ifdef CONFIG_XFRM_MIGRATE |
1123 | extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, | 1318 | extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, |
@@ -1214,4 +1409,9 @@ static inline void xfrm_states_delete(struct xfrm_state **states, int n) | |||
1214 | } | 1409 | } |
1215 | #endif | 1410 | #endif |
1216 | 1411 | ||
1412 | static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb) | ||
1413 | { | ||
1414 | return skb->sp->xvec[skb->sp->len - 1]; | ||
1415 | } | ||
1416 | |||
1217 | #endif /* _NET_XFRM_H */ | 1417 | #endif /* _NET_XFRM_H */ |