[PATCH 5/6] netlink: decode "family" field of Netlink GENERIC protocol

JingPiao Chen chenjingpiao at gmail.com
Sun Jun 11 00:20:04 UTC 2017


On Sat, Jun 10, 2017 at 03:32:46PM +0900, Masatake YAMATO wrote:
[...]
> diff --git a/netlink.c b/netlink.c
> index 049843d..d8a735e 100644
> --- a/netlink.c
> +++ b/netlink.c
> @@ -100,8 +100,8 @@ get_fd_nl_family(struct tcb *const tcp, const int fd)
>  	return NL_FAMILY_ERROR;
>  }
>  
> -static const struct {
> -	const struct xlat *const xlat;
> +static struct {
> +	const struct xlat * xlat;
>  	const char *const dflt;
>  } nlmsg_types[] = {
>  	[NETLINK_AUDIT] = { nl_audit_types, "AUDIT_???" },
> @@ -109,7 +109,8 @@ static const struct {
>  	[NETLINK_ROUTE] = { nl_route_types, "RTM_???" },
>  	[NETLINK_SELINUX] = { nl_selinux_types, "SELNL_MSG_???" },
>  	[NETLINK_SOCK_DIAG] = { nl_sock_diag_types, "SOCK_DIAG_???" },
> -	[NETLINK_XFRM] = { nl_xfrm_types, "XFRM_MSG_???" }
> +	[NETLINK_XFRM] = { nl_xfrm_types, "XFRM_MSG_???" },
> +	[NETLINK_GENERIC] = { NULL, "GENERIC_FAMILY_???" }

it seem NETLINK_* should keep sorted.

>  };
>  
>  /*
> @@ -119,6 +120,9 @@ static const struct {
>  static void
>  decode_nlmsg_type(const uint16_t type, const unsigned int family)
>  {
> +	if (!nlmsg_types [NETLINK_GENERIC].xlat)
> +		nlmsg_types [NETLINK_GENERIC].xlat = genl_families_xlat();
> +
>  	if (family < ARRAY_SIZE(nlmsg_types)
>  	    && nlmsg_types[family].xlat) {
>  		if (family == NETLINK_NETFILTER) {
--
JingPiao Chen




More information about the Strace-devel mailing list