Attach BPF program to socket in BCC Python


Paul Chaignon
 

On Sat, Jul 07, 2018 at 09:18:44PM +0200, spyff wrote:


Hi!

There is multiple options to attach a BPF program (BPF.attach_kprobe(),
BPF.attach_uprobe(), etc) but currently possible to attach BPF program
to socket with the BCC python frontend?
There's a BPF.attach_raw_socket method to help you with that. For examples,
see https://github.com/iovisor/bcc/tree/master/examples/networking/http_filter,
https://github.com/iovisor/bcc/tree/master/examples/networking/vlan_filter,
and https://github.com/iovisor/bcc/blob/master/examples/networking/dns_matching/dns_matching.py.

In C its easy with setsockopt SO_ATTACH_BPF but I'm not sure if its
supported in BCC python.

Thanks,
Ferenc


Ferenc Fejes
 

Hi!

There is multiple options to attach a BPF program (BPF.attach_kprobe(), BPF.attach_uprobe(), etc) but currently possible to attach BPF program to socket with the BCC python frontend? 
In C its easy with setsockopt SO_ATTACH_BPF but I'm not sure if its supported in BCC python.

Thanks,
Ferenc