Lines Matching refs:xp

1909 static int check_reqid(struct xfrm_policy *xp, int dir, int count, void *ptr)  in check_reqid()  argument
1914 for (i=0; i<xp->xfrm_nr; i++) { in check_reqid()
1915 if (xp->xfrm_vec[i].reqid == reqid) in check_reqid()
1943 parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_ipsecrequest *rq) in parse_ipsecrequest() argument
1945 struct net *net = xp_net(xp); in parse_ipsecrequest()
1946 struct xfrm_tmpl *t = xp->xfrm_vec + xp->xfrm_nr; in parse_ipsecrequest()
1949 if (xp->xfrm_nr >= XFRM_MAX_DEPTH) in parse_ipsecrequest()
1982 t->encap_family = xp->family; in parse_ipsecrequest()
1986 xp->xfrm_nr++; in parse_ipsecrequest()
1991 parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol) in parse_ipsecrequests() argument
2005 if ((err = parse_ipsecrequest(xp, rq)) < 0) in parse_ipsecrequests()
2013 static inline int pfkey_xfrm_policy2sec_ctx_size(const struct xfrm_policy *xp) in pfkey_xfrm_policy2sec_ctx_size() argument
2015 struct xfrm_sec_ctx *xfrm_ctx = xp->security; in pfkey_xfrm_policy2sec_ctx_size()
2025 static int pfkey_xfrm_policy2msg_size(const struct xfrm_policy *xp) in pfkey_xfrm_policy2msg_size() argument
2028 int sockaddr_size = pfkey_sockaddr_size(xp->family); in pfkey_xfrm_policy2msg_size()
2032 for (i=0; i<xp->xfrm_nr; i++) { in pfkey_xfrm_policy2msg_size()
2033 t = xp->xfrm_vec + i; in pfkey_xfrm_policy2msg_size()
2042 (xp->xfrm_nr * sizeof(struct sadb_x_ipsecrequest)) + in pfkey_xfrm_policy2msg_size()
2044 pfkey_xfrm_policy2sec_ctx_size(xp); in pfkey_xfrm_policy2msg_size()
2047 static struct sk_buff * pfkey_xfrm_policy2msg_prep(const struct xfrm_policy *xp) in pfkey_xfrm_policy2msg_prep() argument
2052 size = pfkey_xfrm_policy2msg_size(xp); in pfkey_xfrm_policy2msg_prep()
2061 static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *xp, int dir) in pfkey_xfrm_policy2msg() argument
2071 int sockaddr_size = pfkey_sockaddr_size(xp->family); in pfkey_xfrm_policy2msg()
2072 int socklen = pfkey_sockaddr_len(xp->family); in pfkey_xfrm_policy2msg()
2074 size = pfkey_xfrm_policy2msg_size(xp); in pfkey_xfrm_policy2msg()
2086 addr->sadb_address_proto = pfkey_proto_from_xfrm(xp->selector.proto); in pfkey_xfrm_policy2msg()
2087 addr->sadb_address_prefixlen = xp->selector.prefixlen_s; in pfkey_xfrm_policy2msg()
2089 if (!pfkey_sockaddr_fill(&xp->selector.saddr, in pfkey_xfrm_policy2msg()
2090 xp->selector.sport, in pfkey_xfrm_policy2msg()
2092 xp->family)) in pfkey_xfrm_policy2msg()
2101 addr->sadb_address_proto = pfkey_proto_from_xfrm(xp->selector.proto); in pfkey_xfrm_policy2msg()
2102 addr->sadb_address_prefixlen = xp->selector.prefixlen_d; in pfkey_xfrm_policy2msg()
2105 pfkey_sockaddr_fill(&xp->selector.daddr, xp->selector.dport, in pfkey_xfrm_policy2msg()
2107 xp->family); in pfkey_xfrm_policy2msg()
2114 lifetime->sadb_lifetime_allocations = _X2KEY(xp->lft.hard_packet_limit); in pfkey_xfrm_policy2msg()
2115 lifetime->sadb_lifetime_bytes = _X2KEY(xp->lft.hard_byte_limit); in pfkey_xfrm_policy2msg()
2116 lifetime->sadb_lifetime_addtime = xp->lft.hard_add_expires_seconds; in pfkey_xfrm_policy2msg()
2117 lifetime->sadb_lifetime_usetime = xp->lft.hard_use_expires_seconds; in pfkey_xfrm_policy2msg()
2123 lifetime->sadb_lifetime_allocations = _X2KEY(xp->lft.soft_packet_limit); in pfkey_xfrm_policy2msg()
2124 lifetime->sadb_lifetime_bytes = _X2KEY(xp->lft.soft_byte_limit); in pfkey_xfrm_policy2msg()
2125 lifetime->sadb_lifetime_addtime = xp->lft.soft_add_expires_seconds; in pfkey_xfrm_policy2msg()
2126 lifetime->sadb_lifetime_usetime = xp->lft.soft_use_expires_seconds; in pfkey_xfrm_policy2msg()
2132 lifetime->sadb_lifetime_allocations = xp->curlft.packets; in pfkey_xfrm_policy2msg()
2133 lifetime->sadb_lifetime_bytes = xp->curlft.bytes; in pfkey_xfrm_policy2msg()
2134 lifetime->sadb_lifetime_addtime = xp->curlft.add_time; in pfkey_xfrm_policy2msg()
2135 lifetime->sadb_lifetime_usetime = xp->curlft.use_time; in pfkey_xfrm_policy2msg()
2141 if (xp->action == XFRM_POLICY_ALLOW) { in pfkey_xfrm_policy2msg()
2142 if (xp->xfrm_nr) in pfkey_xfrm_policy2msg()
2149 pol->sadb_x_policy_id = xp->index; in pfkey_xfrm_policy2msg()
2150 pol->sadb_x_policy_priority = xp->priority; in pfkey_xfrm_policy2msg()
2152 for (i=0; i<xp->xfrm_nr; i++) { in pfkey_xfrm_policy2msg()
2153 const struct xfrm_tmpl *t = xp->xfrm_vec + i; in pfkey_xfrm_policy2msg()
2192 if ((xfrm_ctx = xp->security)) { in pfkey_xfrm_policy2msg()
2193 int ctx_size = pfkey_xfrm_policy2sec_ctx_size(xp); in pfkey_xfrm_policy2msg()
2206 hdr->sadb_msg_reserved = refcount_read(&xp->refcnt); in pfkey_xfrm_policy2msg()
2211 static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_event *c) in key_notify_policy() argument
2217 out_skb = pfkey_xfrm_policy2msg_prep(xp); in key_notify_policy()
2221 err = pfkey_xfrm_policy2msg(out_skb, xp, dir); in key_notify_policy()
2237 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp)); in key_notify_policy()
2249 struct xfrm_policy *xp; in pfkey_spdadd() local
2264 xp = xfrm_policy_alloc(net, GFP_KERNEL); in pfkey_spdadd()
2265 if (xp == NULL) in pfkey_spdadd()
2268 xp->action = (pol->sadb_x_policy_type == IPSEC_POLICY_DISCARD ? in pfkey_spdadd()
2270 xp->priority = pol->sadb_x_policy_priority; in pfkey_spdadd()
2273 xp->family = pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.saddr); in pfkey_spdadd()
2274 xp->selector.family = xp->family; in pfkey_spdadd()
2275 xp->selector.prefixlen_s = sa->sadb_address_prefixlen; in pfkey_spdadd()
2276 xp->selector.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); in pfkey_spdadd()
2277 xp->selector.sport = ((struct sockaddr_in *)(sa+1))->sin_port; in pfkey_spdadd()
2278 if (xp->selector.sport) in pfkey_spdadd()
2279 xp->selector.sport_mask = htons(0xffff); in pfkey_spdadd()
2282 pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.daddr); in pfkey_spdadd()
2283 xp->selector.prefixlen_d = sa->sadb_address_prefixlen; in pfkey_spdadd()
2288 xp->selector.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); in pfkey_spdadd()
2290 xp->selector.dport = ((struct sockaddr_in *)(sa+1))->sin_port; in pfkey_spdadd()
2291 if (xp->selector.dport) in pfkey_spdadd()
2292 xp->selector.dport_mask = htons(0xffff); in pfkey_spdadd()
2303 err = security_xfrm_policy_alloc(&xp->security, uctx, GFP_KERNEL); in pfkey_spdadd()
2310 xp->lft.soft_byte_limit = XFRM_INF; in pfkey_spdadd()
2311 xp->lft.hard_byte_limit = XFRM_INF; in pfkey_spdadd()
2312 xp->lft.soft_packet_limit = XFRM_INF; in pfkey_spdadd()
2313 xp->lft.hard_packet_limit = XFRM_INF; in pfkey_spdadd()
2315 xp->lft.hard_packet_limit = _KEY2X(lifetime->sadb_lifetime_allocations); in pfkey_spdadd()
2316 xp->lft.hard_byte_limit = _KEY2X(lifetime->sadb_lifetime_bytes); in pfkey_spdadd()
2317 xp->lft.hard_add_expires_seconds = lifetime->sadb_lifetime_addtime; in pfkey_spdadd()
2318 xp->lft.hard_use_expires_seconds = lifetime->sadb_lifetime_usetime; in pfkey_spdadd()
2321 xp->lft.soft_packet_limit = _KEY2X(lifetime->sadb_lifetime_allocations); in pfkey_spdadd()
2322 xp->lft.soft_byte_limit = _KEY2X(lifetime->sadb_lifetime_bytes); in pfkey_spdadd()
2323 xp->lft.soft_add_expires_seconds = lifetime->sadb_lifetime_addtime; in pfkey_spdadd()
2324 xp->lft.soft_use_expires_seconds = lifetime->sadb_lifetime_usetime; in pfkey_spdadd()
2326 xp->xfrm_nr = 0; in pfkey_spdadd()
2328 (err = parse_ipsecrequests(xp, pol)) < 0) in pfkey_spdadd()
2331 err = xfrm_policy_insert(pol->sadb_x_policy_dir-1, xp, in pfkey_spdadd()
2334 xfrm_audit_policy_add(xp, err ? 0 : 1, true); in pfkey_spdadd()
2347 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); in pfkey_spdadd()
2348 xfrm_pol_put(xp); in pfkey_spdadd()
2352 xp->walk.dead = 1; in pfkey_spdadd()
2353 xfrm_policy_destroy(xp); in pfkey_spdadd()
2363 struct xfrm_policy *xp; in pfkey_spddelete() local
2409 xp = xfrm_policy_bysel_ctx(net, &dummy_mark, 0, XFRM_POLICY_TYPE_MAIN, in pfkey_spddelete()
2413 if (xp == NULL) in pfkey_spddelete()
2416 xfrm_audit_policy_delete(xp, err ? 0 : 1, true); in pfkey_spddelete()
2425 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); in pfkey_spddelete()
2428 xfrm_pol_put(xp); in pfkey_spddelete()
2432 static int key_pol_get_resp(struct sock *sk, struct xfrm_policy *xp, const struct sadb_msg *hdr, in… in key_pol_get_resp() argument
2439 out_skb = pfkey_xfrm_policy2msg_prep(xp); in key_pol_get_resp()
2444 err = pfkey_xfrm_policy2msg(out_skb, xp, dir); in key_pol_get_resp()
2457 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, xp_net(xp)); in key_pol_get_resp()
2649 struct xfrm_policy *xp; in pfkey_spdget() local
2660 xp = xfrm_policy_byid(net, &dummy_mark, 0, XFRM_POLICY_TYPE_MAIN, in pfkey_spdget()
2662 if (xp == NULL) in pfkey_spdget()
2666 xfrm_audit_policy_delete(xp, err ? 0 : 1, true); in pfkey_spdget()
2674 km_policy_notify(xp, dir, &c); in pfkey_spdget()
2676 err = key_pol_get_resp(sk, xp, hdr, dir); in pfkey_spdget()
2680 xfrm_pol_put(xp); in pfkey_spdget()
2684 static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr) in dump_sp() argument
2694 out_skb = pfkey_xfrm_policy2msg_prep(xp); in dump_sp()
2698 err = pfkey_xfrm_policy2msg(out_skb, xp, dir); in dump_sp()
3034 static int key_notify_policy_expire(struct xfrm_policy *xp, const struct km_event *c) in key_notify_policy_expire() argument
3097 static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c) in pfkey_send_policy_notify() argument
3099 if (xp && xp->type != XFRM_POLICY_TYPE_MAIN) in pfkey_send_policy_notify()
3104 return key_notify_policy_expire(xp, c); in pfkey_send_policy_notify()
3108 return key_notify_policy(xp, dir, c); in pfkey_send_policy_notify()
3150 static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *xp) in pfkey_send_acquire() argument
3232 pol->sadb_x_policy_id = xp->index; in pfkey_send_acquire()
3233 pol->sadb_x_policy_priority = xp->priority; in pfkey_send_acquire()
3266 struct xfrm_policy *xp; in pfkey_compile_policy() local
3298 xp = xfrm_policy_alloc(net, GFP_ATOMIC); in pfkey_compile_policy()
3299 if (xp == NULL) { in pfkey_compile_policy()
3304 xp->action = (pol->sadb_x_policy_type == IPSEC_POLICY_DISCARD ? in pfkey_compile_policy()
3307 xp->lft.soft_byte_limit = XFRM_INF; in pfkey_compile_policy()
3308 xp->lft.hard_byte_limit = XFRM_INF; in pfkey_compile_policy()
3309 xp->lft.soft_packet_limit = XFRM_INF; in pfkey_compile_policy()
3310 xp->lft.hard_packet_limit = XFRM_INF; in pfkey_compile_policy()
3311 xp->family = sk->sk_family; in pfkey_compile_policy()
3313 xp->xfrm_nr = 0; in pfkey_compile_policy()
3315 (*dir = parse_ipsecrequests(xp, pol)) < 0) in pfkey_compile_policy()
3334 *dir = security_xfrm_policy_alloc(&xp->security, uctx, GFP_ATOMIC); in pfkey_compile_policy()
3342 return xp; in pfkey_compile_policy()
3345 xp->walk.dead = 1; in pfkey_compile_policy()
3346 xfrm_policy_destroy(xp); in pfkey_compile_policy()