STRUCT XFRM_POLICY(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ struct xfrm_policy(9) πŸ¦‹

okay so bestie, this is a page from the Kernel API Manual, and it's literally all about struct xfrm_policy β€” the xfrm policy struct itself. no cap, it's kind of the main character of the whole IPsec policy world πŸ’…


✨ NAME ✨

struct xfrm_policy β€” the xfrm policy. that's it, that's the vibe πŸŽ€


🌸 SYNOPSIS 🌸

like, here's the whole struct in all its glory, bestie β€” every single field, exactly as it is, don't @ me:

struct xfrm_policy {
    possible_net_t xp_net;
    struct hlist_node       bydst;
    struct hlist_node       byidx;
    struct hlist_head       state_cache_list;
    rwlock_t lock;
    refcount_t refcnt;
    u32 pos;
    struct timer_list       timer;
    atomic_t genid;
    u32 priority;
    u32 index;
    u32 if_id;
    struct xfrm_mark        mark;
    struct xfrm_selector    selector;
    struct xfrm_lifetime_cfg lft;
    struct xfrm_lifetime_cur curlft;
    struct xfrm_policy_walk_entry walk;
    struct xfrm_policy_queue polq;
    bool bydst_reinsert;
    u8 type;
    u8 action;
    u8 flags;
    u8 xfrm_nr;
    u16 family;
    struct xfrm_sec_ctx     *security;
    struct xfrm_tmpl        xfrm_vec[XFRM_MAX_DEPTH];
    struct rcu_head         rcu;
    struct xfrm_dev_offload xdo;
 };

πŸ’– Members πŸ’–

bestie, here's the member-by-member rundown, in order, no skipping, i promise 🫢

  • xp_net β€” the network namespace this policy lives in. it's giving "whose house is this" energy.
  • bydst β€” hlist node for the SPD hash table or rbtree list.
  • byidx β€” hlist node for the index hash table.
  • state_cache_list β€” hlist head for the policy's cached xfrm states. caching queen ✨
  • lock β€” serializes changes to the policy structure members. one at a time, bestie, we're not animals.
  • refcnt β€” reference count. it gets freed once it reaches 0. like, that's the whole rule πŸ™ˆ
  • pos β€” kernel internal tie-breaker used to determine the age of the policy.
  • timer β€” timer. yes. that's literally it. a timer. iconic minimalism πŸ’€
  • genid β€” generation, used to invalidate old policies. old news gets cancelled, periodt.
  • priority β€” priority, set by userspace.
  • index β€” policy index (autogenerated).
  • if_id β€” virtual xfrm interface id.
  • mark β€” packet mark.
  • selector β€” selector.
  • lft β€” lifetime configuration data.
  • curlft β€” lifetime state.
  • walk β€” list head on the pernet policy list.
  • polq β€” queue to hold packets while an acquire operation is in progress. the "hold my packets" queue πŸ’…
  • bydst_reinsert β€” this policy tree node needs to be merged.
  • type β€” XFRM_POLICY_TYPE_MAIN or _SUB.
  • action β€” XFRM_POLICY_ALLOW or _BLOCK.
  • flags β€” XFRM_POLICY_LOCALOK, XFRM_POLICY_ICMP.
  • xfrm_nr β€” number of used templates in xfrm_vec.
  • family β€” protocol family.
  • security β€” SELinux security label. keeping it secure and cute πŸ”₯
  • xfrm_vec β€” array of templates to resolve state.
  • rcu β€” rcu head, used to defer memory release. bye bestie, but like, later πŸ‘‹
  • xdo β€” hardware offload state.

🌈 SEE ALSO 🌈

  • Kernel file ./include/net/xfrm.h
  • struct xfrm_mode_cbs(9)

and that's the whole page, bestie! πŸŽ€ this one came from ./include/net, dated October 2026 β€” so like, mark your calendars, mwah πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from