• Home
  • Raw
  • Download

Lines Matching full:xp

1525 static void copy_templates(struct xfrm_policy *xp, struct xfrm_user_tmpl *ut,  in copy_templates()  argument
1530 xp->xfrm_nr = nr; in copy_templates()
1532 struct xfrm_tmpl *t = &xp->xfrm_vec[i]; in copy_templates()
1643 static void copy_from_user_policy(struct xfrm_policy *xp, struct xfrm_userpolicy_info *p) in copy_from_user_policy() argument
1645 xp->priority = p->priority; in copy_from_user_policy()
1646 xp->index = p->index; in copy_from_user_policy()
1647 memcpy(&xp->selector, &p->sel, sizeof(xp->selector)); in copy_from_user_policy()
1648 memcpy(&xp->lft, &p->lft, sizeof(xp->lft)); in copy_from_user_policy()
1649 xp->action = p->action; in copy_from_user_policy()
1650 xp->flags = p->flags; in copy_from_user_policy()
1651 xp->family = p->sel.family; in copy_from_user_policy()
1652 /* XXX xp->share = p->share; */ in copy_from_user_policy()
1655 static void copy_to_user_policy(struct xfrm_policy *xp, struct xfrm_userpolicy_info *p, int dir) in copy_to_user_policy() argument
1658 memcpy(&p->sel, &xp->selector, sizeof(p->sel)); in copy_to_user_policy()
1659 memcpy(&p->lft, &xp->lft, sizeof(p->lft)); in copy_to_user_policy()
1660 memcpy(&p->curlft, &xp->curlft, sizeof(p->curlft)); in copy_to_user_policy()
1661 p->priority = xp->priority; in copy_to_user_policy()
1662 p->index = xp->index; in copy_to_user_policy()
1663 p->sel.family = xp->family; in copy_to_user_policy()
1665 p->action = xp->action; in copy_to_user_policy()
1666 p->flags = xp->flags; in copy_to_user_policy()
1667 p->share = XFRM_SHARE_ANY; /* XXX xp->share */ in copy_to_user_policy()
1672 struct xfrm_policy *xp = xfrm_policy_alloc(net, GFP_KERNEL); in xfrm_policy_construct() local
1675 if (!xp) { in xfrm_policy_construct()
1680 copy_from_user_policy(xp, p); in xfrm_policy_construct()
1682 err = copy_from_user_policy_type(&xp->type, attrs); in xfrm_policy_construct()
1686 if (!(err = copy_from_user_tmpl(xp, attrs))) in xfrm_policy_construct()
1687 err = copy_from_user_sec_ctx(xp, attrs); in xfrm_policy_construct()
1691 xfrm_mark_get(attrs, &xp->mark); in xfrm_policy_construct()
1694 xp->if_id = nla_get_u32(attrs[XFRMA_IF_ID]); in xfrm_policy_construct()
1695 if (!xp->if_id) { in xfrm_policy_construct()
1701 return xp; in xfrm_policy_construct()
1704 xp->walk.dead = 1; in xfrm_policy_construct()
1705 xfrm_policy_destroy(xp); in xfrm_policy_construct()
1714 struct xfrm_policy *xp; in xfrm_add_policy() local
1726 xp = xfrm_policy_construct(net, p, attrs, &err); in xfrm_add_policy()
1727 if (!xp) in xfrm_add_policy()
1735 err = xfrm_policy_insert(p->dir, xp, excl); in xfrm_add_policy()
1736 xfrm_audit_policy_add(xp, err ? 0 : 1, true); in xfrm_add_policy()
1739 security_xfrm_policy_free(xp->security); in xfrm_add_policy()
1740 kfree(xp); in xfrm_add_policy()
1747 km_policy_notify(xp, p->dir, &c); in xfrm_add_policy()
1749 xfrm_pol_put(xp); in xfrm_add_policy()
1754 static int copy_to_user_tmpl(struct xfrm_policy *xp, struct sk_buff *skb) in copy_to_user_tmpl() argument
1759 if (xp->xfrm_nr == 0) in copy_to_user_tmpl()
1762 for (i = 0; i < xp->xfrm_nr; i++) { in copy_to_user_tmpl()
1764 struct xfrm_tmpl *kp = &xp->xfrm_vec[i]; in copy_to_user_tmpl()
1780 sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr, vec); in copy_to_user_tmpl()
1791 static inline int copy_to_user_sec_ctx(struct xfrm_policy *xp, struct sk_buff *skb) in copy_to_user_sec_ctx() argument
1793 if (xp->security) in copy_to_user_sec_ctx()
1794 return copy_sec_ctx(xp->security, skb); in copy_to_user_sec_ctx()
1825 static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr) in dump_one_policy() argument
1841 copy_to_user_policy(xp, p, dir); in dump_one_policy()
1842 err = copy_to_user_tmpl(xp, skb); in dump_one_policy()
1844 err = copy_to_user_sec_ctx(xp, skb); in dump_one_policy()
1846 err = copy_to_user_policy_type(xp->type, skb); in dump_one_policy()
1848 err = xfrm_mark_put(skb, &xp->mark); in dump_one_policy()
1850 err = xfrm_if_id_put(skb, xp->if_id); in dump_one_policy()
1907 struct xfrm_policy *xp, in xfrm_policy_netlink() argument
1923 err = dump_one_policy(xp, dir, 0, &info); in xfrm_policy_netlink()
1936 struct xfrm_policy *xp; in xfrm_get_policy() local
1962 xp = xfrm_policy_byid(net, &m, if_id, type, p->dir, in xfrm_get_policy()
1980 xp = xfrm_policy_bysel_ctx(net, &m, if_id, type, p->dir, in xfrm_get_policy()
1984 if (xp == NULL) in xfrm_get_policy()
1990 resp_skb = xfrm_policy_netlink(skb, xp, p->dir, nlh->nlmsg_seq); in xfrm_get_policy()
1998 xfrm_audit_policy_delete(xp, err ? 0 : 1, true); in xfrm_get_policy()
2007 km_policy_notify(xp, p->dir, &c); in xfrm_get_policy()
2011 xfrm_pol_put(xp); in xfrm_get_policy()
2242 struct xfrm_policy *xp; in xfrm_add_pol_expire() local
2264 xp = xfrm_policy_byid(net, &m, if_id, type, p->dir, p->index, in xfrm_add_pol_expire()
2282 xp = xfrm_policy_bysel_ctx(net, &m, if_id, type, p->dir, in xfrm_add_pol_expire()
2286 if (xp == NULL) in xfrm_add_pol_expire()
2289 if (unlikely(xp->walk.dead)) in xfrm_add_pol_expire()
2294 xfrm_policy_delete(xp, p->dir); in xfrm_add_pol_expire()
2295 xfrm_audit_policy_delete(xp, 1, true); in xfrm_add_pol_expire()
2297 km_policy_expired(xp, p->dir, up->hard, nlh->nlmsg_pid); in xfrm_add_pol_expire()
2300 xfrm_pol_put(xp); in xfrm_add_pol_expire()
2342 struct xfrm_policy *xp; in xfrm_add_acquire() local
2364 /* build an XP */ in xfrm_add_acquire()
2365 xp = xfrm_policy_construct(net, &ua->policy, attrs, &err); in xfrm_add_acquire()
2366 if (!xp) in xfrm_add_acquire()
2372 xp->mark.m = x->mark.m = mark.m; in xfrm_add_acquire()
2373 xp->mark.v = x->mark.v = mark.v; in xfrm_add_acquire()
2376 for (i = 0; i < xp->xfrm_nr; i++, ut++) { in xfrm_add_acquire()
2377 struct xfrm_tmpl *t = &xp->xfrm_vec[i]; in xfrm_add_acquire()
2385 err = km_query(x, t, xp); in xfrm_add_acquire()
2390 kfree(xp); in xfrm_add_acquire()
3030 struct xfrm_policy *xp) in xfrm_acquire_msgsize() argument
3033 + nla_total_size(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr) in xfrm_acquire_msgsize()
3040 struct xfrm_tmpl *xt, struct xfrm_policy *xp) in build_acquire() argument
3055 copy_to_user_policy(xp, &ua->policy, XFRM_POLICY_OUT); in build_acquire()
3061 err = copy_to_user_tmpl(xp, skb); in build_acquire()
3065 err = copy_to_user_policy_type(xp->type, skb); in build_acquire()
3067 err = xfrm_mark_put(skb, &xp->mark); in build_acquire()
3069 err = xfrm_if_id_put(skb, xp->if_id); in build_acquire()
3080 struct xfrm_policy *xp) in xfrm_send_acquire() argument
3086 skb = nlmsg_new(xfrm_acquire_msgsize(x, xp), GFP_ATOMIC); in xfrm_send_acquire()
3090 err = build_acquire(skb, x, xt, xp); in xfrm_send_acquire()
3105 struct xfrm_policy *xp; in xfrm_compile_policy() local
3141 xp = xfrm_policy_alloc(net, GFP_ATOMIC); in xfrm_compile_policy()
3142 if (xp == NULL) { in xfrm_compile_policy()
3147 copy_from_user_policy(xp, p); in xfrm_compile_policy()
3148 xp->type = XFRM_POLICY_TYPE_MAIN; in xfrm_compile_policy()
3149 copy_templates(xp, ut, nr); in xfrm_compile_policy()
3153 return xp; in xfrm_compile_policy()
3156 static inline unsigned int xfrm_polexpire_msgsize(struct xfrm_policy *xp) in xfrm_polexpire_msgsize() argument
3159 + nla_total_size(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr) in xfrm_polexpire_msgsize()
3160 + nla_total_size(xfrm_user_sec_ctx_size(xp->security)) in xfrm_polexpire_msgsize()
3165 static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp, in build_polexpire() argument
3178 copy_to_user_policy(xp, &upe->pol, dir); in build_polexpire()
3179 err = copy_to_user_tmpl(xp, skb); in build_polexpire()
3181 err = copy_to_user_sec_ctx(xp, skb); in build_polexpire()
3183 err = copy_to_user_policy_type(xp->type, skb); in build_polexpire()
3185 err = xfrm_mark_put(skb, &xp->mark); in build_polexpire()
3187 err = xfrm_if_id_put(skb, xp->if_id); in build_polexpire()
3198 static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c) in xfrm_exp_policy_notify() argument
3200 struct net *net = xp_net(xp); in xfrm_exp_policy_notify()
3204 skb = nlmsg_new(xfrm_polexpire_msgsize(xp), GFP_ATOMIC); in xfrm_exp_policy_notify()
3208 err = build_polexpire(skb, xp, dir, c); in xfrm_exp_policy_notify()
3214 static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, const struct km_event *c) in xfrm_notify_policy() argument
3216 unsigned int len = nla_total_size(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); in xfrm_notify_policy()
3217 struct net *net = xp_net(xp); in xfrm_notify_policy()
3251 id->index = xp->index; in xfrm_notify_policy()
3253 memcpy(&id->sel, &xp->selector, sizeof(id->sel)); in xfrm_notify_policy()
3263 copy_to_user_policy(xp, p, dir); in xfrm_notify_policy()
3264 err = copy_to_user_tmpl(xp, skb); in xfrm_notify_policy()
3266 err = copy_to_user_policy_type(xp->type, skb); in xfrm_notify_policy()
3268 err = xfrm_mark_put(skb, &xp->mark); in xfrm_notify_policy()
3270 err = xfrm_if_id_put(skb, xp->if_id); in xfrm_notify_policy()
3311 static int xfrm_send_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c) in xfrm_send_policy_notify() argument
3318 return xfrm_notify_policy(xp, dir, c); in xfrm_send_policy_notify()
3322 return xfrm_exp_policy_notify(xp, dir, c); in xfrm_send_policy_notify()