pyroute2
pyroute2 copied to clipboard
filter api can not match mac address
pyroute2 filter API doesn't support matching mac address, for example, I can install a filter rule through the following command line:
tc filter add dev vnet1 parent 1:0 protocol ip prio 5 u32 match u16 0x0800 0xffff at -2 match u16 0xca67 0xffff at -4 match u32 0x5254005c 0xffffffff at -8 flowid 1:10
but I can't install this rule through the tc API, cause the offset is negative.
Let's see what can we do here. Thanks for the report
@JackSunshine: Could you please test the fix issued in PR #656 ?
Here is the code I used to test: from pyroute2 import IPRoute, protocols
ipr = IPRoute() idx = ipr.link_lookup(ifname='vnet1')[0] ipr.tc('add-filter', 'u32', idx, parent=0x10000, prio=5, protocol=protocols.ETH_P_IP, target=0x10010, keys=["0x0800/0xffff-2", "0xca67/0xffff-4", "0x5254005c/0xffffffff-8"])