From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Haley Subject: Re: [PATCH 7/8] net: Allow setting the network namespace by fd Date: Thu, 23 Sep 2010 10:22:25 -0400 Message-ID: <4C9B62A1.7020606@hp.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: netdev-owner@vger.kernel.org To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, Linux Containers , netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, jamal , Daniel Lezcano , Linus Torvalds , Michael Kerrisk , Ulrich Drepper , Al Viro , David Miller , "Serge E. Hallyn" , Pavel Emelyanov , Pavel Emelyanov , Ben Greear , Matt Helsley , Jonathan Corbet , Sukadev Bhattiprolu , Jan Engelhardt , Patrick McHardy List-Id: containers.vger.kernel.org On 09/23/2010 04:51 AM, Eric W. Biederman wrote: > > Take advantage of the new abstraction and allow network devices > to be placed in any network namespace that we have a fd to talk > about. > ... > +struct net *get_net_ns_by_fd(int fd) > +{ > + struct proc_inode *ei; > + struct file *file; > + struct net *net; > + > + file = NULL; No need to initialize this. > + net = ERR_PTR(-EINVAL); or this? > + file = proc_ns_fget(fd); > + if (!fd) > + goto out; > + return ERR_PTR(-EINVAL); Shouldn't this be: if (!file) And the "goto" seems wrong, especially without a {} here. Unless you meant to keep the "goto" and branch below? -Brian > + > + ei = PROC_I(file->f_dentry->d_inode); > + if (ei->ns_ops != &netns_operations) > + goto out; > + > + net = get_net(ei->ns); > +out: > + if (file) > + fput(file); > + return net; > +}