From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38634 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752917AbeBTRSk (ORCPT ); Tue, 20 Feb 2018 12:18:40 -0500 Date: Tue, 20 Feb 2018 18:18:37 +0100 From: Sabrina Dubroca To: David Ahern Cc: netdev@vger.kernel.org, sbrivio@redhat.com, serhe.popovych@gmail.com Subject: Re: [PATCH iproute2-next v2] ip link: add support to display extended tun attributes Message-ID: <20180220171837.GA10666@bistromath.localdomain> References: <2ee799472ddf052722c5682506223244ce272606.1519124425.git.sd@queasysnail.net> <676f02bb-d2eb-8fdb-5c56-f16338ecc162@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <676f02bb-d2eb-8fdb-5c56-f16338ecc162@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: 2018-02-20, 09:34:15 -0700, David Ahern wrote: > 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. Thanks! > > > > 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. Actually, I didn't want to do that, because that command currently always prints a numeric value, and I don't want to change the output format (in case someone is parsing it and expects the raw uid/gid). -- Sabrina