Thread (25 messages) flat view 25 messages, 4 authors, 2021-01-24

Re: [RFC PATCH 3/7] tun: allow use of BPF_PROG_TYPE_SCHED_CLS program type

From: Yuri Benditovich <hidden>
Date: 2021-01-12 21:53:39
Also in: bpf, kvm, lkml, virtualization

On Tue, Jan 12, 2021 at 9:42 PM Yuri Benditovich
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
This program type can set skb hash value. It will be useful
when the tun will support hash reporting feature if virtio-net.

Signed-off-by: Yuri Benditovich <redacted>
---
 drivers/net/tun.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 7959b5c2d11f..455f7afc1f36 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2981,6 +2981,8 @@ static int tun_set_ebpf(struct tun_struct *tun, struct tun_prog __rcu **prog_p,
                prog = NULL;
        } else {
                prog = bpf_prog_get_type(fd, BPF_PROG_TYPE_SOCKET_FILTER);
+               if (IS_ERR(prog))
+                       prog = bpf_prog_get_type(fd, BPF_PROG_TYPE_SCHED_CLS);
                if (IS_ERR(prog))
                        return PTR_ERR(prog);
        }
Comment from Alexei Starovoitov:
Patches 1 and 2 are missing for me, so I couldn't review properly,
but this diff looks odd.
It allows sched_cls prog type to attach to tun.
That means everything that sched_cls progs can do will be done from tun hook?
sched_cls assumes l2 and can modify the packet.
I think crashes are inevitable.
--
2.17.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help