.. | .. |
---|
15 | 15 | #include <linux/audit.h> |
---|
16 | 16 | #include <linux/slab.h> |
---|
17 | 17 | #include <linux/refcount.h> |
---|
| 18 | +#include <linux/sockptr.h> |
---|
18 | 19 | |
---|
19 | 20 | #include <net/sock.h> |
---|
20 | 21 | #include <net/dst.h> |
---|
.. | .. |
---|
127 | 128 | |
---|
128 | 129 | struct xfrm_state_offload { |
---|
129 | 130 | struct net_device *dev; |
---|
| 131 | + struct net_device *real_dev; |
---|
130 | 132 | unsigned long offload_handle; |
---|
131 | 133 | unsigned int num_exthdrs; |
---|
132 | 134 | u8 flags; |
---|
| 135 | +}; |
---|
| 136 | + |
---|
| 137 | +struct xfrm_mode { |
---|
| 138 | + u8 encap; |
---|
| 139 | + u8 family; |
---|
| 140 | + u8 flags; |
---|
| 141 | +}; |
---|
| 142 | + |
---|
| 143 | +/* Flags for xfrm_mode. */ |
---|
| 144 | +enum { |
---|
| 145 | + XFRM_MODE_FLAG_TUNNEL = 1, |
---|
133 | 146 | }; |
---|
134 | 147 | |
---|
135 | 148 | /* Full description of state of transformer. */ |
---|
.. | .. |
---|
182 | 195 | |
---|
183 | 196 | /* Data for encapsulator */ |
---|
184 | 197 | struct xfrm_encap_tmpl *encap; |
---|
| 198 | + struct sock __rcu *encap_sk; |
---|
185 | 199 | |
---|
186 | 200 | /* Data for care-of address */ |
---|
187 | 201 | xfrm_address_t *coaddr; |
---|
.. | .. |
---|
219 | 233 | struct xfrm_stats stats; |
---|
220 | 234 | |
---|
221 | 235 | struct xfrm_lifetime_cur curlft; |
---|
222 | | - struct tasklet_hrtimer mtimer; |
---|
| 236 | + struct hrtimer mtimer; |
---|
223 | 237 | |
---|
224 | 238 | struct xfrm_state_offload xso; |
---|
225 | 239 | |
---|
.. | .. |
---|
234 | 248 | /* Reference to data common to all the instances of this |
---|
235 | 249 | * transformer. */ |
---|
236 | 250 | const struct xfrm_type *type; |
---|
237 | | - struct xfrm_mode *inner_mode; |
---|
238 | | - struct xfrm_mode *inner_mode_iaf; |
---|
239 | | - struct xfrm_mode *outer_mode; |
---|
| 251 | + struct xfrm_mode inner_mode; |
---|
| 252 | + struct xfrm_mode inner_mode_iaf; |
---|
| 253 | + struct xfrm_mode outer_mode; |
---|
240 | 254 | |
---|
241 | 255 | const struct xfrm_type_offload *type_offload; |
---|
242 | 256 | |
---|
.. | .. |
---|
316 | 330 | xfrm_address_t *saddr, |
---|
317 | 331 | xfrm_address_t *daddr, |
---|
318 | 332 | u32 mark); |
---|
319 | | - void (*decode_session)(struct sk_buff *skb, |
---|
320 | | - struct flowi *fl, |
---|
321 | | - int reverse); |
---|
322 | | - int (*get_tos)(const struct flowi *fl); |
---|
323 | | - int (*init_path)(struct xfrm_dst *path, |
---|
324 | | - struct dst_entry *dst, |
---|
325 | | - int nfheader_len); |
---|
326 | 333 | int (*fill_dst)(struct xfrm_dst *xdst, |
---|
327 | 334 | struct net_device *dev, |
---|
328 | 335 | const struct flowi *fl); |
---|
.. | .. |
---|
342 | 349 | int __xfrm_state_delete(struct xfrm_state *x); |
---|
343 | 350 | |
---|
344 | 351 | struct xfrm_state_afinfo { |
---|
345 | | - unsigned int family; |
---|
346 | | - unsigned int proto; |
---|
347 | | - __be16 eth_proto; |
---|
348 | | - struct module *owner; |
---|
349 | | - const struct xfrm_type *type_map[IPPROTO_MAX]; |
---|
350 | | - const struct xfrm_type_offload *type_offload_map[IPPROTO_MAX]; |
---|
351 | | - struct xfrm_mode *mode_map[XFRM_MODE_MAX]; |
---|
| 352 | + u8 family; |
---|
| 353 | + u8 proto; |
---|
352 | 354 | |
---|
353 | | - int (*init_flags)(struct xfrm_state *x); |
---|
354 | | - void (*init_tempsel)(struct xfrm_selector *sel, |
---|
355 | | - const struct flowi *fl); |
---|
356 | | - void (*init_temprop)(struct xfrm_state *x, |
---|
357 | | - const struct xfrm_tmpl *tmpl, |
---|
358 | | - const xfrm_address_t *daddr, |
---|
359 | | - const xfrm_address_t *saddr); |
---|
360 | | - int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); |
---|
361 | | - int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); |
---|
| 355 | + const struct xfrm_type_offload *type_offload_esp; |
---|
| 356 | + |
---|
| 357 | + const struct xfrm_type *type_esp; |
---|
| 358 | + const struct xfrm_type *type_ipip; |
---|
| 359 | + const struct xfrm_type *type_ipip6; |
---|
| 360 | + const struct xfrm_type *type_comp; |
---|
| 361 | + const struct xfrm_type *type_ah; |
---|
| 362 | + const struct xfrm_type *type_routing; |
---|
| 363 | + const struct xfrm_type *type_dstopts; |
---|
| 364 | + |
---|
362 | 365 | int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb); |
---|
363 | | - int (*output_finish)(struct sock *sk, struct sk_buff *skb); |
---|
364 | | - int (*extract_input)(struct xfrm_state *x, |
---|
365 | | - struct sk_buff *skb); |
---|
366 | | - int (*extract_output)(struct xfrm_state *x, |
---|
367 | | - struct sk_buff *skb); |
---|
368 | 366 | int (*transport_finish)(struct sk_buff *skb, |
---|
369 | 367 | int async); |
---|
370 | 368 | void (*local_error)(struct sk_buff *skb, u32 mtu); |
---|
.. | .. |
---|
376 | 374 | struct xfrm_state_afinfo *xfrm_state_afinfo_get_rcu(unsigned int family); |
---|
377 | 375 | |
---|
378 | 376 | struct xfrm_input_afinfo { |
---|
379 | | - unsigned int family; |
---|
| 377 | + u8 family; |
---|
| 378 | + bool is_ipip; |
---|
380 | 379 | int (*callback)(struct sk_buff *skb, u8 protocol, |
---|
381 | 380 | int err); |
---|
382 | 381 | }; |
---|
.. | .. |
---|
404 | 403 | int (*reject)(struct xfrm_state *, struct sk_buff *, |
---|
405 | 404 | const struct flowi *); |
---|
406 | 405 | int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); |
---|
407 | | - /* Estimate maximal size of result of transformation of a dgram */ |
---|
408 | | - u32 (*get_mtu)(struct xfrm_state *, int size); |
---|
409 | 406 | }; |
---|
410 | 407 | |
---|
411 | 408 | int xfrm_register_type(const struct xfrm_type *type, unsigned short family); |
---|
412 | | -int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family); |
---|
| 409 | +void xfrm_unregister_type(const struct xfrm_type *type, unsigned short family); |
---|
413 | 410 | |
---|
414 | 411 | struct xfrm_type_offload { |
---|
415 | 412 | char *description; |
---|
.. | .. |
---|
421 | 418 | }; |
---|
422 | 419 | |
---|
423 | 420 | int xfrm_register_type_offload(const struct xfrm_type_offload *type, unsigned short family); |
---|
424 | | -int xfrm_unregister_type_offload(const struct xfrm_type_offload *type, unsigned short family); |
---|
425 | | - |
---|
426 | | -struct xfrm_mode { |
---|
427 | | - /* |
---|
428 | | - * Remove encapsulation header. |
---|
429 | | - * |
---|
430 | | - * The IP header will be moved over the top of the encapsulation |
---|
431 | | - * header. |
---|
432 | | - * |
---|
433 | | - * On entry, the transport header shall point to where the IP header |
---|
434 | | - * should be and the network header shall be set to where the IP |
---|
435 | | - * header currently is. skb->data shall point to the start of the |
---|
436 | | - * payload. |
---|
437 | | - */ |
---|
438 | | - int (*input2)(struct xfrm_state *x, struct sk_buff *skb); |
---|
439 | | - |
---|
440 | | - /* |
---|
441 | | - * This is the actual input entry point. |
---|
442 | | - * |
---|
443 | | - * For transport mode and equivalent this would be identical to |
---|
444 | | - * input2 (which does not need to be set). While tunnel mode |
---|
445 | | - * and equivalent would set this to the tunnel encapsulation function |
---|
446 | | - * xfrm4_prepare_input that would in turn call input2. |
---|
447 | | - */ |
---|
448 | | - int (*input)(struct xfrm_state *x, struct sk_buff *skb); |
---|
449 | | - |
---|
450 | | - /* |
---|
451 | | - * Add encapsulation header. |
---|
452 | | - * |
---|
453 | | - * On exit, the transport header will be set to the start of the |
---|
454 | | - * encapsulation header to be filled in by x->type->output and |
---|
455 | | - * the mac header will be set to the nextheader (protocol for |
---|
456 | | - * IPv4) field of the extension header directly preceding the |
---|
457 | | - * encapsulation header, or in its absence, that of the top IP |
---|
458 | | - * header. The value of the network header will always point |
---|
459 | | - * to the top IP header while skb->data will point to the payload. |
---|
460 | | - */ |
---|
461 | | - int (*output2)(struct xfrm_state *x,struct sk_buff *skb); |
---|
462 | | - |
---|
463 | | - /* |
---|
464 | | - * This is the actual output entry point. |
---|
465 | | - * |
---|
466 | | - * For transport mode and equivalent this would be identical to |
---|
467 | | - * output2 (which does not need to be set). While tunnel mode |
---|
468 | | - * and equivalent would set this to a tunnel encapsulation function |
---|
469 | | - * (xfrm4_prepare_output or xfrm6_prepare_output) that would in turn |
---|
470 | | - * call output2. |
---|
471 | | - */ |
---|
472 | | - int (*output)(struct xfrm_state *x, struct sk_buff *skb); |
---|
473 | | - |
---|
474 | | - /* |
---|
475 | | - * Adjust pointers into the packet and do GSO segmentation. |
---|
476 | | - */ |
---|
477 | | - struct sk_buff *(*gso_segment)(struct xfrm_state *x, struct sk_buff *skb, netdev_features_t features); |
---|
478 | | - |
---|
479 | | - /* |
---|
480 | | - * Adjust pointers into the packet when IPsec is done at layer2. |
---|
481 | | - */ |
---|
482 | | - void (*xmit)(struct xfrm_state *x, struct sk_buff *skb); |
---|
483 | | - |
---|
484 | | - struct xfrm_state_afinfo *afinfo; |
---|
485 | | - struct module *owner; |
---|
486 | | - unsigned int encap; |
---|
487 | | - int flags; |
---|
488 | | -}; |
---|
489 | | - |
---|
490 | | -/* Flags for xfrm_mode. */ |
---|
491 | | -enum { |
---|
492 | | - XFRM_MODE_FLAG_TUNNEL = 1, |
---|
493 | | -}; |
---|
494 | | - |
---|
495 | | -int xfrm_register_mode(struct xfrm_mode *mode, int family); |
---|
496 | | -int xfrm_unregister_mode(struct xfrm_mode *mode, int family); |
---|
| 421 | +void xfrm_unregister_type_offload(const struct xfrm_type_offload *type, unsigned short family); |
---|
497 | 422 | |
---|
498 | 423 | static inline int xfrm_af2proto(unsigned int family) |
---|
499 | 424 | { |
---|
.. | .. |
---|
507 | 432 | } |
---|
508 | 433 | } |
---|
509 | 434 | |
---|
510 | | -static inline struct xfrm_mode *xfrm_ip2inner_mode(struct xfrm_state *x, int ipproto) |
---|
| 435 | +static inline const struct xfrm_mode *xfrm_ip2inner_mode(struct xfrm_state *x, int ipproto) |
---|
511 | 436 | { |
---|
512 | 437 | if ((ipproto == IPPROTO_IPIP && x->props.family == AF_INET) || |
---|
513 | 438 | (ipproto == IPPROTO_IPV6 && x->props.family == AF_INET6)) |
---|
514 | | - return x->inner_mode; |
---|
| 439 | + return &x->inner_mode; |
---|
515 | 440 | else |
---|
516 | | - return x->inner_mode_iaf; |
---|
| 441 | + return &x->inner_mode_iaf; |
---|
517 | 442 | } |
---|
518 | 443 | |
---|
519 | 444 | struct xfrm_tmpl { |
---|
.. | .. |
---|
578 | 503 | /* This lock only affects elements except for entry. */ |
---|
579 | 504 | rwlock_t lock; |
---|
580 | 505 | refcount_t refcnt; |
---|
| 506 | + u32 pos; |
---|
581 | 507 | struct timer_list timer; |
---|
582 | 508 | |
---|
583 | 509 | atomic_t genid; |
---|
.. | .. |
---|
590 | 516 | struct xfrm_lifetime_cur curlft; |
---|
591 | 517 | struct xfrm_policy_walk_entry walk; |
---|
592 | 518 | struct xfrm_policy_queue polq; |
---|
| 519 | + bool bydst_reinsert; |
---|
593 | 520 | u8 type; |
---|
594 | 521 | u8 action; |
---|
595 | 522 | u8 flags; |
---|
.. | .. |
---|
597 | 524 | u16 family; |
---|
598 | 525 | struct xfrm_sec_ctx *security; |
---|
599 | 526 | struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; |
---|
| 527 | + struct hlist_node bydst_inexact_list; |
---|
600 | 528 | struct rcu_head rcu; |
---|
601 | 529 | }; |
---|
602 | 530 | |
---|
.. | .. |
---|
1099 | 1027 | }; |
---|
1100 | 1028 | |
---|
1101 | 1029 | struct sec_path { |
---|
1102 | | - refcount_t refcnt; |
---|
1103 | 1030 | int len; |
---|
1104 | 1031 | int olen; |
---|
| 1032 | + int verified_cnt; |
---|
1105 | 1033 | |
---|
1106 | 1034 | struct xfrm_state *xvec[XFRM_MAX_DEPTH]; |
---|
1107 | 1035 | struct xfrm_offload ovec[XFRM_MAX_OFFLOAD_DEPTH]; |
---|
1108 | 1036 | }; |
---|
1109 | 1037 | |
---|
1110 | | -static inline int secpath_exists(struct sk_buff *skb) |
---|
1111 | | -{ |
---|
1112 | | -#ifdef CONFIG_XFRM |
---|
1113 | | - return skb->sp != NULL; |
---|
1114 | | -#else |
---|
1115 | | - return 0; |
---|
1116 | | -#endif |
---|
1117 | | -} |
---|
1118 | | - |
---|
1119 | | -static inline struct sec_path * |
---|
1120 | | -secpath_get(struct sec_path *sp) |
---|
1121 | | -{ |
---|
1122 | | - if (sp) |
---|
1123 | | - refcount_inc(&sp->refcnt); |
---|
1124 | | - return sp; |
---|
1125 | | -} |
---|
1126 | | - |
---|
1127 | | -void __secpath_destroy(struct sec_path *sp); |
---|
1128 | | - |
---|
1129 | | -static inline void |
---|
1130 | | -secpath_put(struct sec_path *sp) |
---|
1131 | | -{ |
---|
1132 | | - if (sp && refcount_dec_and_test(&sp->refcnt)) |
---|
1133 | | - __secpath_destroy(sp); |
---|
1134 | | -} |
---|
1135 | | - |
---|
1136 | | -struct sec_path *secpath_dup(struct sec_path *src); |
---|
1137 | | -int secpath_set(struct sk_buff *skb); |
---|
| 1038 | +struct sec_path *secpath_set(struct sk_buff *skb); |
---|
1138 | 1039 | |
---|
1139 | 1040 | static inline void |
---|
1140 | 1041 | secpath_reset(struct sk_buff *skb) |
---|
1141 | 1042 | { |
---|
1142 | 1043 | #ifdef CONFIG_XFRM |
---|
1143 | | - secpath_put(skb->sp); |
---|
1144 | | - skb->sp = NULL; |
---|
| 1044 | + skb_ext_del(skb, SKB_EXT_SEC_PATH); |
---|
1145 | 1045 | #endif |
---|
1146 | 1046 | } |
---|
1147 | 1047 | |
---|
.. | .. |
---|
1197 | 1097 | if (sk && sk->sk_policy[XFRM_POLICY_IN]) |
---|
1198 | 1098 | return __xfrm_policy_check(sk, ndir, skb, family); |
---|
1199 | 1099 | |
---|
1200 | | - return (!net->xfrm.policy_count[dir] && !skb->sp) || |
---|
1201 | | - (skb_dst(skb)->flags & DST_NOPOLICY) || |
---|
| 1100 | + return (!net->xfrm.policy_count[dir] && !secpath_exists(skb)) || |
---|
| 1101 | + (skb_dst(skb) && (skb_dst(skb)->flags & DST_NOPOLICY)) || |
---|
1202 | 1102 | __xfrm_policy_check(sk, ndir, skb, family); |
---|
1203 | 1103 | } |
---|
1204 | 1104 | |
---|
.. | .. |
---|
1506 | 1406 | |
---|
1507 | 1407 | struct xfrm6_protocol { |
---|
1508 | 1408 | int (*handler)(struct sk_buff *skb); |
---|
| 1409 | + int (*input_handler)(struct sk_buff *skb, int nexthdr, __be32 spi, |
---|
| 1410 | + int encap_type); |
---|
1509 | 1411 | int (*cb_handler)(struct sk_buff *skb, int err); |
---|
1510 | 1412 | int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt, |
---|
1511 | 1413 | u8 type, u8 code, int offset, __be32 info); |
---|
.. | .. |
---|
1517 | 1419 | /* XFRM tunnel handlers. */ |
---|
1518 | 1420 | struct xfrm_tunnel { |
---|
1519 | 1421 | int (*handler)(struct sk_buff *skb); |
---|
| 1422 | + int (*cb_handler)(struct sk_buff *skb, int err); |
---|
1520 | 1423 | int (*err_handler)(struct sk_buff *skb, u32 info); |
---|
1521 | 1424 | |
---|
1522 | 1425 | struct xfrm_tunnel __rcu *next; |
---|
.. | .. |
---|
1525 | 1428 | |
---|
1526 | 1429 | struct xfrm6_tunnel { |
---|
1527 | 1430 | int (*handler)(struct sk_buff *skb); |
---|
| 1431 | + int (*cb_handler)(struct sk_buff *skb, int err); |
---|
1528 | 1432 | int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt, |
---|
1529 | 1433 | u8 type, u8 code, int offset, __be32 info); |
---|
1530 | 1434 | struct xfrm6_tunnel __rcu *next; |
---|
.. | .. |
---|
1602 | 1506 | u8 proto, |
---|
1603 | 1507 | unsigned short family); |
---|
1604 | 1508 | #ifdef CONFIG_XFRM_SUB_POLICY |
---|
1605 | | -int xfrm_tmpl_sort(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n, |
---|
1606 | | - unsigned short family, struct net *net); |
---|
1607 | | -int xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **src, int n, |
---|
| 1509 | +void xfrm_tmpl_sort(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n, |
---|
1608 | 1510 | unsigned short family); |
---|
| 1511 | +void xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **src, int n, |
---|
| 1512 | + unsigned short family); |
---|
1609 | 1513 | #else |
---|
1610 | | -static inline int xfrm_tmpl_sort(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, |
---|
1611 | | - int n, unsigned short family, struct net *net) |
---|
1612 | | -{ |
---|
1613 | | - return -ENOSYS; |
---|
1614 | | -} |
---|
1615 | | - |
---|
1616 | | -static inline int xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **src, |
---|
| 1514 | +static inline void xfrm_tmpl_sort(struct xfrm_tmpl **d, struct xfrm_tmpl **s, |
---|
1617 | 1515 | int n, unsigned short family) |
---|
1618 | 1516 | { |
---|
1619 | | - return -ENOSYS; |
---|
| 1517 | +} |
---|
| 1518 | + |
---|
| 1519 | +static inline void xfrm_state_sort(struct xfrm_state **d, struct xfrm_state **s, |
---|
| 1520 | + int n, unsigned short family) |
---|
| 1521 | +{ |
---|
1620 | 1522 | } |
---|
1621 | 1523 | #endif |
---|
1622 | 1524 | |
---|
.. | .. |
---|
1645 | 1547 | void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si); |
---|
1646 | 1548 | u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq); |
---|
1647 | 1549 | int xfrm_init_replay(struct xfrm_state *x); |
---|
1648 | | -int xfrm_state_mtu(struct xfrm_state *x, int mtu); |
---|
| 1550 | +u32 xfrm_state_mtu(struct xfrm_state *x, int mtu); |
---|
1649 | 1551 | int __xfrm_init_state(struct xfrm_state *x, bool init_replay, bool offload); |
---|
1650 | 1552 | int xfrm_init_state(struct xfrm_state *x); |
---|
1651 | | -int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb); |
---|
1652 | 1553 | int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type); |
---|
1653 | 1554 | int xfrm_input_resume(struct sk_buff *skb, int nexthdr); |
---|
| 1555 | +int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb, |
---|
| 1556 | + int (*finish)(struct net *, struct sock *, |
---|
| 1557 | + struct sk_buff *)); |
---|
1654 | 1558 | int xfrm_trans_queue(struct sk_buff *skb, |
---|
1655 | 1559 | int (*finish)(struct net *, struct sock *, |
---|
1656 | 1560 | struct sk_buff *)); |
---|
1657 | 1561 | int xfrm_output_resume(struct sk_buff *skb, int err); |
---|
1658 | 1562 | int xfrm_output(struct sock *sk, struct sk_buff *skb); |
---|
1659 | | -int xfrm_inner_extract_output(struct xfrm_state *x, struct sk_buff *skb); |
---|
| 1563 | + |
---|
| 1564 | +int pktgen_xfrm_outer_mode_output(struct xfrm_state *x, struct sk_buff *skb); |
---|
| 1565 | + |
---|
1660 | 1566 | void xfrm_local_error(struct sk_buff *skb, int mtu); |
---|
1661 | | -int xfrm4_extract_header(struct sk_buff *skb); |
---|
1662 | 1567 | int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb); |
---|
1663 | 1568 | int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, |
---|
1664 | 1569 | int encap_type); |
---|
.. | .. |
---|
1674 | 1579 | return xfrm_input(skb, nexthdr, spi, 0); |
---|
1675 | 1580 | } |
---|
1676 | 1581 | |
---|
1677 | | -int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); |
---|
1678 | | -int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); |
---|
1679 | 1582 | int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb); |
---|
1680 | 1583 | int xfrm4_output_finish(struct sock *sk, struct sk_buff *skb); |
---|
1681 | | -int xfrm4_rcv_cb(struct sk_buff *skb, u8 protocol, int err); |
---|
1682 | 1584 | int xfrm4_protocol_register(struct xfrm4_protocol *handler, unsigned char protocol); |
---|
1683 | 1585 | int xfrm4_protocol_deregister(struct xfrm4_protocol *handler, unsigned char protocol); |
---|
1684 | 1586 | int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); |
---|
1685 | 1587 | int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); |
---|
1686 | 1588 | void xfrm4_local_error(struct sk_buff *skb, u32 mtu); |
---|
1687 | | -int xfrm6_extract_header(struct sk_buff *skb); |
---|
1688 | 1589 | int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb); |
---|
1689 | 1590 | int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi, |
---|
1690 | 1591 | struct ip6_tnl *t); |
---|
| 1592 | +int xfrm6_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, |
---|
| 1593 | + int encap_type); |
---|
1691 | 1594 | int xfrm6_transport_finish(struct sk_buff *skb, int async); |
---|
1692 | 1595 | int xfrm6_rcv_tnl(struct sk_buff *skb, struct ip6_tnl *t); |
---|
1693 | 1596 | int xfrm6_rcv(struct sk_buff *skb); |
---|
1694 | 1597 | int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, |
---|
1695 | 1598 | xfrm_address_t *saddr, u8 proto); |
---|
1696 | 1599 | void xfrm6_local_error(struct sk_buff *skb, u32 mtu); |
---|
1697 | | -int xfrm6_rcv_cb(struct sk_buff *skb, u8 protocol, int err); |
---|
1698 | 1600 | int xfrm6_protocol_register(struct xfrm6_protocol *handler, unsigned char protocol); |
---|
1699 | 1601 | int xfrm6_protocol_deregister(struct xfrm6_protocol *handler, unsigned char protocol); |
---|
1700 | 1602 | int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family); |
---|
1701 | 1603 | int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family); |
---|
1702 | 1604 | __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr); |
---|
1703 | 1605 | __be32 xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr); |
---|
1704 | | -int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); |
---|
1705 | | -int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); |
---|
1706 | 1606 | int xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb); |
---|
1707 | 1607 | int xfrm6_output_finish(struct sock *sk, struct sk_buff *skb); |
---|
1708 | 1608 | int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, |
---|
1709 | 1609 | u8 **prevhdr); |
---|
1710 | 1610 | |
---|
1711 | 1611 | #ifdef CONFIG_XFRM |
---|
| 1612 | +void xfrm6_local_rxpmtu(struct sk_buff *skb, u32 mtu); |
---|
1712 | 1613 | int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); |
---|
1713 | | -int xfrm_user_policy(struct sock *sk, int optname, |
---|
1714 | | - u8 __user *optval, int optlen); |
---|
| 1614 | +int xfrm6_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); |
---|
| 1615 | +int xfrm_user_policy(struct sock *sk, int optname, sockptr_t optval, |
---|
| 1616 | + int optlen); |
---|
1715 | 1617 | #else |
---|
1716 | | -static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) |
---|
| 1618 | +static inline int xfrm_user_policy(struct sock *sk, int optname, |
---|
| 1619 | + sockptr_t optval, int optlen) |
---|
1717 | 1620 | { |
---|
1718 | 1621 | return -ENOPROTOOPT; |
---|
1719 | | -} |
---|
1720 | | - |
---|
1721 | | -static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb) |
---|
1722 | | -{ |
---|
1723 | | - /* should not happen */ |
---|
1724 | | - kfree_skb(skb); |
---|
1725 | | - return 0; |
---|
1726 | 1622 | } |
---|
1727 | 1623 | #endif |
---|
1728 | 1624 | |
---|
.. | .. |
---|
1739 | 1635 | void *); |
---|
1740 | 1636 | void xfrm_policy_walk_done(struct xfrm_policy_walk *walk, struct net *net); |
---|
1741 | 1637 | int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); |
---|
1742 | | -struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, u32 mark, u32 if_id, |
---|
1743 | | - u8 type, int dir, |
---|
| 1638 | +struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, |
---|
| 1639 | + const struct xfrm_mark *mark, |
---|
| 1640 | + u32 if_id, u8 type, int dir, |
---|
1744 | 1641 | struct xfrm_selector *sel, |
---|
1745 | 1642 | struct xfrm_sec_ctx *ctx, int delete, |
---|
1746 | 1643 | int *err); |
---|
1747 | | -struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u32 if_id, u8, |
---|
1748 | | - int dir, u32 id, int delete, int *err); |
---|
| 1644 | +struct xfrm_policy *xfrm_policy_byid(struct net *net, |
---|
| 1645 | + const struct xfrm_mark *mark, u32 if_id, |
---|
| 1646 | + u8 type, int dir, u32 id, int delete, |
---|
| 1647 | + int *err); |
---|
1749 | 1648 | int xfrm_policy_flush(struct net *net, u8 type, bool task_valid); |
---|
1750 | 1649 | void xfrm_policy_hash_rebuild(struct net *net); |
---|
1751 | 1650 | u32 xfrm_get_acqseq(void); |
---|
.. | .. |
---|
1763 | 1662 | const struct xfrm_migrate *m, int num_bundles, |
---|
1764 | 1663 | const struct xfrm_kmaddress *k, |
---|
1765 | 1664 | const struct xfrm_encap_tmpl *encap); |
---|
1766 | | -struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net); |
---|
| 1665 | +struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net, |
---|
| 1666 | + u32 if_id); |
---|
1767 | 1667 | struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x, |
---|
1768 | 1668 | struct xfrm_migrate *m, |
---|
1769 | 1669 | struct xfrm_encap_tmpl *encap); |
---|
1770 | 1670 | int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, |
---|
1771 | 1671 | struct xfrm_migrate *m, int num_bundles, |
---|
1772 | 1672 | struct xfrm_kmaddress *k, struct net *net, |
---|
1773 | | - struct xfrm_encap_tmpl *encap); |
---|
| 1673 | + struct xfrm_encap_tmpl *encap, u32 if_id); |
---|
1774 | 1674 | #endif |
---|
1775 | 1675 | |
---|
1776 | 1676 | int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); |
---|
.. | .. |
---|
1922 | 1822 | #ifdef CONFIG_XFRM |
---|
1923 | 1823 | static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb) |
---|
1924 | 1824 | { |
---|
1925 | | - return skb->sp->xvec[skb->sp->len - 1]; |
---|
| 1825 | + struct sec_path *sp = skb_sec_path(skb); |
---|
| 1826 | + |
---|
| 1827 | + return sp->xvec[sp->len - 1]; |
---|
1926 | 1828 | } |
---|
1927 | 1829 | #endif |
---|
1928 | 1830 | |
---|
1929 | 1831 | static inline struct xfrm_offload *xfrm_offload(struct sk_buff *skb) |
---|
1930 | 1832 | { |
---|
1931 | 1833 | #ifdef CONFIG_XFRM |
---|
1932 | | - struct sec_path *sp = skb->sp; |
---|
| 1834 | + struct sec_path *sp = skb_sec_path(skb); |
---|
1933 | 1835 | |
---|
1934 | 1836 | if (!sp || !sp->olen || sp->len != sp->olen) |
---|
1935 | 1837 | return NULL; |
---|
.. | .. |
---|
1987 | 1889 | static inline void xfrm_dev_state_free(struct xfrm_state *x) |
---|
1988 | 1890 | { |
---|
1989 | 1891 | struct xfrm_state_offload *xso = &x->xso; |
---|
1990 | | - struct net_device *dev = xso->dev; |
---|
| 1892 | + struct net_device *dev = xso->dev; |
---|
1991 | 1893 | |
---|
1992 | 1894 | if (dev && dev->xfrmdev_ops) { |
---|
1993 | 1895 | if (dev->xfrmdev_ops->xdo_dev_state_free) |
---|
.. | .. |
---|
2088 | 1990 | tunnel = true; |
---|
2089 | 1991 | break; |
---|
2090 | 1992 | } |
---|
2091 | | - if (tunnel && !(x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL)) |
---|
| 1993 | + if (tunnel && !(x->outer_mode.flags & XFRM_MODE_FLAG_TUNNEL)) |
---|
2092 | 1994 | return -EINVAL; |
---|
2093 | 1995 | |
---|
2094 | 1996 | return 0; |
---|
.. | .. |
---|
2127 | 2029 | } |
---|
2128 | 2030 | #endif |
---|
2129 | 2031 | |
---|
| 2032 | +#if IS_ENABLED(CONFIG_IPV6) |
---|
| 2033 | +static inline bool xfrm6_local_dontfrag(const struct sock *sk) |
---|
| 2034 | +{ |
---|
| 2035 | + int proto; |
---|
| 2036 | + |
---|
| 2037 | + if (!sk || sk->sk_family != AF_INET6) |
---|
| 2038 | + return false; |
---|
| 2039 | + |
---|
| 2040 | + proto = sk->sk_protocol; |
---|
| 2041 | + if (proto == IPPROTO_UDP || proto == IPPROTO_RAW) |
---|
| 2042 | + return inet6_sk(sk)->dontfrag; |
---|
| 2043 | + |
---|
| 2044 | + return false; |
---|
| 2045 | +} |
---|
| 2046 | +#endif |
---|
2130 | 2047 | #endif /* _NET_XFRM_H */ |
---|