svinota / pyroute2

Python Netlink and PF_ROUTE library — network configuration and monitoring
https://pyroute2.org/
Other
960 stars 248 forks source link

"get_filters" TCA_U32_HASH information is not correct #618

Open ralonsoh opened 5 years ago

ralonsoh commented 5 years ago

Function "pyroute2.iproute.linux.RTNL_API.get_filters" returns an incorrect TCA_U32_HASH value. The filter ID should match the ID returned in the CLI. In this case, the filter ID is 800::800. The value returned by this library is TCA_U32_HASH=2147483648 (equal to 0x80000000).

Filter with priority 49: filter parent ffff: protocol all pref 49 u32 chain 0 filter parent ffff: protocol all pref 49 u32 chain 0 fh 800: ht divisor 1 filter parent ffff: protocol all pref 49 u32 chain 0 fh 800::800 order 2048 key ht 800 bkt 0 flowid :1 not_in_hw match 00000000/00000000 at 0 police 0x1 rate 2560Kbit burst 192000b mtu 1200b action drop overhead 0b ref 1 bind 1

Structure returned: <class 'dict'>: {'family': 0, 'pad1': 0, 'pad2': 0, 'index': 2, 'handle': 2147485696, 'parent': 4294901760, 'info': 3212032, 'attrs': (('TCA_KIND', 'u32'), ('UNKNOWN', {'header': {'length': 8, 'type': 11}}), ('TCA_OPTIONS', {'attrs': (('TCA_U32_SEL', {'flags': 1, 'offshift': 0, 'nkeys': 1, 'align': (), 'offmask': 0, 'off': 0, 'offoff': 0, 'hoff': 0, 'hmask': 0, 'keys': ({'key_mask': 0, 'key_val': 0, 'key_off': 0, 'key_offmask': 0},)}), ('TCA_U32_HASH', 2147483648), ('TCA_U32_CLASSID', 1), ('UNKNOWN', {'header': {'length': 8, 'type': 11}}), ('TCA_U32_POLICE', {'attrs': (('TCA_POLICE_TBF', {'index': 1, 'action': 2, 'limit': 0, 'burst': 9375000, 'mtu': 1200, 'rate_cell_log': 0, 'rate___reserved': 0, 'rate_overhead': 0, 'rate_cell_align': 0, 'rate_mpu': 0, 'rate': 320000, 'peak_celllog': 0, 'peakreserved': 0, 'peak_overhead': 0, 'peak_cell_align': 0, 'peak_mpu': 0, 'peak': 0, 'refcnt': 1, 'bindcnt': 1, 'capab': 0}), ('UNKNOWN', {'header': {'length': 36, 'type': 6}}))}))}), ('TCA_STATS', {'bytes': 0, 'packets': 0, 'drop': 0, 'overlimits': 0, 'bps': 0, 'pps': 0, 'qlen': 0, 'backlog': 0})), 'header': {'length': 260, 'type': 44, 'flags': 2, 'sequence_number': 255, 'pid': 10153, 'error': None, 'stats': (0, 0, 0)}, 'event': 'RTM_NEWTFILTER'}

svinota commented 5 years ago

Thanks, trying to look into

ralonsoh commented 5 years ago

For both #617 and this one, #618, I can help debugging and coding. The problem is I don't understand how the raw data is packed.