|
67 | 67 | - instance of a transformer, struct xfrm_state (=SA)
|
68 | 68 | - template to clone xfrm_state, struct xfrm_tmpl
|
69 | 69 |
|
70 |
| - SPD is plain linear list of xfrm_policy rules, ordered by priority. |
| 70 | + SPD is organized as hash table (for policies that meet minimum address prefix |
| 71 | + length setting, net->xfrm.policy_hthresh). Other policies are stored in |
| 72 | + lists, sorted into rbtree ordered by destination and source address networks. |
| 73 | + See net/xfrm/xfrm_policy.c for details. |
| 74 | +
|
71 | 75 | (To be compatible with existing pfkeyv2 implementations,
|
72 | 76 | many rules with priority of 0x7fffffff are allowed to exist and
|
73 | 77 | such rules are ordered in an unpredictable way, thanks to bsd folks.)
|
74 | 78 |
|
75 |
| - Lookup is plain linear search until the first match with selector. |
76 |
| -
|
77 | 79 | If "action" is "block", then we prohibit the flow, otherwise:
|
78 | 80 | if "xfrms_nr" is zero, the flow passes untransformed. Otherwise,
|
79 | 81 | policy entry has list of up to XFRM_MAX_DEPTH transformations,
|
80 | 82 | described by templates xfrm_tmpl. Each template is resolved
|
81 | 83 | to a complete xfrm_state (see below) and we pack bundle of transformations
|
82 |
| - to a dst_entry returned to requestor. |
| 84 | + to a dst_entry returned to requester. |
83 | 85 |
|
84 | 86 | dst -. xfrm .-> xfrm_state #1
|
85 | 87 | |---. child .-> dst -. xfrm .-> xfrm_state #2
|
86 | 88 | |---. child .-> dst -. xfrm .-> xfrm_state #3
|
87 | 89 | |---. child .-> NULL
|
88 | 90 |
|
89 |
| - Bundles are cached at xrfm_policy struct (field ->bundles). |
90 |
| -
|
91 | 91 |
|
92 | 92 | Resolution of xrfm_tmpl
|
93 | 93 | -----------------------
|
@@ -526,6 +526,36 @@ struct xfrm_policy_queue {
|
526 | 526 | unsigned long timeout;
|
527 | 527 | };
|
528 | 528 |
|
| 529 | +/** |
| 530 | + * struct xfrm_policy - xfrm policy |
| 531 | + * @xp_net: network namespace the policy lives in |
| 532 | + * @bydst: hlist node for SPD hash table or rbtree list |
| 533 | + * @byidx: hlist node for index hash table |
| 534 | + * @lock: serialize changes to policy structure members |
| 535 | + * @refcnt: reference count, freed once it reaches 0 |
| 536 | + * @pos: kernel internal tie-breaker to determine age of policy |
| 537 | + * @timer: timer |
| 538 | + * @genid: generation, used to invalidate old policies |
| 539 | + * @priority: priority, set by userspace |
| 540 | + * @index: policy index (autogenerated) |
| 541 | + * @if_id: virtual xfrm interface id |
| 542 | + * @mark: packet mark |
| 543 | + * @selector: selector |
| 544 | + * @lft: liftime configuration data |
| 545 | + * @curlft: liftime state |
| 546 | + * @walk: list head on pernet policy list |
| 547 | + * @polq: queue to hold packets while aqcuire operaion in progress |
| 548 | + * @bydst_reinsert: policy tree node needs to be merged |
| 549 | + * @type: XFRM_POLICY_TYPE_MAIN or _SUB |
| 550 | + * @action: XFRM_POLICY_ALLOW or _BLOCK |
| 551 | + * @flags: XFRM_POLICY_LOCALOK, XFRM_POLICY_ICMP |
| 552 | + * @xfrm_nr: number of used templates in @xfrm_vec |
| 553 | + * @family: protocol family |
| 554 | + * @security: SELinux security label |
| 555 | + * @xfrm_vec: array of templates to resolve state |
| 556 | + * @rcu: rcu head, used to defer memory release |
| 557 | + * @xdo: hardware offload state |
| 558 | + */ |
529 | 559 | struct xfrm_policy {
|
530 | 560 | possible_net_t xp_net;
|
531 | 561 | struct hlist_node bydst;
|
@@ -555,7 +585,6 @@ struct xfrm_policy {
|
555 | 585 | u16 family;
|
556 | 586 | struct xfrm_sec_ctx *security;
|
557 | 587 | struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH];
|
558 |
| - struct hlist_node bydst_inexact_list; |
559 | 588 | struct rcu_head rcu;
|
560 | 589 |
|
561 | 590 | struct xfrm_dev_offload xdo;
|
@@ -1016,7 +1045,7 @@ void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev);
|
1016 | 1045 |
|
1017 | 1046 | struct xfrm_if_parms {
|
1018 | 1047 | int link; /* ifindex of underlying L2 interface */
|
1019 |
| - u32 if_id; /* interface identifyer */ |
| 1048 | + u32 if_id; /* interface identifier */ |
1020 | 1049 | bool collect_md;
|
1021 | 1050 | };
|
1022 | 1051 |
|
|
0 commit comments