mirror of
https://github.com/vishvananda/netlink
synced 2025-03-20 10:06:41 +00:00
fix RouteList can't list routes properly when unspecifying link
Signed-off-by: chengzhycn <chengzhycn@gmail.com>
This commit is contained in:
parent
8715fe718d
commit
337a587de1
@ -1004,8 +1004,10 @@ func (h *Handle) RouteList(link Link, family int) ([]Route, error) {
|
||||
routeFilter := &Route{}
|
||||
if link != nil {
|
||||
routeFilter.LinkIndex = link.Attrs().Index
|
||||
|
||||
return h.RouteListFiltered(family, routeFilter, RT_FILTER_OIF)
|
||||
}
|
||||
return h.RouteListFiltered(family, routeFilter, RT_FILTER_OIF)
|
||||
return h.RouteListFiltered(family, routeFilter, 0)
|
||||
}
|
||||
|
||||
// RouteListFiltered gets a list of routes in the system filtered with specified rules.
|
||||
|
@ -49,6 +49,14 @@ func TestRouteAddDel(t *testing.T) {
|
||||
t.Fatal("Route not added properly")
|
||||
}
|
||||
|
||||
routes, err = RouteList(nil, FAMILY_V4)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(routes) != 1 {
|
||||
t.Fatal("Route not listed properly")
|
||||
}
|
||||
|
||||
dstIP := net.IPv4(192, 168, 0, 42)
|
||||
routeToDstIP, err := RouteGet(dstIP)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user