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

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* xfrm4_protocol.c - Generic xfrm protocol multiplexer.
40 #define for_each_protocol_rcu(head, handler) \ argument
41 for (handler = rcu_dereference(head); \
43 handler = rcu_dereference(handler->next)) \
49 struct xfrm4_protocol __rcu **head = proto_handlers(protocol); in xfrm4_rcv_cb() local
51 if (!head) in xfrm4_rcv_cb()
54 for_each_protocol_rcu(*head, handler) in xfrm4_rcv_cb()
55 if ((ret = handler->cb_handler(skb, err)) <= 0) in xfrm4_rcv_cb()
66 struct xfrm4_protocol __rcu **head = proto_handlers(nexthdr); in xfrm4_rcv_encap() local
68 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = NULL; in xfrm4_rcv_encap()
69 XFRM_SPI_SKB_CB(skb)->family = AF_INET; in xfrm4_rcv_encap()
70 XFRM_SPI_SKB_CB(skb)->daddroff = offsetof(struct iphdr, daddr); in xfrm4_rcv_encap()
72 if (!head) in xfrm4_rcv_encap()
78 if (ip_route_input_noref(skb, iph->daddr, iph->saddr, in xfrm4_rcv_encap()
79 iph->tos, skb->dev)) in xfrm4_rcv_encap()
83 for_each_protocol_rcu(*head, handler) in xfrm4_rcv_encap()
84 if ((ret = handler->input_handler(skb, nexthdr, spi, encap_type)) != -EINVAL) in xfrm4_rcv_encap()
101 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = NULL; in xfrm4_esp_rcv()
104 if ((ret = handler->handler(skb)) != -EINVAL) in xfrm4_esp_rcv()
118 if (!handler->err_handler(skb, info)) in xfrm4_esp_err()
121 return -ENOENT; in xfrm4_esp_err()
129 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = NULL; in xfrm4_ah_rcv()
132 if ((ret = handler->handler(skb)) != -EINVAL) in xfrm4_ah_rcv()
146 if (!handler->err_handler(skb, info)) in xfrm4_ah_err()
149 return -ENOENT; in xfrm4_ah_err()
157 XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4 = NULL; in xfrm4_ipcomp_rcv()
160 if ((ret = handler->handler(skb)) != -EINVAL) in xfrm4_ipcomp_rcv()
174 if (!handler->err_handler(skb, info)) in xfrm4_ipcomp_err()
177 return -ENOENT; in xfrm4_ipcomp_err()
221 struct xfrm4_protocol *t; in xfrm4_protocol_register() local
223 int ret = -EEXIST; in xfrm4_protocol_register()
224 int priority = handler->priority; in xfrm4_protocol_register()
227 return -EINVAL; in xfrm4_protocol_register()
236 (t = rcu_dereference_protected(*pprev, in xfrm4_protocol_register()
238 pprev = &t->next) { in xfrm4_protocol_register()
239 if (t->priority < priority) in xfrm4_protocol_register()
241 if (t->priority == priority) in xfrm4_protocol_register()
245 handler->next = *pprev; in xfrm4_protocol_register()
255 pr_err("%s: can't add protocol\n", __func__); in xfrm4_protocol_register()
256 ret = -EAGAIN; in xfrm4_protocol_register()
268 struct xfrm4_protocol *t; in xfrm4_protocol_deregister() local
269 int ret = -ENOENT; in xfrm4_protocol_deregister()
272 return -EINVAL; in xfrm4_protocol_deregister()
277 (t = rcu_dereference_protected(*pprev, in xfrm4_protocol_deregister()
279 pprev = &t->next) { in xfrm4_protocol_deregister()
280 if (t == handler) { in xfrm4_protocol_deregister()
281 *pprev = handler->next; in xfrm4_protocol_deregister()
290 pr_err("%s: can't remove protocol\n", __func__); in xfrm4_protocol_deregister()
291 ret = -EAGAIN; in xfrm4_protocol_deregister()