|
38 | 38 | #define XFRM_PROTO_COMP 108 |
39 | 39 | #define XFRM_PROTO_IPIP 4 |
40 | 40 | #define XFRM_PROTO_IPV6 41 |
| 41 | +#define XFRM_PROTO_IPTFS IPPROTO_AGGFRAG |
41 | 42 | #define XFRM_PROTO_ROUTING IPPROTO_ROUTING |
42 | 43 | #define XFRM_PROTO_DSTOPTS IPPROTO_DSTOPTS |
43 | 44 |
|
@@ -213,6 +214,7 @@ struct xfrm_state { |
213 | 214 | u16 family; |
214 | 215 | xfrm_address_t saddr; |
215 | 216 | int header_len; |
| 217 | + int enc_hdr_len; |
216 | 218 | int trailer_len; |
217 | 219 | u32 extra_flags; |
218 | 220 | struct xfrm_mark smark; |
@@ -303,6 +305,9 @@ struct xfrm_state { |
303 | 305 | * interpreted by xfrm_type methods. */ |
304 | 306 | void *data; |
305 | 307 | u8 dir; |
| 308 | + |
| 309 | + const struct xfrm_mode_cbs *mode_cbs; |
| 310 | + void *mode_data; |
306 | 311 | }; |
307 | 312 |
|
308 | 313 | static inline struct net *xs_net(struct xfrm_state *x) |
@@ -460,6 +465,45 @@ struct xfrm_type_offload { |
460 | 465 | int xfrm_register_type_offload(const struct xfrm_type_offload *type, unsigned short family); |
461 | 466 | void xfrm_unregister_type_offload(const struct xfrm_type_offload *type, unsigned short family); |
462 | 467 |
|
| 468 | +/** |
| 469 | + * struct xfrm_mode_cbs - XFRM mode callbacks |
| 470 | + * @owner: module owner or NULL |
| 471 | + * @init_state: Add/init mode specific state in `xfrm_state *x` |
| 472 | + * @clone_state: Copy mode specific values from `orig` to new state `x` |
| 473 | + * @destroy_state: Cleanup mode specific state from `xfrm_state *x` |
| 474 | + * @user_init: Process mode specific netlink attributes from user |
| 475 | + * @copy_to_user: Add netlink attributes to `attrs` based on state in `x` |
| 476 | + * @sa_len: Return space required to store mode specific netlink attributes |
| 477 | + * @get_inner_mtu: Return avail payload space after removing encap overhead |
| 478 | + * @input: Process received packet from SA using mode |
| 479 | + * @output: Output given packet using mode |
| 480 | + * @prepare_output: Add mode specific encapsulation to packet in skb. On return |
| 481 | + * `transport_header` should point at ESP header, `network_header` should |
| 482 | + * point at outer IP header and `mac_header` should opint at the |
| 483 | + * protocol/nexthdr field of the outer IP. |
| 484 | + * |
| 485 | + * One should examine and understand the specific uses of these callbacks in |
| 486 | + * xfrm for further detail on how and when these functions are called. RTSL. |
| 487 | + */ |
| 488 | +struct xfrm_mode_cbs { |
| 489 | + struct module *owner; |
| 490 | + int (*init_state)(struct xfrm_state *x); |
| 491 | + int (*clone_state)(struct xfrm_state *x, struct xfrm_state *orig); |
| 492 | + void (*destroy_state)(struct xfrm_state *x); |
| 493 | + int (*user_init)(struct net *net, struct xfrm_state *x, |
| 494 | + struct nlattr **attrs, |
| 495 | + struct netlink_ext_ack *extack); |
| 496 | + int (*copy_to_user)(struct xfrm_state *x, struct sk_buff *skb); |
| 497 | + unsigned int (*sa_len)(const struct xfrm_state *x); |
| 498 | + u32 (*get_inner_mtu)(struct xfrm_state *x, int outer_mtu); |
| 499 | + int (*input)(struct xfrm_state *x, struct sk_buff *skb); |
| 500 | + int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb); |
| 501 | + int (*prepare_output)(struct xfrm_state *x, struct sk_buff *skb); |
| 502 | +}; |
| 503 | + |
| 504 | +int xfrm_register_mode_cbs(u8 mode, const struct xfrm_mode_cbs *mode_cbs); |
| 505 | +void xfrm_unregister_mode_cbs(u8 mode); |
| 506 | + |
463 | 507 | static inline int xfrm_af2proto(unsigned int family) |
464 | 508 | { |
465 | 509 | switch(family) { |
|
0 commit comments