From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f173.google.com ([209.85.192.173]:43567 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456AbeBTQe2 (ORCPT ); Tue, 20 Feb 2018 11:34:28 -0500 Received: by mail-pf0-f173.google.com with SMTP id z14so2711219pfe.10 for ; Tue, 20 Feb 2018 08:34:28 -0800 (PST) Subject: Re: [PATCH iproute2-next v2] ip link: add support to display extended tun attributes To: Sabrina Dubroca , netdev@vger.kernel.org Cc: sbrivio@redhat.com, serhe.popovych@gmail.com References: <2ee799472ddf052722c5682506223244ce272606.1519124425.git.sd@queasysnail.net> From: David Ahern Message-ID: <676f02bb-d2eb-8fdb-5c56-f16338ecc162@gmail.com> Date: Tue, 20 Feb 2018 09:34:15 -0700 MIME-Version: 1.0 In-Reply-To: <2ee799472ddf052722c5682506223244ce272606.1519124425.git.sd@queasysnail.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 2/20/18 5:43 AM, Sabrina Dubroca wrote: > Signed-off-by: Sabrina Dubroca > Reviewed-by: Stefano Brivio > --- > v2: define print_onoff to print flags, fix checkpatch warnings, drop > header changes > > ip/iptuntap.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) applied to iproute2-next. > > diff --git a/ip/iptuntap.c b/ip/iptuntap.c > index 4628db2832b4..07253870472f 100644 > --- a/ip/iptuntap.c > +++ b/ip/iptuntap.c > @@ -469,3 +469,89 @@ int do_iptuntap(int argc, char **argv) > *argv); > exit(-1); > } > + > +static void print_owner(FILE *f, uid_t uid) > +{ > + struct passwd *pw = getpwuid(uid); > + > + if (pw) > + fprintf(f, "user %s ", pw->pw_name); > + else > + fprintf(f, "user %u ", uid); > +} > + > +static void print_group(FILE *f, gid_t gid) > +{ > + struct group *group = getgrgid(gid); > + > + if (group) > + fprintf(f, "group %s ", group->gr_name); > + else > + fprintf(f, "group %u ", gid); > +} > + Those helpers can be re-used to make 'ip tuntap show' better too.