mirror of
https://github.com/torvalds/linux.git
synced 2026-10-23 15:32:04 +02:00
net: make dev_xdp_sb_prog_count() see programs attached through a link
ethtool refuses to enable tcp-data-split on a device running
a single-buffer XDP program (which can't deal with the payload
landing in a separate buffer). dev_xdp_sb_prog_count() only looks
at xdp_state[].prog though, ignoring bpf_link integration.
Get the prog pointer from dev_xdp_prog(), which will consult both.
bpf_xdp_link_update() needs a bit of a touch-up, too, since
ethtool calls dev_xdp_sb_prog_count() with just the instance
lock (for ops-locked devices) - we now have to make sure the
link updates happen under that lock.
Spotted by AI while reviewing the XDP propagation series,
verified and tested on netdevsim with a C test along these lines:
link = bpf_program__attach_xdp(prog, ifindex);
system("ethtool -G eth0 tcp-data-split on")
Fixes: 197258f0ef ("net: ethtool: add hds_config member in ethtool_netdev_state")
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20261001012559.297751-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
aaaaf87ea9
commit
d333c8bca6
|
|
@ -10364,13 +10364,15 @@ EXPORT_SYMBOL_GPL(dev_xdp_prog_count);
|
|||
|
||||
u8 dev_xdp_sb_prog_count(struct net_device *dev)
|
||||
{
|
||||
struct bpf_prog *prog;
|
||||
u8 count = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < __MAX_XDP_MODE; i++)
|
||||
if (dev->xdp_state[i].prog &&
|
||||
!dev->xdp_state[i].prog->aux->xdp_has_frags)
|
||||
for (i = 0; i < __MAX_XDP_MODE; i++) {
|
||||
prog = dev_xdp_prog(dev, i);
|
||||
if (prog && !prog->aux->xdp_has_frags)
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
@ -10750,11 +10752,12 @@ static int bpf_xdp_link_update(struct bpf_link *link, struct bpf_prog *new_prog,
|
|||
bpf_op = dev_xdp_bpf_op(xdp_link->dev, mode);
|
||||
err = dev_xdp_install(xdp_link->dev, mode, bpf_op, NULL,
|
||||
xdp_link->flags, new_prog);
|
||||
if (!err)
|
||||
old_prog = xchg(&link->prog, new_prog);
|
||||
netdev_unlock_ops(xdp_link->dev);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
|
||||
old_prog = xchg(&link->prog, new_prog);
|
||||
bpf_prog_put(old_prog);
|
||||
|
||||
out_unlock:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user