lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <605c7f63-a97e-aad0-c492-7b0ddf8b19fc@gmail.com>
Date:   Thu, 1 Feb 2018 13:09:54 +0200
From:   Serhey Popovych <serhe.popovych@...il.com>
To:     David Ahern <dsahern@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH iproute2-next v2 5/6] utils: Introduce and use
 print_name_and_link() to print name@...k

David Ahern wrote:
> On 1/30/18 11:09 AM, Serhey Popovych wrote:
>> There is at least three places implementing same things: two in
>> ipaddress.c print_linkinfo() & print_linkinfo_brief() and one in
>> bridge/link.c.
>>
>> These two implementations diverge from each other very little:
>> bridge/link.c does not support JSON output at the moment and
>> print_linkinfo_brief() does not handle IFLA_LINK_NETNS case.
>>
>> Introduce and use print_name_and_link() routine to handle name@...k
>> output in all possible variations; respect IFLA_LINK_NETNS attribute to
>> handle case when link is in different namespace; use "if%d" template
>> for interface name instead of "<nil>" to share logic with other
>> code (e.g. ll_name_to_index() and ll_index_to_name()) supporting such
>> template.
>>
>> Signed-off-by: Serhey Popovych <serhe.popovych@...il.com>
>> ---
>>  bridge/link.c   |   13 +++----------
>>  include/utils.h |    4 ++++
>>  ip/ipaddress.c  |   48 ++----------------------------------------------
>>  lib/utils.c     |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>  4 files changed, 60 insertions(+), 56 deletions(-)
>>
>> diff --git a/bridge/link.c b/bridge/link.c
>> index a11cbb1..90c9734 100644
>> --- a/bridge/link.c
>> +++ b/bridge/link.c
>> @@ -125,20 +125,13 @@ int print_linkinfo(const struct sockaddr_nl *who,
>>  	if (n->nlmsg_type == RTM_DELLINK)
>>  		fprintf(fp, "Deleted ");
>>  
>> -	fprintf(fp, "%d: %s ", ifi->ifi_index,
>> -		tb[IFLA_IFNAME] ? rta_getattr_str(tb[IFLA_IFNAME]) : "<nil>");
>> +	fprintf(fp, "%d: ", ifi->ifi_index);
>> +
>> +	print_name_and_link("%s: ", COLOR_NONE, name, tb);
> 
> It only needs tb[IFLA_LINK] so just pass it. Makes the arg list
> consistent with the function name too.
> 

Unfortunately not only: it uses IFLA_LINK_NETNSID too. May be adding
"_rta" suffix to this routine as we did in the past when introducing
get_addr_rta() and similar routines? In my opinion this is preferred
than adding one more parameters to the routine.

On the other hand tb[IFLA_LINK] taken by rta_getaddr_u32() (but actually
it is "int" with values strictly greater than zero as implemented in
kernel), so making function to catch missing tb[IFLA_LINK] would require
some helper and may broke "should never happen" case when
(int)rta_getattr_u32(tb[IFLA_LINK]) < 0.

Currently we may call ll_index_to_name() with negative iflink.



Download attachment "signature.asc" of type "application/pgp-signature" (491 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ