Skip to content

Commit 33bb54b

Browse files
committed
ci/diffs: add a diff reverting ffa327eebccf in netdev tree
See: https://lore.kernel.org/bpf/5af7b3b9-3ee1-4ef6-8431-72b40445eacd@linux.dev/ Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
1 parent 63ae362 commit 33bb54b

File tree

1 file changed

+150
-0
lines changed

1 file changed

+150
-0
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
From 1ce75c3927155863d7ac4470aa8081d455cdaa03 Mon Sep 17 00:00:00 2001
2+
From: Ihor Solodrai <ihor.solodrai@linux.dev>
3+
Date: Thu, 2 Oct 2025 09:48:40 -0700
4+
Subject: [PATCH] Revert "xdp: update mem type when page pool is used for
5+
generic XDP"
6+
7+
This reverts commit ffa327eebccf015866dd37bac073a21f83ff5be0.
8+
---
9+
include/linux/netdevice.h | 4 +---
10+
kernel/bpf/cpumap.c | 2 +-
11+
kernel/bpf/devmap.c | 2 +-
12+
net/core/dev.c | 32 +++++++++++---------------------
13+
4 files changed, 14 insertions(+), 26 deletions(-)
14+
15+
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
16+
index 02c1368aa9f4..d1a687444b27 100644
17+
--- a/include/linux/netdevice.h
18+
+++ b/include/linux/netdevice.h
19+
@@ -78,7 +78,6 @@ struct udp_tunnel_nic_info;
20+
struct udp_tunnel_nic;
21+
struct bpf_prog;
22+
struct xdp_buff;
23+
-struct xdp_rxq_info;
24+
struct xdp_frame;
25+
struct xdp_metadata_ops;
26+
struct xdp_md;
27+
@@ -4176,8 +4175,7 @@ static inline void dev_consume_skb_any(struct sk_buff *skb)
28+
}
29+
30+
u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp,
31+
- const struct bpf_prog *xdp_prog,
32+
- struct xdp_rxq_info *rxq);
33+
+ const struct bpf_prog *xdp_prog);
34+
void generic_xdp_tx(struct sk_buff *skb, const struct bpf_prog *xdp_prog);
35+
int do_xdp_generic(const struct bpf_prog *xdp_prog, struct sk_buff **pskb);
36+
int netif_rx(struct sk_buff *skb);
37+
diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c
38+
index 120daeb8f4e8..703e5df1f4ef 100644
39+
--- a/kernel/bpf/cpumap.c
40+
+++ b/kernel/bpf/cpumap.c
41+
@@ -145,7 +145,7 @@ static u32 cpu_map_bpf_prog_run_skb(struct bpf_cpu_map_entry *rcpu,
42+
for (u32 i = 0; i < skb_n; i++) {
43+
struct sk_buff *skb = skbs[i];
44+
45+
- act = bpf_prog_run_generic_xdp(skb, &xdp, rcpu->prog, NULL);
46+
+ act = bpf_prog_run_generic_xdp(skb, &xdp, rcpu->prog);
47+
switch (act) {
48+
case XDP_PASS:
49+
skbs[pass++] = skb;
50+
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
51+
index 6c2bc7d5ee04..2625601de76e 100644
52+
--- a/kernel/bpf/devmap.c
53+
+++ b/kernel/bpf/devmap.c
54+
@@ -512,7 +512,7 @@ static u32 dev_map_bpf_prog_run_skb(struct sk_buff *skb, struct bpf_dtab_netdev
55+
__skb_pull(skb, skb->mac_len);
56+
xdp.txq = &txq;
57+
58+
- act = bpf_prog_run_generic_xdp(skb, &xdp, dst->xdp_prog, NULL);
59+
+ act = bpf_prog_run_generic_xdp(skb, &xdp, dst->xdp_prog);
60+
switch (act) {
61+
case XDP_PASS:
62+
__skb_push(skb, skb->mac_len);
63+
diff --git a/net/core/dev.c b/net/core/dev.c
64+
index d584bad4f833..a64cef2c537e 100644
65+
--- a/net/core/dev.c
66+
+++ b/net/core/dev.c
67+
@@ -5318,10 +5318,10 @@ static struct netdev_rx_queue *netif_get_rxqueue(struct sk_buff *skb)
68+
}
69+
70+
u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp,
71+
- const struct bpf_prog *xdp_prog,
72+
- struct xdp_rxq_info *rxq)
73+
+ const struct bpf_prog *xdp_prog)
74+
{
75+
void *orig_data, *orig_data_end, *hard_start;
76+
+ struct netdev_rx_queue *rxqueue;
77+
bool orig_bcast, orig_host;
78+
u32 mac_len, frame_sz;
79+
__be16 orig_eth_type;
80+
@@ -5339,9 +5339,8 @@ u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp,
81+
frame_sz = (void *)skb_end_pointer(skb) - hard_start;
82+
frame_sz += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
83+
84+
- if (!rxq)
85+
- rxq = &netif_get_rxqueue(skb)->xdp_rxq;
86+
- xdp_init_buff(xdp, frame_sz, rxq);
87+
+ rxqueue = netif_get_rxqueue(skb);
88+
+ xdp_init_buff(xdp, frame_sz, &rxqueue->xdp_rxq);
89+
xdp_prepare_buff(xdp, hard_start, skb_headroom(skb) - mac_len,
90+
skb_headlen(skb) + mac_len, true);
91+
if (skb_is_nonlinear(skb)) {
92+
@@ -5420,23 +5419,17 @@ u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp,
93+
return act;
94+
}
95+
96+
-static int netif_skb_check_for_xdp(struct sk_buff **pskb,
97+
- const struct bpf_prog *prog,
98+
- struct xdp_rxq_info *rxq)
99+
+static int
100+
+netif_skb_check_for_xdp(struct sk_buff **pskb, const struct bpf_prog *prog)
101+
{
102+
struct sk_buff *skb = *pskb;
103+
int err, hroom, troom;
104+
- struct page_pool *pool;
105+
106+
- pool = this_cpu_read(system_page_pool.pool);
107+
local_lock_nested_bh(&system_page_pool.bh_lock);
108+
- err = skb_cow_data_for_xdp(pool, pskb, prog);
109+
+ err = skb_cow_data_for_xdp(this_cpu_read(system_page_pool.pool), pskb, prog);
110+
local_unlock_nested_bh(&system_page_pool.bh_lock);
111+
- if (!err) {
112+
- rxq->mem.type = MEM_TYPE_PAGE_POOL;
113+
- rxq->mem.id = pool->xdp_mem_id;
114+
+ if (!err)
115+
return 0;
116+
- }
117+
118+
/* In case we have to go down the path and also linearize,
119+
* then lets do the pskb_expand_head() work just once here.
120+
@@ -5474,13 +5467,13 @@ static u32 netif_receive_generic_xdp(struct sk_buff **pskb,
121+
122+
if (skb_cloned(skb) || skb_is_nonlinear(skb) ||
123+
skb_headroom(skb) < XDP_PACKET_HEADROOM) {
124+
- if (netif_skb_check_for_xdp(pskb, xdp_prog, xdp->rxq))
125+
+ if (netif_skb_check_for_xdp(pskb, xdp_prog))
126+
goto do_drop;
127+
}
128+
129+
__skb_pull(*pskb, mac_len);
130+
131+
- act = bpf_prog_run_generic_xdp(*pskb, xdp, xdp_prog, xdp->rxq);
132+
+ act = bpf_prog_run_generic_xdp(*pskb, xdp, xdp_prog);
133+
switch (act) {
134+
case XDP_REDIRECT:
135+
case XDP_TX:
136+
@@ -5537,10 +5530,7 @@ int do_xdp_generic(const struct bpf_prog *xdp_prog, struct sk_buff **pskb)
137+
struct bpf_net_context __bpf_net_ctx, *bpf_net_ctx;
138+
139+
if (xdp_prog) {
140+
- struct xdp_rxq_info rxq = {};
141+
- struct xdp_buff xdp = {
142+
- .rxq = &rxq,
143+
- };
144+
+ struct xdp_buff xdp;
145+
u32 act;
146+
int err;
147+
148+
--
149+
2.49.0
150+

0 commit comments

Comments
 (0)