[PATCH 02/26] netlink: add a basic rtnetlink parser of addr messages

Dmitry V. Levin ldv at altlinux.org
Sat Aug 12 15:41:29 UTC 2017


On Sat, Aug 12, 2017 at 11:33:51PM +0800, JingPiao Chen wrote:
> On Sat, Aug 12, 2017 at 03:05:15AM +0300, Dmitry V. Levin wrote:
> > On Thu, Aug 10, 2017 at 09:04:52AM +0800, JingPiao Chen wrote:
> > > * rtnl_addr.c: New file.
> > > * Makefile.am (strace_SOURCES): Add it.
> > > * configure.ac (AC_CHECK_HEADERS): Add linux/if_addr.h.
> > > * netlink_route.h (decode_ifaddrmsg): New prototype.
> > > * netlink_route.c (route_decoders): Add RTM_DELADDR,
> > > RTM_GETADDR, RTM_GETANYCAST, RTM_GETMULTICAST add RTM_NEWADDR.
> > > * xlat/ifaddrflags.in: New file.
> > [...]
> > > +DECL_NETLINK_ROUTE_DECODER(decode_ifaddrmsg)
> > > +{
> > > +	struct ifaddrmsg ifaddr = { .ifa_family = family };
> > > +	const size_t offset = sizeof(ifaddr.ifa_family);
> > > +
> > > +	PRINT_FIELD_XVAL("{", ifaddr, ifa_family, addrfams, "AF_???");
> > > +
> > > +	tprints(", ");
> > > +	if (len >= sizeof(ifaddr)) {
> > > +		if (!umoven_or_printaddr(tcp, addr + offset,
> > > +					 sizeof(ifaddr) - offset,
> > > +					 (void *) &ifaddr + offset)) {
> > > +			PRINT_FIELD_U("", ifaddr, ifa_prefixlen);
> > > +			PRINT_FIELD_FLAGS(", ", ifaddr, ifa_flags,
> > > +					  ifaddrflags, "IFA_F_???");
> > > +			PRINT_FIELD_U(", ", ifaddr, ifa_scope);
> > 
> > When ifaddr.ifa_flags contains one of RT_SCOPE_* constants defined
> > in linux/rtnetlink.h, it would be better if this constant was printed
> > in its symbolic form.
> 
> You means:
> 
> route_scope = RT_SCOPE_*.
> printflags_ex(ifaddr.ifa_flags, NULL, ifaddrflags, route_scope, NULL);
> 
> I do not understand why ifaddr.ifa_flags contain RT_SCOPE_* constants?

Of course it's ifa_scope, not ifa_flags:
PRINT_FIELD_XVAL(", ", ifaddr, ifa_scope, NULL);


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170812/0c0750e9/attachment.bin>


More information about the Strace-devel mailing list