1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright (c) 2017 Jesper Dangaard Brouer, Red Hat Inc.
6 #ifndef __LINUX_NET_XDP_H__
7 #define __LINUX_NET_XDP_H__
9 #include <linux/bitfield.h>
10 #include <linux/filter.h>
11 #include <linux/netdevice.h>
12 #include <linux/skbuff.h> /* skb_shared_info */
14 #include <net/page_pool/types.h>
17 * DOC: XDP RX-queue information
19 * The XDP RX-queue info (xdp_rxq_info) is associated with the driver
20 * level RX-ring queues. It is information that is specific to how
21 * the driver has configured a given RX-ring queue.
23 * Each xdp_buff frame received in the driver carries a (pointer)
24 * reference to this xdp_rxq_info structure. This provides the XDP
25 * data-path read-access to RX-info for both kernel and bpf-side
28 * For now, direct access is only safe while running in NAPI/softirq
29 * context. Contents are read-mostly and must not be updated during
30 * driver NAPI/softirq poll.
32 * The driver usage API is a register and unregister API.
34 * The struct is not directly tied to the XDP prog. A new XDP prog
35 * can be attached as long as it doesn't change the underlying
36 * RX-ring. If the RX-ring does change significantly, the NIC driver
37 * naturally needs to stop the RX-ring before purging and reallocating
38 * memory. In that process the driver MUST call unregister (which
39 * also applies for driver shutdown and unload). The register API is
40 * also mandatory during RX-ring setup.
44 MEM_TYPE_PAGE_SHARED = 0, /* Split-page refcnt based model */
45 MEM_TYPE_PAGE_ORDER0, /* Orig XDP full page model */
47 MEM_TYPE_XSK_BUFF_POOL,
51 /* XDP flags for ndo_xdp_xmit */
52 #define XDP_XMIT_FLUSH (1U << 0) /* doorbell signal consumer */
53 #define XDP_XMIT_FLAGS_MASK XDP_XMIT_FLUSH
56 u32 type; /* enum xdp_mem_type, but known size type */
63 struct net_device *dev;
66 struct xdp_mem_info mem;
68 } ____cacheline_aligned; /* perf critical, avoid false-sharing */
71 struct net_device *dev;
75 XDP_FLAGS_HAS_FRAGS = BIT(0), /* non-linear xdp buff */
76 XDP_FLAGS_FRAGS_PF_MEMALLOC = BIT(1), /* xdp paged memory is under
85 void *data_hard_start;
86 struct xdp_rxq_info *rxq;
87 struct xdp_txq_info *txq;
88 u32 frame_sz; /* frame size to deduce data_hard_end/reserved tailroom*/
89 u32 flags; /* supported values defined in xdp_buff_flags */
92 static __always_inline bool xdp_buff_has_frags(const struct xdp_buff *xdp)
94 return !!(xdp->flags & XDP_FLAGS_HAS_FRAGS);
97 static __always_inline void xdp_buff_set_frags_flag(struct xdp_buff *xdp)
99 xdp->flags |= XDP_FLAGS_HAS_FRAGS;
102 static __always_inline void xdp_buff_clear_frags_flag(struct xdp_buff *xdp)
104 xdp->flags &= ~XDP_FLAGS_HAS_FRAGS;
107 static __always_inline bool
108 xdp_buff_is_frag_pfmemalloc(const struct xdp_buff *xdp)
110 return !!(xdp->flags & XDP_FLAGS_FRAGS_PF_MEMALLOC);
113 static __always_inline void xdp_buff_set_frag_pfmemalloc(struct xdp_buff *xdp)
115 xdp->flags |= XDP_FLAGS_FRAGS_PF_MEMALLOC;
118 static __always_inline void
119 xdp_init_buff(struct xdp_buff *xdp, u32 frame_sz, struct xdp_rxq_info *rxq)
121 xdp->frame_sz = frame_sz;
126 static __always_inline void
127 xdp_prepare_buff(struct xdp_buff *xdp, unsigned char *hard_start,
128 int headroom, int data_len, const bool meta_valid)
130 unsigned char *data = hard_start + headroom;
132 xdp->data_hard_start = hard_start;
134 xdp->data_end = data + data_len;
135 xdp->data_meta = meta_valid ? data : data + 1;
138 /* Reserve memory area at end-of data area.
140 * This macro reserves tailroom in the XDP buffer by limiting the
141 * XDP/BPF data access to data_hard_end. Notice same area (and size)
142 * is used for XDP_PASS, when constructing the SKB via build_skb().
144 #define xdp_data_hard_end(xdp) \
145 ((xdp)->data_hard_start + (xdp)->frame_sz - \
146 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))
148 static inline struct skb_shared_info *
149 xdp_get_shared_info_from_buff(const struct xdp_buff *xdp)
151 return (struct skb_shared_info *)xdp_data_hard_end(xdp);
154 static __always_inline unsigned int
155 xdp_get_buff_len(const struct xdp_buff *xdp)
157 unsigned int len = xdp->data_end - xdp->data;
158 const struct skb_shared_info *sinfo;
160 if (likely(!xdp_buff_has_frags(xdp)))
163 sinfo = xdp_get_shared_info_from_buff(xdp);
164 len += sinfo->xdp_frags_size;
169 void xdp_return_frag(netmem_ref netmem, const struct xdp_buff *xdp);
172 * __xdp_buff_add_frag - attach frag to &xdp_buff
173 * @xdp: XDP buffer to attach the frag to
174 * @netmem: network memory containing the frag
175 * @offset: offset at which the frag starts
176 * @size: size of the frag
177 * @truesize: total memory size occupied by the frag
178 * @try_coalesce: whether to try coalescing the frags (not valid for XSk)
180 * Attach frag to the XDP buffer. If it currently has no frags attached,
181 * initialize the related fields, otherwise check that the frag number
182 * didn't reach the limit of ``MAX_SKB_FRAGS``. If possible, try coalescing
183 * the frag with the previous one.
184 * The function doesn't check/update the pfmemalloc bit. Please use the
185 * non-underscored wrapper in drivers.
187 * Return: true on success, false if there's no space for the frag in
188 * the shared info struct.
190 static inline bool __xdp_buff_add_frag(struct xdp_buff *xdp, netmem_ref netmem,
191 u32 offset, u32 size, u32 truesize,
194 struct skb_shared_info *sinfo = xdp_get_shared_info_from_buff(xdp);
198 if (!xdp_buff_has_frags(xdp)) {
199 xdp_buff_set_frags_flag(xdp);
202 sinfo->xdp_frags_size = 0;
203 sinfo->xdp_frags_truesize = 0;
208 nr_frags = sinfo->nr_frags;
209 prev = &sinfo->frags[nr_frags - 1];
211 if (try_coalesce && netmem == skb_frag_netmem(prev) &&
212 offset == skb_frag_off(prev) + skb_frag_size(prev)) {
213 skb_frag_size_add(prev, size);
214 /* Guaranteed to only decrement the refcount */
215 xdp_return_frag(netmem, xdp);
216 } else if (unlikely(nr_frags == MAX_SKB_FRAGS)) {
220 __skb_fill_netmem_desc_noacc(sinfo, nr_frags++, netmem,
224 sinfo->nr_frags = nr_frags;
225 sinfo->xdp_frags_size += size;
226 sinfo->xdp_frags_truesize += truesize;
232 * xdp_buff_add_frag - attach frag to &xdp_buff
233 * @xdp: XDP buffer to attach the frag to
234 * @netmem: network memory containing the frag
235 * @offset: offset at which the frag starts
236 * @size: size of the frag
237 * @truesize: total memory size occupied by the frag
239 * Version of __xdp_buff_add_frag() which takes care of the pfmemalloc bit.
241 * Return: true on success, false if there's no space for the frag in
242 * the shared info struct.
244 static inline bool xdp_buff_add_frag(struct xdp_buff *xdp, netmem_ref netmem,
245 u32 offset, u32 size, u32 truesize)
247 if (!__xdp_buff_add_frag(xdp, netmem, offset, size, truesize, true))
250 if (unlikely(netmem_is_pfmemalloc(netmem)))
251 xdp_buff_set_frag_pfmemalloc(xdp);
260 u32 metasize; /* uses lower 8-bits */
261 /* Lifetime of xdp_rxq_info is limited to NAPI/enqueue time,
262 * while mem_type is valid on remote CPU.
264 enum xdp_mem_type mem_type:32;
265 struct net_device *dev_rx; /* used by cpumap */
267 u32 flags; /* supported values defined in xdp_buff_flags */
270 static __always_inline bool xdp_frame_has_frags(const struct xdp_frame *frame)
272 return !!(frame->flags & XDP_FLAGS_HAS_FRAGS);
275 static __always_inline bool
276 xdp_frame_is_frag_pfmemalloc(const struct xdp_frame *frame)
278 return !!(frame->flags & XDP_FLAGS_FRAGS_PF_MEMALLOC);
281 #define XDP_BULK_QUEUE_SIZE 16
282 struct xdp_frame_bulk {
284 netmem_ref q[XDP_BULK_QUEUE_SIZE];
287 static __always_inline void xdp_frame_bulk_init(struct xdp_frame_bulk *bq)
292 static inline struct skb_shared_info *
293 xdp_get_shared_info_from_frame(const struct xdp_frame *frame)
295 void *data_hard_start = frame->data - frame->headroom - sizeof(*frame);
297 return (struct skb_shared_info *)(data_hard_start + frame->frame_sz -
298 SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
301 struct xdp_cpumap_stats {
302 unsigned int redirect;
307 /* Clear kernel pointers in xdp_frame */
308 static inline void xdp_scrub_frame(struct xdp_frame *frame)
311 frame->dev_rx = NULL;
315 xdp_update_skb_shared_info(struct sk_buff *skb, u8 nr_frags,
316 unsigned int size, unsigned int truesize,
319 struct skb_shared_info *sinfo = skb_shinfo(skb);
321 sinfo->nr_frags = nr_frags;
323 * ``destructor_arg`` is unionized with ``xdp_frags_{,true}size``,
324 * reset it after that these fields aren't used anymore.
326 sinfo->destructor_arg = NULL;
329 skb->data_len += size;
330 skb->truesize += truesize;
331 skb->pfmemalloc |= pfmemalloc;
334 /* Avoids inlining WARN macro in fast-path */
335 void xdp_warn(const char *msg, const char *func, const int line);
336 #define XDP_WARN(msg) xdp_warn(msg, __func__, __LINE__)
338 struct sk_buff *xdp_build_skb_from_buff(const struct xdp_buff *xdp);
339 struct sk_buff *xdp_build_skb_from_zc(struct xdp_buff *xdp);
340 struct xdp_frame *xdp_convert_zc_to_xdp_frame(struct xdp_buff *xdp);
341 struct sk_buff *__xdp_build_skb_from_frame(struct xdp_frame *xdpf,
343 struct net_device *dev);
344 struct sk_buff *xdp_build_skb_from_frame(struct xdp_frame *xdpf,
345 struct net_device *dev);
346 int xdp_alloc_skb_bulk(void **skbs, int n_skb, gfp_t gfp);
347 struct xdp_frame *xdpf_clone(struct xdp_frame *xdpf);
350 void xdp_convert_frame_to_buff(const struct xdp_frame *frame,
351 struct xdp_buff *xdp)
353 xdp->data_hard_start = frame->data - frame->headroom - sizeof(*frame);
354 xdp->data = frame->data;
355 xdp->data_end = frame->data + frame->len;
356 xdp->data_meta = frame->data - frame->metasize;
357 xdp->frame_sz = frame->frame_sz;
358 xdp->flags = frame->flags;
362 int xdp_update_frame_from_buff(const struct xdp_buff *xdp,
363 struct xdp_frame *xdp_frame)
365 int metasize, headroom;
367 /* Assure headroom is available for storing info */
368 headroom = xdp->data - xdp->data_hard_start;
369 metasize = xdp->data - xdp->data_meta;
370 metasize = metasize > 0 ? metasize : 0;
371 if (unlikely((headroom - metasize) < sizeof(*xdp_frame)))
374 /* Catch if driver didn't reserve tailroom for skb_shared_info */
375 if (unlikely(xdp->data_end > xdp_data_hard_end(xdp))) {
376 XDP_WARN("Driver BUG: missing reserved tailroom");
380 xdp_frame->data = xdp->data;
381 xdp_frame->len = xdp->data_end - xdp->data;
382 xdp_frame->headroom = headroom - sizeof(*xdp_frame);
383 xdp_frame->metasize = metasize;
384 xdp_frame->frame_sz = xdp->frame_sz;
385 xdp_frame->flags = xdp->flags;
390 /* Convert xdp_buff to xdp_frame */
392 struct xdp_frame *xdp_convert_buff_to_frame(struct xdp_buff *xdp)
394 struct xdp_frame *xdp_frame;
396 if (xdp->rxq->mem.type == MEM_TYPE_XSK_BUFF_POOL)
397 return xdp_convert_zc_to_xdp_frame(xdp);
399 /* Store info in top of packet */
400 xdp_frame = xdp->data_hard_start;
401 if (unlikely(xdp_update_frame_from_buff(xdp, xdp_frame) < 0))
404 /* rxq only valid until napi_schedule ends, convert to xdp_mem_type */
405 xdp_frame->mem_type = xdp->rxq->mem.type;
410 void __xdp_return(netmem_ref netmem, enum xdp_mem_type mem_type,
411 bool napi_direct, struct xdp_buff *xdp);
412 void xdp_return_frame(struct xdp_frame *xdpf);
413 void xdp_return_frame_rx_napi(struct xdp_frame *xdpf);
414 void xdp_return_buff(struct xdp_buff *xdp);
415 void xdp_return_frame_bulk(struct xdp_frame *xdpf,
416 struct xdp_frame_bulk *bq);
418 static inline void xdp_flush_frame_bulk(struct xdp_frame_bulk *bq)
420 if (unlikely(!bq->count))
423 page_pool_put_netmem_bulk(bq->q, bq->count);
427 static __always_inline unsigned int
428 xdp_get_frame_len(const struct xdp_frame *xdpf)
430 const struct skb_shared_info *sinfo;
431 unsigned int len = xdpf->len;
433 if (likely(!xdp_frame_has_frags(xdpf)))
436 sinfo = xdp_get_shared_info_from_frame(xdpf);
437 len += sinfo->xdp_frags_size;
442 int __xdp_rxq_info_reg(struct xdp_rxq_info *xdp_rxq,
443 struct net_device *dev, u32 queue_index,
444 unsigned int napi_id, u32 frag_size);
446 xdp_rxq_info_reg(struct xdp_rxq_info *xdp_rxq,
447 struct net_device *dev, u32 queue_index,
448 unsigned int napi_id)
450 return __xdp_rxq_info_reg(xdp_rxq, dev, queue_index, napi_id, 0);
453 void xdp_rxq_info_unreg(struct xdp_rxq_info *xdp_rxq);
454 void xdp_rxq_info_unused(struct xdp_rxq_info *xdp_rxq);
455 bool xdp_rxq_info_is_reg(struct xdp_rxq_info *xdp_rxq);
456 int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq,
457 enum xdp_mem_type type, void *allocator);
458 void xdp_rxq_info_unreg_mem_model(struct xdp_rxq_info *xdp_rxq);
459 int xdp_reg_mem_model(struct xdp_mem_info *mem,
460 enum xdp_mem_type type, void *allocator);
461 void xdp_unreg_mem_model(struct xdp_mem_info *mem);
462 int xdp_reg_page_pool(struct page_pool *pool);
463 void xdp_unreg_page_pool(const struct page_pool *pool);
464 void xdp_rxq_info_attach_page_pool(struct xdp_rxq_info *xdp_rxq,
465 const struct page_pool *pool);
468 * xdp_rxq_info_attach_mem_model - attach registered mem info to RxQ info
469 * @xdp_rxq: XDP RxQ info to attach the memory info to
470 * @mem: already registered memory info
472 * If the driver registers its memory providers manually, it must use this
473 * function instead of xdp_rxq_info_reg_mem_model().
476 xdp_rxq_info_attach_mem_model(struct xdp_rxq_info *xdp_rxq,
477 const struct xdp_mem_info *mem)
483 * xdp_rxq_info_detach_mem_model - detach registered mem info from RxQ info
484 * @xdp_rxq: XDP RxQ info to detach the memory info from
486 * If the driver registers its memory providers manually and then attaches it
487 * via xdp_rxq_info_attach_mem_model(), it must call this function before
488 * xdp_rxq_info_unreg().
490 static inline void xdp_rxq_info_detach_mem_model(struct xdp_rxq_info *xdp_rxq)
492 xdp_rxq->mem = (struct xdp_mem_info){ };
495 /* Drivers not supporting XDP metadata can use this helper, which
496 * rejects any room expansion for metadata as a result.
498 static __always_inline void
499 xdp_set_data_meta_invalid(struct xdp_buff *xdp)
501 xdp->data_meta = xdp->data + 1;
504 static __always_inline bool
505 xdp_data_meta_unsupported(const struct xdp_buff *xdp)
507 return unlikely(xdp->data_meta > xdp->data);
510 static inline bool xdp_metalen_invalid(unsigned long metalen)
512 unsigned long meta_max;
514 meta_max = type_max(typeof_member(struct skb_shared_info, meta_len));
515 BUILD_BUG_ON(!__builtin_constant_p(meta_max));
517 return !IS_ALIGNED(metalen, sizeof(u32)) || metalen > meta_max;
520 struct xdp_attachment_info {
521 struct bpf_prog *prog;
526 void xdp_attachment_setup(struct xdp_attachment_info *info,
527 struct netdev_bpf *bpf);
529 #define DEV_MAP_BULK_SIZE XDP_BULK_QUEUE_SIZE
531 /* Define the relationship between xdp-rx-metadata kfunc and
532 * various other entities:
533 * - xdp_rx_metadata enum
534 * - netdev netlink enum (Documentation/netlink/specs/netdev.yaml)
536 * - xdp_metadata_ops field
538 #define XDP_METADATA_KFUNC_xxx \
539 XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_TIMESTAMP, \
540 NETDEV_XDP_RX_METADATA_TIMESTAMP, \
541 bpf_xdp_metadata_rx_timestamp, \
543 XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_HASH, \
544 NETDEV_XDP_RX_METADATA_HASH, \
545 bpf_xdp_metadata_rx_hash, \
547 XDP_METADATA_KFUNC(XDP_METADATA_KFUNC_RX_VLAN_TAG, \
548 NETDEV_XDP_RX_METADATA_VLAN_TAG, \
549 bpf_xdp_metadata_rx_vlan_tag, \
552 enum xdp_rx_metadata {
553 #define XDP_METADATA_KFUNC(name, _, __, ___) name,
554 XDP_METADATA_KFUNC_xxx
555 #undef XDP_METADATA_KFUNC
556 MAX_XDP_METADATA_KFUNC,
559 enum xdp_rss_hash_type {
560 /* First part: Individual bits for L3/L4 types */
561 XDP_RSS_L3_IPV4 = BIT(0),
562 XDP_RSS_L3_IPV6 = BIT(1),
564 /* The fixed (L3) IPv4 and IPv6 headers can both be followed by
565 * variable/dynamic headers, IPv4 called Options and IPv6 called
566 * Extension Headers. HW RSS type can contain this info.
568 XDP_RSS_L3_DYNHDR = BIT(2),
570 /* When RSS hash covers L4 then drivers MUST set XDP_RSS_L4 bit in
571 * addition to the protocol specific bit. This ease interaction with
572 * SKBs and avoids reserving a fixed mask for future L4 protocol bits.
574 XDP_RSS_L4 = BIT(3), /* L4 based hash, proto can be unknown */
575 XDP_RSS_L4_TCP = BIT(4),
576 XDP_RSS_L4_UDP = BIT(5),
577 XDP_RSS_L4_SCTP = BIT(6),
578 XDP_RSS_L4_IPSEC = BIT(7), /* L4 based hash include IPSEC SPI */
579 XDP_RSS_L4_ICMP = BIT(8),
581 /* Second part: RSS hash type combinations used for driver HW mapping */
582 XDP_RSS_TYPE_NONE = 0,
583 XDP_RSS_TYPE_L2 = XDP_RSS_TYPE_NONE,
585 XDP_RSS_TYPE_L3_IPV4 = XDP_RSS_L3_IPV4,
586 XDP_RSS_TYPE_L3_IPV6 = XDP_RSS_L3_IPV6,
587 XDP_RSS_TYPE_L3_IPV4_OPT = XDP_RSS_L3_IPV4 | XDP_RSS_L3_DYNHDR,
588 XDP_RSS_TYPE_L3_IPV6_EX = XDP_RSS_L3_IPV6 | XDP_RSS_L3_DYNHDR,
590 XDP_RSS_TYPE_L4_ANY = XDP_RSS_L4,
591 XDP_RSS_TYPE_L4_IPV4_TCP = XDP_RSS_L3_IPV4 | XDP_RSS_L4 | XDP_RSS_L4_TCP,
592 XDP_RSS_TYPE_L4_IPV4_UDP = XDP_RSS_L3_IPV4 | XDP_RSS_L4 | XDP_RSS_L4_UDP,
593 XDP_RSS_TYPE_L4_IPV4_SCTP = XDP_RSS_L3_IPV4 | XDP_RSS_L4 | XDP_RSS_L4_SCTP,
594 XDP_RSS_TYPE_L4_IPV4_IPSEC = XDP_RSS_L3_IPV4 | XDP_RSS_L4 | XDP_RSS_L4_IPSEC,
595 XDP_RSS_TYPE_L4_IPV4_ICMP = XDP_RSS_L3_IPV4 | XDP_RSS_L4 | XDP_RSS_L4_ICMP,
597 XDP_RSS_TYPE_L4_IPV6_TCP = XDP_RSS_L3_IPV6 | XDP_RSS_L4 | XDP_RSS_L4_TCP,
598 XDP_RSS_TYPE_L4_IPV6_UDP = XDP_RSS_L3_IPV6 | XDP_RSS_L4 | XDP_RSS_L4_UDP,
599 XDP_RSS_TYPE_L4_IPV6_SCTP = XDP_RSS_L3_IPV6 | XDP_RSS_L4 | XDP_RSS_L4_SCTP,
600 XDP_RSS_TYPE_L4_IPV6_IPSEC = XDP_RSS_L3_IPV6 | XDP_RSS_L4 | XDP_RSS_L4_IPSEC,
601 XDP_RSS_TYPE_L4_IPV6_ICMP = XDP_RSS_L3_IPV6 | XDP_RSS_L4 | XDP_RSS_L4_ICMP,
603 XDP_RSS_TYPE_L4_IPV6_TCP_EX = XDP_RSS_TYPE_L4_IPV6_TCP | XDP_RSS_L3_DYNHDR,
604 XDP_RSS_TYPE_L4_IPV6_UDP_EX = XDP_RSS_TYPE_L4_IPV6_UDP | XDP_RSS_L3_DYNHDR,
605 XDP_RSS_TYPE_L4_IPV6_SCTP_EX = XDP_RSS_TYPE_L4_IPV6_SCTP | XDP_RSS_L3_DYNHDR,
608 struct xdp_metadata_ops {
609 int (*xmo_rx_timestamp)(const struct xdp_md *ctx, u64 *timestamp);
610 int (*xmo_rx_hash)(const struct xdp_md *ctx, u32 *hash,
611 enum xdp_rss_hash_type *rss_type);
612 int (*xmo_rx_vlan_tag)(const struct xdp_md *ctx, __be16 *vlan_proto,
617 u32 bpf_xdp_metadata_kfunc_id(int id);
618 bool bpf_dev_bound_kfunc_id(u32 btf_id);
619 void xdp_set_features_flag(struct net_device *dev, xdp_features_t val);
620 void xdp_features_set_redirect_target(struct net_device *dev, bool support_sg);
621 void xdp_features_clear_redirect_target(struct net_device *dev);
623 static inline u32 bpf_xdp_metadata_kfunc_id(int id) { return 0; }
624 static inline bool bpf_dev_bound_kfunc_id(u32 btf_id) { return false; }
627 xdp_set_features_flag(struct net_device *dev, xdp_features_t val)
632 xdp_features_set_redirect_target(struct net_device *dev, bool support_sg)
637 xdp_features_clear_redirect_target(struct net_device *dev)
642 static inline void xdp_clear_features_flag(struct net_device *dev)
644 xdp_set_features_flag(dev, 0);
647 static __always_inline u32 bpf_prog_run_xdp(const struct bpf_prog *prog,
648 struct xdp_buff *xdp)
650 /* Driver XDP hooks are invoked within a single NAPI poll cycle and thus
651 * under local_bh_disable(), which provides the needed RCU protection
652 * for accessing map entries.
654 u32 act = __bpf_prog_run(prog, xdp, BPF_DISPATCHER_FUNC(xdp));
656 if (static_branch_unlikely(&bpf_master_redirect_enabled_key)) {
657 if (act == XDP_TX && netif_is_bond_slave(xdp->rxq->dev))
658 act = xdp_master_redirect(xdp);
663 #endif /* __LINUX_NET_XDP_H__ */