Lines Matching refs:xp
1908 static int check_reqid(struct xfrm_policy *xp, int dir, int count, void *ptr) in check_reqid() argument
1913 for (i=0; i<xp->xfrm_nr; i++) { in check_reqid()
1914 if (xp->xfrm_vec[i].reqid == reqid) in check_reqid()
1942 parse_ipsecrequest(struct xfrm_policy *xp, struct sadb_x_policy *pol, 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()
1985 t->encap_family = xp->family; in parse_ipsecrequest()
1989 xp->xfrm_nr++; in parse_ipsecrequest()
1994 parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol) in parse_ipsecrequests() argument
2008 if ((err = parse_ipsecrequest(xp, pol, rq)) < 0) in parse_ipsecrequests()
2016 static inline int pfkey_xfrm_policy2sec_ctx_size(const struct xfrm_policy *xp) in pfkey_xfrm_policy2sec_ctx_size() argument
2018 struct xfrm_sec_ctx *xfrm_ctx = xp->security; in pfkey_xfrm_policy2sec_ctx_size()
2028 static int pfkey_xfrm_policy2msg_size(const struct xfrm_policy *xp) in pfkey_xfrm_policy2msg_size() argument
2031 int sockaddr_size = pfkey_sockaddr_size(xp->family); in pfkey_xfrm_policy2msg_size()
2035 for (i=0; i<xp->xfrm_nr; i++) { in pfkey_xfrm_policy2msg_size()
2036 t = xp->xfrm_vec + i; in pfkey_xfrm_policy2msg_size()
2045 (xp->xfrm_nr * sizeof(struct sadb_x_ipsecrequest)) + in pfkey_xfrm_policy2msg_size()
2047 pfkey_xfrm_policy2sec_ctx_size(xp); in pfkey_xfrm_policy2msg_size()
2050 static struct sk_buff * pfkey_xfrm_policy2msg_prep(const struct xfrm_policy *xp) in pfkey_xfrm_policy2msg_prep() argument
2055 size = pfkey_xfrm_policy2msg_size(xp); in pfkey_xfrm_policy2msg_prep()
2064 static int pfkey_xfrm_policy2msg(struct sk_buff *skb, const struct xfrm_policy *xp, int dir) in pfkey_xfrm_policy2msg() argument
2074 int sockaddr_size = pfkey_sockaddr_size(xp->family); in pfkey_xfrm_policy2msg()
2075 int socklen = pfkey_sockaddr_len(xp->family); in pfkey_xfrm_policy2msg()
2077 size = pfkey_xfrm_policy2msg_size(xp); in pfkey_xfrm_policy2msg()
2089 addr->sadb_address_proto = pfkey_proto_from_xfrm(xp->selector.proto); in pfkey_xfrm_policy2msg()
2090 addr->sadb_address_prefixlen = xp->selector.prefixlen_s; in pfkey_xfrm_policy2msg()
2092 if (!pfkey_sockaddr_fill(&xp->selector.saddr, in pfkey_xfrm_policy2msg()
2093 xp->selector.sport, in pfkey_xfrm_policy2msg()
2095 xp->family)) in pfkey_xfrm_policy2msg()
2104 addr->sadb_address_proto = pfkey_proto_from_xfrm(xp->selector.proto); in pfkey_xfrm_policy2msg()
2105 addr->sadb_address_prefixlen = xp->selector.prefixlen_d; in pfkey_xfrm_policy2msg()
2108 pfkey_sockaddr_fill(&xp->selector.daddr, xp->selector.dport, in pfkey_xfrm_policy2msg()
2110 xp->family); in pfkey_xfrm_policy2msg()
2117 lifetime->sadb_lifetime_allocations = _X2KEY(xp->lft.hard_packet_limit); in pfkey_xfrm_policy2msg()
2118 lifetime->sadb_lifetime_bytes = _X2KEY(xp->lft.hard_byte_limit); in pfkey_xfrm_policy2msg()
2119 lifetime->sadb_lifetime_addtime = xp->lft.hard_add_expires_seconds; in pfkey_xfrm_policy2msg()
2120 lifetime->sadb_lifetime_usetime = xp->lft.hard_use_expires_seconds; in pfkey_xfrm_policy2msg()
2126 lifetime->sadb_lifetime_allocations = _X2KEY(xp->lft.soft_packet_limit); in pfkey_xfrm_policy2msg()
2127 lifetime->sadb_lifetime_bytes = _X2KEY(xp->lft.soft_byte_limit); in pfkey_xfrm_policy2msg()
2128 lifetime->sadb_lifetime_addtime = xp->lft.soft_add_expires_seconds; in pfkey_xfrm_policy2msg()
2129 lifetime->sadb_lifetime_usetime = xp->lft.soft_use_expires_seconds; in pfkey_xfrm_policy2msg()
2135 lifetime->sadb_lifetime_allocations = xp->curlft.packets; in pfkey_xfrm_policy2msg()
2136 lifetime->sadb_lifetime_bytes = xp->curlft.bytes; in pfkey_xfrm_policy2msg()
2137 lifetime->sadb_lifetime_addtime = xp->curlft.add_time; in pfkey_xfrm_policy2msg()
2138 lifetime->sadb_lifetime_usetime = xp->curlft.use_time; in pfkey_xfrm_policy2msg()
2144 if (xp->action == XFRM_POLICY_ALLOW) { in pfkey_xfrm_policy2msg()
2145 if (xp->xfrm_nr) in pfkey_xfrm_policy2msg()
2152 pol->sadb_x_policy_id = xp->index; in pfkey_xfrm_policy2msg()
2153 pol->sadb_x_policy_priority = xp->priority; in pfkey_xfrm_policy2msg()
2155 for (i=0; i<xp->xfrm_nr; i++) { in pfkey_xfrm_policy2msg()
2156 const struct xfrm_tmpl *t = xp->xfrm_vec + i; in pfkey_xfrm_policy2msg()
2195 if ((xfrm_ctx = xp->security)) { in pfkey_xfrm_policy2msg()
2196 int ctx_size = pfkey_xfrm_policy2sec_ctx_size(xp); in pfkey_xfrm_policy2msg()
2209 hdr->sadb_msg_reserved = refcount_read(&xp->refcnt); in pfkey_xfrm_policy2msg()
2214 static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_event *c) in key_notify_policy() argument
2220 out_skb = pfkey_xfrm_policy2msg_prep(xp); in key_notify_policy()
2224 err = pfkey_xfrm_policy2msg(out_skb, xp, dir); in key_notify_policy()
2240 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp)); in key_notify_policy()
2252 struct xfrm_policy *xp; in pfkey_spdadd() local
2267 xp = xfrm_policy_alloc(net, GFP_KERNEL); in pfkey_spdadd()
2268 if (xp == NULL) in pfkey_spdadd()
2271 xp->action = (pol->sadb_x_policy_type == IPSEC_POLICY_DISCARD ? in pfkey_spdadd()
2273 xp->priority = pol->sadb_x_policy_priority; in pfkey_spdadd()
2276 xp->family = pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.saddr); in pfkey_spdadd()
2277 xp->selector.family = xp->family; in pfkey_spdadd()
2278 xp->selector.prefixlen_s = sa->sadb_address_prefixlen; in pfkey_spdadd()
2279 xp->selector.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); in pfkey_spdadd()
2280 xp->selector.sport = ((struct sockaddr_in *)(sa+1))->sin_port; in pfkey_spdadd()
2281 if (xp->selector.sport) in pfkey_spdadd()
2282 xp->selector.sport_mask = htons(0xffff); in pfkey_spdadd()
2285 pfkey_sadb_addr2xfrm_addr(sa, &xp->selector.daddr); in pfkey_spdadd()
2286 xp->selector.prefixlen_d = sa->sadb_address_prefixlen; in pfkey_spdadd()
2291 xp->selector.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); in pfkey_spdadd()
2293 xp->selector.dport = ((struct sockaddr_in *)(sa+1))->sin_port; in pfkey_spdadd()
2294 if (xp->selector.dport) in pfkey_spdadd()
2295 xp->selector.dport_mask = htons(0xffff); in pfkey_spdadd()
2306 err = security_xfrm_policy_alloc(&xp->security, uctx, GFP_KERNEL); in pfkey_spdadd()
2313 xp->lft.soft_byte_limit = XFRM_INF; in pfkey_spdadd()
2314 xp->lft.hard_byte_limit = XFRM_INF; in pfkey_spdadd()
2315 xp->lft.soft_packet_limit = XFRM_INF; in pfkey_spdadd()
2316 xp->lft.hard_packet_limit = XFRM_INF; in pfkey_spdadd()
2318 xp->lft.hard_packet_limit = _KEY2X(lifetime->sadb_lifetime_allocations); in pfkey_spdadd()
2319 xp->lft.hard_byte_limit = _KEY2X(lifetime->sadb_lifetime_bytes); in pfkey_spdadd()
2320 xp->lft.hard_add_expires_seconds = lifetime->sadb_lifetime_addtime; in pfkey_spdadd()
2321 xp->lft.hard_use_expires_seconds = lifetime->sadb_lifetime_usetime; in pfkey_spdadd()
2324 xp->lft.soft_packet_limit = _KEY2X(lifetime->sadb_lifetime_allocations); in pfkey_spdadd()
2325 xp->lft.soft_byte_limit = _KEY2X(lifetime->sadb_lifetime_bytes); in pfkey_spdadd()
2326 xp->lft.soft_add_expires_seconds = lifetime->sadb_lifetime_addtime; in pfkey_spdadd()
2327 xp->lft.soft_use_expires_seconds = lifetime->sadb_lifetime_usetime; in pfkey_spdadd()
2329 xp->xfrm_nr = 0; in pfkey_spdadd()
2331 (err = parse_ipsecrequests(xp, pol)) < 0) in pfkey_spdadd()
2334 err = xfrm_policy_insert(pol->sadb_x_policy_dir-1, xp, in pfkey_spdadd()
2337 xfrm_audit_policy_add(xp, err ? 0 : 1, true); in pfkey_spdadd()
2350 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); in pfkey_spdadd()
2351 xfrm_pol_put(xp); in pfkey_spdadd()
2355 xp->walk.dead = 1; in pfkey_spdadd()
2356 xfrm_policy_destroy(xp); in pfkey_spdadd()
2366 struct xfrm_policy *xp; in pfkey_spddelete() local
2412 xp = xfrm_policy_bysel_ctx(net, &dummy_mark, 0, XFRM_POLICY_TYPE_MAIN, in pfkey_spddelete()
2416 if (xp == NULL) in pfkey_spddelete()
2419 xfrm_audit_policy_delete(xp, err ? 0 : 1, true); in pfkey_spddelete()
2428 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); in pfkey_spddelete()
2431 xfrm_pol_put(xp); in pfkey_spddelete()
2435 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
2442 out_skb = pfkey_xfrm_policy2msg_prep(xp); in key_pol_get_resp()
2447 err = pfkey_xfrm_policy2msg(out_skb, xp, dir); in key_pol_get_resp()
2460 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, xp_net(xp)); in key_pol_get_resp()
2652 struct xfrm_policy *xp; in pfkey_spdget() local
2663 xp = xfrm_policy_byid(net, &dummy_mark, 0, XFRM_POLICY_TYPE_MAIN, in pfkey_spdget()
2665 if (xp == NULL) in pfkey_spdget()
2669 xfrm_audit_policy_delete(xp, err ? 0 : 1, true); in pfkey_spdget()
2677 km_policy_notify(xp, dir, &c); in pfkey_spdget()
2679 err = key_pol_get_resp(sk, xp, hdr, dir); in pfkey_spdget()
2683 xfrm_pol_put(xp); in pfkey_spdget()
2687 static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr) in dump_sp() argument
2697 out_skb = pfkey_xfrm_policy2msg_prep(xp); in dump_sp()
2701 err = pfkey_xfrm_policy2msg(out_skb, xp, dir); in dump_sp()
3037 static int key_notify_policy_expire(struct xfrm_policy *xp, const struct km_event *c) in key_notify_policy_expire() argument
3100 static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c) in pfkey_send_policy_notify() argument
3102 if (xp && xp->type != XFRM_POLICY_TYPE_MAIN) in pfkey_send_policy_notify()
3107 return key_notify_policy_expire(xp, c); in pfkey_send_policy_notify()
3111 return key_notify_policy(xp, dir, c); in pfkey_send_policy_notify()
3153 static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *xp) in pfkey_send_acquire() argument
3235 pol->sadb_x_policy_id = xp->index; in pfkey_send_acquire()
3236 pol->sadb_x_policy_priority = xp->priority; in pfkey_send_acquire()
3269 struct xfrm_policy *xp; in pfkey_compile_policy() local
3301 xp = xfrm_policy_alloc(net, GFP_ATOMIC); in pfkey_compile_policy()
3302 if (xp == NULL) { in pfkey_compile_policy()
3307 xp->action = (pol->sadb_x_policy_type == IPSEC_POLICY_DISCARD ? in pfkey_compile_policy()
3310 xp->lft.soft_byte_limit = XFRM_INF; in pfkey_compile_policy()
3311 xp->lft.hard_byte_limit = XFRM_INF; in pfkey_compile_policy()
3312 xp->lft.soft_packet_limit = XFRM_INF; in pfkey_compile_policy()
3313 xp->lft.hard_packet_limit = XFRM_INF; in pfkey_compile_policy()
3314 xp->family = sk->sk_family; in pfkey_compile_policy()
3316 xp->xfrm_nr = 0; in pfkey_compile_policy()
3318 (*dir = parse_ipsecrequests(xp, pol)) < 0) in pfkey_compile_policy()
3337 *dir = security_xfrm_policy_alloc(&xp->security, uctx, GFP_ATOMIC); in pfkey_compile_policy()
3345 return xp; in pfkey_compile_policy()
3348 xp->walk.dead = 1; in pfkey_compile_policy()
3349 xfrm_policy_destroy(xp); in pfkey_compile_policy()