Skip to content

Commit 219d609

Browse files
laoarNobody
authored and
Nobody
committed
bpf: allow setting mount device for bpffs
We noticed our tc ebpf tools can't start after we upgrade our in-house kernel version from 4.19 to 5.10. That is because of the behaviour change in bpffs caused by commit d2935de ("vfs: Convert bpf to use the new mount API"). In our tc ebpf tools, we do strict environment check. If the enrioment is not match, we won't allow to start the ebpf progs. One of the check is whether bpffs is properly mounted. The mount information of bpffs in kernel-4.19 and kernel-5.10 are as follows, - kenrel 4.19 $ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf bpffs on /sys/fs/bpf type bpf (rw,relatime) - kernel 5.10 $ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf none on /sys/fs/bpf type bpf (rw,relatime) The device name in kernel-5.10 is displayed as none instead of bpffs, then our environment check fails. Currently we modify the tools to adopt to the kernel behaviour change, but I think we'd better change the kernel code to keep the behavior consistent. After this change, the mount information will be displayed the same with the behavior in kernel-4.19, for example, $ mount -t bpf bpffs /sys/fs/bpf $ mount -t bpf bpffs on /sys/fs/bpf type bpf (rw,relatime) Fixes: d2935de ("vfs: Convert bpf to use the new mount API") Signed-off-by: Yafang Shao <[email protected]> Cc: David Howells <[email protected]>
1 parent 3b02f8d commit 219d609

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

kernel/bpf/inode.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,12 +648,26 @@ static int bpf_parse_param(struct fs_context *fc, struct fs_parameter *param)
648648
int opt;
649649

650650
opt = fs_parse(fc, bpf_fs_parameters, param, &result);
651-
if (opt < 0)
651+
if (opt < 0) {
652652
/* We might like to report bad mount options here, but
653653
* traditionally we've ignored all mount options, so we'd
654654
* better continue to ignore non-existing options for bpf.
655655
*/
656-
return opt == -ENOPARAM ? 0 : opt;
656+
if (opt == -ENOPARAM) {
657+
if (strcmp(param->key, "source") == 0) {
658+
if (param->type != fs_value_is_string)
659+
return 0;
660+
if (fc->source)
661+
return 0;
662+
fc->source = param->string;
663+
param->string = NULL;
664+
}
665+
666+
return 0;
667+
}
668+
669+
return opt;
670+
}
657671

658672
switch (opt) {
659673
case OPT_MODE:

0 commit comments

Comments
 (0)