From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Lezcano Subject: Re: [PATCH 7/8] net: Allow setting the network namespace by fd Date: Fri, 24 Sep 2010 15:46:28 +0200 Message-ID: <4C9CABB4.3010002@fr.ibm.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Pavel Emelyanov , Ulrich Drepper , netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jonathan Corbet , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jan Engelhardt , Linux Containers , Al Viro , netfilter-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Michael Kerrisk , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Ben Greear , Sukadev Bhattiprolu , Linus Torvalds , David Miller , Pavel Emelyanov To: "Eric W. Biederman" Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org On 09/23/2010 10: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. > > Signed-off-by: Eric W. Biederman > --- [ ... ] > +struct net *get_net_ns_by_fd(int fd) > +{ > + struct proc_inode *ei; > + struct file *file; > + struct net *net; > + > + file = NULL; > + net = ERR_PTR(-EINVAL); > + file = proc_ns_fget(fd); > + if (!fd) > + goto out; > + return ERR_PTR(-EINVAL); > + > + ei = PROC_I(file->f_dentry->d_inode); > + if (ei->ns_ops !=&netns_operations) > + goto out; Is this check necessary here ? proc_ns_fget checks "file->f_op != &ns_file_operations", no ?