Commit f72909f1 authored by Gary Lin's avatar Gary Lin Committed by Brenden Blanco

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.
parent 007d28c5
...@@ -160,7 +160,7 @@ while 1: ...@@ -160,7 +160,7 @@ while 1:
break; break;
if mode == BPF.XDP: if mode == BPF.XDP:
b.remove_xdp(device) b.remove_xdp(device, flags)
else: else:
ip.tc("del", "clsact", idx) ip.tc("del", "clsact", idx)
ipdb.release() ipdb.release()
...@@ -591,12 +591,12 @@ class BPF(object): ...@@ -591,12 +591,12 @@ class BPF(object):
% (dev, errstr)) % (dev, errstr))
@staticmethod @staticmethod
def remove_xdp(dev): def remove_xdp(dev, flags=0):
''' '''
This function removes any BPF function from a device on the This function removes any BPF function from a device on the
device driver level (XDP) 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: if res < 0:
errstr = os.strerror(ct.get_errno()) errstr = os.strerror(ct.get_errno())
raise Exception("Failed to detach BPF from device %s: %s" raise Exception("Failed to detach BPF from device %s: %s"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment