xfrm policy add/del/update 是通过netlink消息进行的。 其中xfrm_add_policy 用来添加 xfrm policy。
##netlink message type
1 | 163 XFRM_MSG_NEWPOLICY, |
1 | 2290 [XFRM_MSG_NEWPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_add_policy }, |
1 | 501 struct xfrm_policy { |
##Add a policy:
1 | > xfrm_add_policy |
1 | 1363 static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, |
xfrm policy is a hash list array, every element is a hist list. In the list the policies are sorted with increased policy’s priority.
1 | 548 int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) |