Use Addrmsg when listing addrs, and RtMsg when listing routes

This commit is contained in:
conjones 2022-03-23 10:45:47 +00:00 committed by Vish (Ishaya) Abrams
parent 083e92e21e
commit 657c30750a
2 changed files with 4 additions and 3 deletions

View File

@ -176,7 +176,7 @@ func AddrList(link Link, family int) ([]Addr, error) {
// The list can be filtered by link and ip family.
func (h *Handle) AddrList(link Link, family int) ([]Addr, error) {
req := h.newNetlinkRequest(unix.RTM_GETADDR, unix.NLM_F_DUMP)
msg := nl.NewIfInfomsg(family)
msg := nl.NewIfAddrmsg(family)
req.AddData(msg)
msgs, err := req.Execute(unix.NETLINK_ROUTE, unix.RTM_NEWADDR)

View File

@ -1030,8 +1030,9 @@ func RouteListFiltered(family int, filter *Route, filterMask uint64) ([]Route, e
// All rules must be defined in RouteFilter struct
func (h *Handle) RouteListFiltered(family int, filter *Route, filterMask uint64) ([]Route, error) {
req := h.newNetlinkRequest(unix.RTM_GETROUTE, unix.NLM_F_DUMP)
infmsg := nl.NewIfInfomsg(family)
req.AddData(infmsg)
rtmsg := nl.NewRtMsg()
rtmsg.Family = uint8(family)
req.AddData(rtmsg)
msgs, err := req.Execute(unix.NETLINK_ROUTE, unix.RTM_NEWROUTE)
if err != nil {