pyroute2 icon indicating copy to clipboard operation
pyroute2 copied to clipboard

filter api can not match mac address

Open JackSunshine opened this issue 5 years ago • 2 comments

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.

JackSunshine avatar Oct 29 '19 06:10 JackSunshine

Let's see what can we do here. Thanks for the report

svinota avatar Nov 05 '19 15:11 svinota

@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"])

Vic063 avatar Dec 13 '19 13:12 Vic063