NIKSS-vSwitch / nikss

Native In-Kernel P4-programmable Software Switch for Software-Defined Networking (previously PSA-eBPF)
Apache License 2.0
47 stars 4 forks source link

validate-os: remove bpf device field check #110

Closed Trigary closed 4 months ago

Trigary commented 4 months ago

I use NIKSS on a Hyper-V VM running Ubuntu 20.04 (kernel: 5.8). With this setup, BPF is mounted on device "none":

$ mount | grep bpf
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)

nikss-ctl validate-os interpreted this as BPF not being mounted:

$ nikss-ctl validate-os
Kernel family: Linux ... OK
Kernel version: 5.8 ... OK
Machine architecture: x86_64 ... OK
BPF filesystem is mounted: false ... ERROR (BPF filesystem is not mounted)
BPF filesystem mount point:  ... ERROR (expected BPF filesystem to be mounted on /sys/fs/bpf)
BPF filesystem in read-write mode: false ... ERROR (BPF filesystem is not mounted in read-write mode)
Kernel build option CONFIG_BPF: yes ... OK
[...]
Invalid system configuration, NIKSS will not work.

This PR fixes that issue by removing the check that requires the mounted device to be named bpf.

Credit goes to @mikroskeem for discovering why validate-os was rejecting my system.

mikroskeem commented 4 months ago

fs_type check is sufficient, as filesystem type is enforced on kernel level. Rough explanation - you can specify pretty much anything as a source to (some? all? we care about bpf here) virtual filesystems, it's ignored and passed as-is.

e.g.

# mount -t bpf abcdef /mnt/bpf
# mount -t tmpfs xyz /mnt/tmp
# mount -t bpf /dev/sda /mnt/bpf2
# mount -t bpf /dev/nonexistent /mnt/bpf3
# mount | tail -4
abcdef on /mnt/bpf type bpf (rw,relatime)
xyz on /mnt/tmp type tmpfs (rw,relatime)
/dev/sda on /mnt/bpf2 type bpf (rw,relatime)
/dev/nonexistent on /mnt/bpf3 type bpf (rw,relatime)
tatry commented 4 months ago

Thanks @mikroskeem, that was I was not sure about in my review.