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

JingPiao Chen chenjingpiao at gmail.com
Sat Aug 12 15:33:51 UTC 2017


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?

--
JingPiao Chen




More information about the Strace-devel mailing list