vrf: fix route filter to use output iface

current route filter uses RT_FILTER_IIF in conjunction with LinkIndex.
This combination is ignored by netlink, rendering the filter
ineffective

Signed-off-by: Poh Chiat Koh <poh@inter.link>
This commit is contained in:
Poh Chiat Koh
2023-07-14 17:19:49 +02:00
parent 1561794ae9
commit c1a7948b19
2 changed files with 170 additions and 12 deletions

View File

@ -111,7 +111,7 @@ func addInterface(vrf *netlink.Vrf, intf string) error {
LinkIndex: i.Attrs().Index,
Scope: netlink.SCOPE_UNIVERSE, // Exclude local and connected routes
}
filterMask := netlink.RT_FILTER_IIF | netlink.RT_FILTER_SCOPE // Filter based on link index and scope
filterMask := netlink.RT_FILTER_OIF | netlink.RT_FILTER_SCOPE // Filter based on link index and scope
routes, err := netlink.RouteListFiltered(netlink.FAMILY_ALL, filter, filterMask)
if err != nil {
return fmt.Errorf("failed getting all routes for %s", intf)