Re: [PATCH net] bpf: expose netns inode to bpf programs
From: David Ahern <hidden>
Date: 2017-01-31 22:11:29
On 1/25/17 8:27 PM, Alexei Starovoitov wrote:
in cases where bpf programs are looking at sockets and packets that belong to different netns, it could be useful to read netns inode, so that programs can make intelligent decisions. For example to disallow raw sockets in all non-init netns the program can do: if (sk->type == SOCK_RAW && sk->netns_inum != 0xf0000075) return 0; where 0xf0000075 inode comes from /proc/pid/ns/net Similarly TC cls_bpf/act_bpf and socket filters can do if (skb->netns_inum == expected_inode) The lack of netns awareness was a concern even for socket filters, since the application can attach the same bpf program to sockets in a different netns. Just like tc cls_bpf program can work in different netns as well, so it has to be addressed uniformly across all types of bpf programs. Signed-off-by: Alexei Starovoitov <ast@kernel.org> --- with corresponding change in 'ip vrf' that David Ahern is working on, this will address 'malfunction' concern that Andy discovered in 'ip vrf', hence this fix is needed for 'net'.
FWIW, the iproute2 patch (along with a few other namespace related fixups) can be found here:
https://github.com/dsahern/iproute2
vrf/ip-vrf branch.