[PATCH] Add netlink domain sockets support to socketutils

Masatake YAMATO yamato at redhat.com
Sun May 15 06:45:12 UTC 2016


On Sun, 15 May 2016 02:27:36 +0300, "Dmitry V. Levin" <ldv at altlinux.org> wrote:
>> +	if (netlink_proto) {
>> +		if (asprintf(&details, "%s:[%s]", proto_name,
>> +			    netlink_proto) < 0)
> 
> I've tried this with "ip l" command, and it printed
> <NETLINK:[NETLINK_ROUTE]>, which looks redundant.
>
> Wouldn't it be more useful to print just netlink_proto but also add more
> netlink specific information, e.g. <NETLINK_ROUTE:[ndiag_portid]>?

How about <NETLINK:[ROUTE]> ?

`NETLINK_' prefix comes from netlink_protocols.h.
As far as seeing the contents of netlink_protocols array,
it seems that all entries have the same prefix.
The prefix can be trimmed before build a string which will be cached:

+	if (netlink_proto) {
++		if (has_prefix (netlink_proto, "NETLINK_"))
++			netlink_proto += netlink_proto + strlen ("NETLINK_");
+		if (asprintf(&details, "%s:[%s]", proto_name,
+			    netlink_proto) < 0)
+			return -1;
+	} else {

Masatake YAMATO




More information about the Strace-devel mailing list