Re: libmnl & rtnetlink questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 21, 2020 at 01:30:05PM +0200, Pablo Neira Ayuso wrote:
> On Mon, Apr 13, 2020 at 02:00:22PM -0500, Ian Pilcher wrote:
> > First off, please let me know if this list isn't an appropriate place
> > for these sorts of questions.
> > 
> > With that out of the way, I'm trying to understand the sample program
> > at:
> > 
> >   http://git.netfilter.org/libmnl/tree/examples/rtnl/rtnl-link-dump.c
> > 
> > I've been able to puzzle most of it out, but I'm confused by the
> > use of the struct rtgenmsg (declared on line 88 and used on lines
> > 95-96).
> > 
> > * Based on rtnetlink(7), shouldn't this more properly be a struct
> >   ifinfomsg (even though only rtgen_family/ifi_family is set)?
> 
> RTM_GETLINK expects ifinfomsg, yes.

commit 905cf0abe8c2c892313f08e38d808eee4e794987
Author: David Ahern <dsahern@xxxxxxxxx>
Date:   Sun Oct 7 20:16:30 2018 -0700

    rtnetlink: Update rtnl_dump_ifinfo for strict data checking
    
    Update rtnl_dump_ifinfo for strict data checking. If the flag is set,
    the dump request is expected to have an ifinfomsg struct as the header
    potentially followed by one or more attributes. Any data passed in the
    header or as an attribute is taken as a request to influence the data
    returned. Only values supported by the dump handler are allowed to be
    non-0 or set in the request. At the moment only the IFA_TARGET_NETNSID,
    IFLA_EXT_MASK, IFLA_MASTER, and IFLA_LINKINFO attributes are supported.

Probably this explains the reason why.

> > * More importantly, why is setting this to AF_PACKET required at all?
> >   Testing the program without setting it reveals that it definitely is
> >   required, but I haven't been able to find anything that explains *why*
> >   that is the case.
> 
> Probably AF_UNSPEC is more appropriate there?

Would you send a patch for this?

Thanks.



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux