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.h284
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
41DECLARE_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
37extern struct sock *xfrm_nl; 51extern struct sock *xfrm_nl;
38extern u32 sysctl_xfrm_aevent_etime; 52extern u32 sysctl_xfrm_aevent_etime;
39extern u32 sysctl_xfrm_aevent_rseqth; 53extern 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
244struct net_device;
230struct xfrm_type; 245struct xfrm_type;
231struct xfrm_dst; 246struct xfrm_dst;
232struct xfrm_policy_afinfo { 247struct 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
248extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); 266extern 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
258struct xfrm_state_afinfo { 276struct 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
272extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo); 298extern 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);
299extern int xfrm_unregister_type(struct xfrm_type *type, unsigned short family); 325extern int xfrm_unregister_type(struct xfrm_type *type, unsigned short family);
300 326
301struct xfrm_mode { 327struct 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 */
519struct 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 */
548struct 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 */
458struct xfrm_audit 561struct xfrm_audit
459{ 562{
@@ -462,41 +565,59 @@ struct xfrm_audit
462}; 565};
463 566
464#ifdef CONFIG_AUDITSYSCALL 567#ifdef CONFIG_AUDITSYSCALL
465static inline struct audit_buffer *xfrm_audit_start(u32 auid, u32 sid) 568static 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); 582static 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
487extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, 597extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result,
488 u32 auid, u32 sid); 598 u32 auid, u32 secid);
489extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, 599extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result,
490 u32 auid, u32 sid); 600 u32 auid, u32 secid);
491extern void xfrm_audit_state_add(struct xfrm_state *x, int result, 601extern void xfrm_audit_state_add(struct xfrm_state *x, int result,
492 u32 auid, u32 sid); 602 u32 auid, u32 secid);
493extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, 603extern void xfrm_audit_state_delete(struct xfrm_state *x, int result,
494 u32 auid, u32 sid); 604 u32 auid, u32 secid);
605extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x,
606 struct sk_buff *skb);
607extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family);
608extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family,
609 __be32 net_spi, __be32 net_seq);
610extern 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
502static inline void xfrm_pol_hold(struct xfrm_policy *policy) 623static 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
508extern void __xfrm_policy_destroy(struct xfrm_policy *policy); 629extern void xfrm_policy_destroy(struct xfrm_policy *policy);
509 630
510static inline void xfrm_pol_put(struct xfrm_policy *policy) 631static 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
761extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family); 881extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family);
762 882
763static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family) 883static 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
897static 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
773static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb) 902static 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
783extern int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, unsigned short family); 912static 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
918static 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
924extern int __xfrm_decode_session(struct sk_buff *skb, struct flowi *fl,
925 unsigned int family, int reverse);
926
927static 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
933static 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
784extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family); 940extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family);
785 941
786static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) 942static 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}
1000static inline int xfrm_decode_session_reverse(struct sk_buff *skb,
1001 struct flowi *fl,
1002 unsigned int family)
1003{
1004 return -ENOSYS;
1005}
1006static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir,
1007 struct sk_buff *skb)
1008{
1009 return 1;
1010}
1011static 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
846static __inline__ 1018static __inline__
@@ -981,12 +1153,27 @@ struct xfrm6_tunnel {
981 1153
982extern void xfrm_init(void); 1154extern void xfrm_init(void);
983extern void xfrm4_init(void); 1155extern void xfrm4_init(void);
984extern void xfrm6_init(void);
985extern void xfrm6_fini(void);
986extern void xfrm_state_init(void); 1156extern void xfrm_state_init(void);
987extern void xfrm4_state_init(void); 1157extern void xfrm4_state_init(void);
988extern void xfrm6_state_init(void); 1158#ifdef CONFIG_XFRM
1159extern int xfrm6_init(void);
1160extern void xfrm6_fini(void);
1161extern int xfrm6_state_init(void);
989extern void xfrm6_state_fini(void); 1162extern void xfrm6_state_fini(void);
1163#else
1164static inline int xfrm6_init(void)
1165{
1166 return 0;
1167}
1168static inline void xfrm6_fini(void)
1169{
1170 ;
1171}
1172#endif
1173
1174#ifdef CONFIG_XFRM_STATISTICS
1175extern int xfrm_proc_init(void);
1176#endif
990 1177
991extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); 1178extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *);
992extern struct xfrm_state *xfrm_state_alloc(void); 1179extern struct xfrm_state *xfrm_state_alloc(void);
@@ -1045,14 +1232,23 @@ extern int xfrm_state_delete(struct xfrm_state *x);
1045extern int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info); 1232extern int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info);
1046extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si); 1233extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si);
1047extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si); 1234extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si);
1048extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq); 1235extern int xfrm_replay_check(struct xfrm_state *x,
1236 struct sk_buff *skb, __be32 seq);
1049extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); 1237extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
1050extern void xfrm_replay_notify(struct xfrm_state *x, int event); 1238extern void xfrm_replay_notify(struct xfrm_state *x, int event);
1051extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); 1239extern int xfrm_state_mtu(struct xfrm_state *x, int mtu);
1052extern int xfrm_init_state(struct xfrm_state *x); 1240extern int xfrm_init_state(struct xfrm_state *x);
1241extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb);
1242extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi,
1243 int encap_type);
1244extern int xfrm_input_resume(struct sk_buff *skb, int nexthdr);
1245extern int xfrm_output_resume(struct sk_buff *skb, int err);
1053extern int xfrm_output(struct sk_buff *skb); 1246extern int xfrm_output(struct sk_buff *skb);
1247extern int xfrm4_extract_header(struct sk_buff *skb);
1248extern int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb);
1054extern int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, 1249extern int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi,
1055 int encap_type); 1250 int encap_type);
1251extern int xfrm4_transport_finish(struct sk_buff *skb, int async);
1056extern int xfrm4_rcv(struct sk_buff *skb); 1252extern int xfrm4_rcv(struct sk_buff *skb);
1057 1253
1058static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) 1254static 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
1259extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1260extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1063extern int xfrm4_output(struct sk_buff *skb); 1261extern int xfrm4_output(struct sk_buff *skb);
1064extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); 1262extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family);
1065extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); 1263extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family);
1264extern int xfrm6_extract_header(struct sk_buff *skb);
1265extern int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb);
1066extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi); 1266extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi);
1267extern int xfrm6_transport_finish(struct sk_buff *skb, int async);
1067extern int xfrm6_rcv(struct sk_buff *skb); 1268extern int xfrm6_rcv(struct sk_buff *skb);
1068extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, 1269extern 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
1072extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr); 1273extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr);
1073extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr); 1274extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr);
1074extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr); 1275extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr);
1276extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1277extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1075extern int xfrm6_output(struct sk_buff *skb); 1278extern int xfrm6_output(struct sk_buff *skb);
1076extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, 1279extern 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
1080extern int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); 1283extern int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb);
1081extern int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen); 1284extern int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen);
1082extern int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsigned short family);
1083#else 1285#else
1084static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) 1286static 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
1096static 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
1102struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); 1299struct 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);
1113struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, 1310struct 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);
1116extern int xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info);
1117extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); 1313extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
1118extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, 1314extern 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);
1120extern void xfrm_init_pmtu(struct dst_entry *dst);
1121 1316
1122#ifdef CONFIG_XFRM_MIGRATE 1317#ifdef CONFIG_XFRM_MIGRATE
1123extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1318extern 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
1412static 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 */