From: Gary Lin Date: Fri, 18 Aug 2017 09:42:08 +0000 (+0800) Subject: Allow the flags to be specified in remove_xdp() X-Git-Tag: submit/tizen_4.0/20171018.110122~36 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f72909f15be3a1e015f0dfa7f953ca8192b07977;p=platform%2Fupstream%2Fbcc.git Allow the flags to be specified in remove_xdp() When detaching a generic XDP program to an interface without native XDP support, remove_xdp() showed the following message: bpf: nlmsg error Operation not supported Add the flags parameter to notify the kernel that it's a generic XDP program. --- diff --git a/examples/networking/xdp/xdp_drop_count.py b/examples/networking/xdp/xdp_drop_count.py index 0a5c7400..ff0af0fe 100755 --- a/examples/networking/xdp/xdp_drop_count.py +++ b/examples/networking/xdp/xdp_drop_count.py @@ -160,7 +160,7 @@ while 1: break; if mode == BPF.XDP: - b.remove_xdp(device) + b.remove_xdp(device, flags) else: ip.tc("del", "clsact", idx) ipdb.release() diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py index 5488f529..dcfa83f1 100644 --- a/src/python/bcc/__init__.py +++ b/src/python/bcc/__init__.py @@ -591,12 +591,12 @@ class BPF(object): % (dev, errstr)) @staticmethod - def remove_xdp(dev): + def remove_xdp(dev, flags=0): ''' This function removes any BPF function from a device on the device driver level (XDP) ''' - res = lib.bpf_attach_xdp(dev.encode("ascii"), -1, 0) + res = lib.bpf_attach_xdp(dev.encode("ascii"), -1, flags) if res < 0: errstr = os.strerror(ct.get_errno()) raise Exception("Failed to detach BPF from device %s: %s"