test ./tools/testing/selftests/bpf/test_offload.py failed

From: Jie2x Zhou
Date: Wed Sep 07 2022 - 01:18:50 EST


hi,

I try to know why output following error?
I found that "disable_ifindex" file do not set read function, so return -EINVAL when do read.
Is it a bug in test_offload.py?

test output:
selftests: bpf: test_offload.py
Test destruction of generic XDP...
......
raise Exception("Command failed: %s\n%s" % (proc.args, stderr))
Exception: Command failed: cat /sys/kernel/debug/netdevsim/netdevsim0//ports/0/dev/hwstats/l3/disable_ifindex

cat: /sys/kernel/debug/netdevsim/netdevsim0//ports/0/dev/hwstats/l3/disable_ifindex: Invalid argument
not ok 20 selftests: bpf: test_offload.py # exit=1

source code:
In drivers/net/netdevsim/hwstats.c:
define NSIM_DEV_HWSTATS_FOPS(ACTION, TYPE) \
{ \
.fops = { \
.open = simple_open, \
.write = nsim_dev_hwstats_do_write, \
.llseek = generic_file_llseek, \
.owner = THIS_MODULE, \
}, \
.action = ACTION, \
.type = TYPE, \
}

static const struct nsim_dev_hwstats_fops nsim_dev_hwstats_l3_disable_fops =
NSIM_DEV_HWSTATS_FOPS(NSIM_DEV_HWSTATS_DO_DISABLE,
NETDEV_OFFLOAD_XSTATS_TYPE_L3);

debugfs_create_file("disable_ifindex", 0600, hwstats->l3_ddir, hwstats,
&nsim_dev_hwstats_l3_disable_fops.fops);

In fs/read_write.c:
ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
{
......
if (file->f_op->read)
ret = file->f_op->read(file, buf, count, pos);
else if (file->f_op->read_iter)
ret = new_sync_read(file, buf, count, pos);
else
ret = -EINVAL;
......
}

best regards,