Lines Matching +full:t +full:- +full:head

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* xfrm6_protocol.c - Generic xfrm protocol multiplexer for ipv6.
41 #define for_each_protocol_rcu(head, handler) \ argument
42 for (handler = rcu_dereference(head); \
44 handler = rcu_dereference(handler->next)) \
50 struct xfrm6_protocol __rcu **head = proto_handlers(protocol); in xfrm6_rcv_cb() local
52 if (!head) in xfrm6_rcv_cb()
56 if ((ret = handler->cb_handler(skb, err)) <= 0) in xfrm6_rcv_cb()
67 struct xfrm6_protocol __rcu **head = proto_handlers(nexthdr); in xfrm6_rcv_encap() local
69 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = NULL; in xfrm6_rcv_encap()
70 XFRM_SPI_SKB_CB(skb)->family = AF_INET6; in xfrm6_rcv_encap()
71 XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct ipv6hdr, daddr); in xfrm6_rcv_encap()
73 if (!head) in xfrm6_rcv_encap()
81 .flowi6_iif = skb->dev->ifindex, in xfrm6_rcv_encap()
82 .daddr = ip6h->daddr, in xfrm6_rcv_encap()
83 .saddr = ip6h->saddr, in xfrm6_rcv_encap()
85 .flowi6_mark = skb->mark, in xfrm6_rcv_encap()
86 .flowi6_proto = ip6h->nexthdr, in xfrm6_rcv_encap()
89 dst = ip6_route_input_lookup(dev_net(skb->dev), skb->dev, &fl6, in xfrm6_rcv_encap()
91 if (dst->error) in xfrm6_rcv_encap()
96 for_each_protocol_rcu(*head, handler) in xfrm6_rcv_encap()
97 if ((ret = handler->input_handler(skb, nexthdr, spi, encap_type)) != -EINVAL) in xfrm6_rcv_encap()
114 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = NULL; in xfrm6_esp_rcv()
117 if ((ret = handler->handler(skb)) != -EINVAL) in xfrm6_esp_rcv()
132 if (!handler->err_handler(skb, opt, type, code, offset, info)) in xfrm6_esp_err()
135 return -ENOENT; in xfrm6_esp_err()
143 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = NULL; in xfrm6_ah_rcv()
146 if ((ret = handler->handler(skb)) != -EINVAL) in xfrm6_ah_rcv()
161 if (!handler->err_handler(skb, opt, type, code, offset, info)) in xfrm6_ah_err()
164 return -ENOENT; in xfrm6_ah_err()
172 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6 = NULL; in xfrm6_ipcomp_rcv()
175 if ((ret = handler->handler(skb)) != -EINVAL) in xfrm6_ipcomp_rcv()
190 if (!handler->err_handler(skb, opt, type, code, offset, info)) in xfrm6_ipcomp_err()
193 return -ENOENT; in xfrm6_ipcomp_err()
237 struct xfrm6_protocol *t; in xfrm6_protocol_register() local
239 int ret = -EEXIST; in xfrm6_protocol_register()
240 int priority = handler->priority; in xfrm6_protocol_register()
243 return -EINVAL; in xfrm6_protocol_register()
252 (t = rcu_dereference_protected(*pprev, in xfrm6_protocol_register()
254 pprev = &t->next) { in xfrm6_protocol_register()
255 if (t->priority < priority) in xfrm6_protocol_register()
257 if (t->priority == priority) in xfrm6_protocol_register()
261 handler->next = *pprev; in xfrm6_protocol_register()
271 pr_err("%s: can't add protocol\n", __func__); in xfrm6_protocol_register()
272 ret = -EAGAIN; in xfrm6_protocol_register()
284 struct xfrm6_protocol *t; in xfrm6_protocol_deregister() local
285 int ret = -ENOENT; in xfrm6_protocol_deregister()
288 return -EINVAL; in xfrm6_protocol_deregister()
293 (t = rcu_dereference_protected(*pprev, in xfrm6_protocol_deregister()
295 pprev = &t->next) { in xfrm6_protocol_deregister()
296 if (t == handler) { in xfrm6_protocol_deregister()
297 *pprev = handler->next; in xfrm6_protocol_deregister()
306 pr_err("%s: can't remove protocol\n", __func__); in xfrm6_protocol_deregister()
307 ret = -EAGAIN; in xfrm6_protocol_deregister()