vishvananda/netlink

tc-u32 match filter

bc185174 opened this issue · 1 comments

Is it currently possible to add this tc filter using u32 match with the library?

Example given in https://man7.org/linux/man-pages/man8/tc-u32.8.html:

tc filter add dev eth0 parent 999:0 prio 99 protocol ip u32 \
                      match ip src 192.168.8.0/24 classid 1:1

Figured can do something like the following and setting the ip/mask + ipv4 header offset.

key := netlink.TcU32Key{
	Mask:    mask,
	Val:     ipAddr,
	Off:     offset,
	OffMask: offset,
}

filter := netlink.U32{}
sel := netlink.TcU32Sel{
	Keys: []netlink.TcU32Key{
                {
                        key,
                },
        },
}
filter.Sel = &sel