From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: netns_id in bpf_sk_lookup_{tcp,udp} Date: Tue, 20 Nov 2018 22:12:12 -0700 Message-ID: <3df598c0-d90a-c794-e19b-22e0f61d4f49@gmail.com> References: <15bf5496-523f-564f-443e-f3262bb9e668@gmail.com> <90ae2d6b-049a-90a2-05e5-66700e885b39@gmail.com> <55816e4b-1a00-a1f3-6514-f755b992a049@6wind.com> <077323f3-3026-06b5-fb4b-54383e5387f6@gmail.com> <1754196d-67a8-6632-878f-72e0e6c2d917@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: netdev , daniel@iogearbox.net To: nicolas.dichtel@6wind.com, Joe Stringer Return-path: Received: from mail-pl1-f194.google.com ([209.85.214.194]:34589 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbeKUPpI (ORCPT ); Wed, 21 Nov 2018 10:45:08 -0500 Received: by mail-pl1-f194.google.com with SMTP id f12-v6so3707261plo.1 for ; Tue, 20 Nov 2018 21:12:15 -0800 (PST) In-Reply-To: <1754196d-67a8-6632-878f-72e0e6c2d917@6wind.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 11/20/18 2:05 AM, Nicolas Dichtel wrote: > Le 20/11/2018 à 00:46, David Ahern a écrit : > [snip] >> That revelation shows another hole: >> $ ip netns add foo >> $ ip netns set foo 0xffffffff > It also works with 0xf0000000 ... > >> $ ip netns list >> foo (id: 0) >> >> Seems like alloc_netid() should error out if reqid < -1 (-1 being the >> NETNSA_NSID_NOT_ASSIGNED flag) as opposed to blindly ignoring it. > alloc_netid() tries to allocate the specified nsid if this nsid is valid, ie >= > 0, else it allocates a new nsid (actually the lower available). > This is the expected behavior. > > For me, it's more an iproute2 problem, which parses an unsigned and silently > cast it to a signed value. > > -----8<-------------------- > > From 79bac98bfd0acbf2526a3427d5aba96564844209 Mon Sep 17 00:00:00 2001 > From: Nicolas Dichtel > Date: Tue, 20 Nov 2018 09:59:46 +0100 > Subject: ipnetns: parse nsid as a signed integer > > Don't confuse the user, nsid is a signed interger, this kind of command > should return an error: 'ip netns set foo 0xffffffff'. > > Signed-off-by: Nicolas Dichtel > --- > ip/ipnetns.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/ip/ipnetns.c b/ip/ipnetns.c > index 0eac18cf2682..54346ac987cf 100644 > --- a/ip/ipnetns.c > +++ b/ip/ipnetns.c > @@ -739,8 +739,7 @@ static int netns_set(int argc, char **argv) > { > char netns_path[PATH_MAX]; > const char *name; > - unsigned int nsid; > - int netns; > + int netns, nsid; > > if (argc < 1) { > fprintf(stderr, "No netns name specified\n"); > @@ -754,7 +753,7 @@ static int netns_set(int argc, char **argv) > /* If a negative nsid is specified the kernel will select the nsid. */ > if (strcmp(argv[1], "auto") == 0) > nsid = -1; > - else if (get_unsigned(&nsid, argv[1], 0)) > + else if (get_integer(&nsid, argv[1], 0)) > invarg("Invalid \"netnsid\" value\n", argv[1]); > > snprintf(netns_path, sizeof(netns_path), "%s/%s", NETNS_RUN_DIR, name); > Nicolas: Can you send this formally and cc Stephen so it goes into the master branch? Thanks