|
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,
|
|
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;
|
|
0 commit comments