OpenVZ Forum - RDF feed
type: channel
items: [PATCH] Teach cifs about network namespaces.
items: Re: [PATCH] Teach cifs about network namespaces.
items: Re: [PATCH] Teach cifs about network namespaces (take 2)

[PATCH] Teach cifs about network namespaces.
type: item
description: From: Rob Landley <rlandley@parallels.com> Teach cifs about network namespaces, so mounting uses adresses and routing visible from a container rather than from init context. For a long drawn out test reproduction sequence, see: http://landley.livejournal.com/47024.html http://landley.livejournal.com/47205.html http://landley.livejournal.com/47476.html Signed-off-by: Rob Landley <rlandley@parallels.com> --- fs/cifs/cifsglob.h | 32 ++++++++++++++++++++++++++++++++ fs/cifs/connect.c | 22 +++++++++++++++++----- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 7136c0c..86f31bb 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -168,6 +168,9 @@ struct TCP_Server_Info { struct sockaddr_in6 sockAddr6; } addr; struct sockaddr_storage srcaddr; /* locally bind to this IP */ +#ifdef CONFIG_NET_NS + struct net *net; +#endif wait_queue_head_t response_q; wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/ struct list_head pending_mid_q; @@ -227,6 +230,35 @@ struct TCP_Server_Info { }; /* + * Macros to allow the TCP_Server_Info->net field and related code to drop out + * when CONFIG_NET_NS isn't set. + */ + +static inline struct net * +cifs_net_ns(struct TCP_Server_Info *srv) +{ +#ifdef CONFIG_NET_NS + return srv->net; +#else + return &init_net; +#endif +} + +static inline void +cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net) +{ +#ifdef CONFIG_NET_NS + srv->net = net; +#endif +} + +#ifdef CONFIG_NET_NS +#define cifs_use_net_ns() (1) +#else +#define cifs_use_net_ns() (0) +#endif + +/* * Session structure. One of these for each uid session with a particular host */ struct cifsSesInfo { diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index cc1a860..b4faef0 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1545,6 +1545,10 @@ cifs_find_tcp_session(struct sockaddr *addr, struct smb_vol *vol) spin_lock(&cifs_tcp_ses_lock); list_for_each_entry(server, &cifs_tcp_ses_list, tcp…
creator: Rob Landley
date: 2011-01-11T04:35:19-00:00

Re: [PATCH] Teach cifs about network namespaces.
type: item
description: On 01/11/2011 01:12 AM, Matt Helsley wrote: > On Mon, Jan 10, 2011 at 10:35:19PM -0600, Rob Landley wrote: >> From: Rob Landley <rlandley@parallels.com> >> >> Teach cifs about network namespaces, so mounting uses adresses and >> routing visible from a container rather than from init context. >> >> For a long drawn out test reproduction sequence, see: >> >> http://landley.livejournal.com/47024.html >> http://landley.livejournal.com/47205.html >> http://landley.livejournal.com/47476.html >> >> Signed-off-by: Rob Landley <rlandley@parallels.com> >> --- >> >> fs/cifs/cifsglob.h | 32 ++++++++++++++++++++++++++++++++ >> fs/cifs/connect.c | 22 +++++++++++++++++----- >> 2 files changed, 49 insertions(+), 5 deletions(-) >> >> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h >> index 7136c0c..86f31bb 100644 >> --- a/fs/cifs/cifsglob.h >> +++ b/fs/cifs/cifsglob.h >> @@ -168,6 +168,9 @@ struct TCP_Server_Info { >> struct sockaddr_in6 sockAddr6; >> } addr; >> struct sockaddr_storage srcaddr; /* locally bind to this IP */ >> +#ifdef CONFIG_NET_NS >> + struct net *net; >> +#endif > > I'm assuming this bit is correct -- don't know enough about CIFS to be > sure... > >> wait_queue_head_t response_q; >> wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/ >> struct list_head pending_mid_q; >> @@ -227,6 +230,35 @@ struct TCP_Server_Info { >> }; >> >> /* >> + * Macros to allow the TCP_Server_Info->net field and related code to drop out >> + * when CONFIG_NET_NS isn't set. >> + */ >> + >> +static inline struct net * >> +cifs_net_ns(struct TCP_Server_Info *srv) >> +{ >> +#ifdef CONFIG_NET_NS >> + return srv->net; >> +#else >> + return &init_net; >> +#endif >> +} > > I thought style dictated we do this a different way: > > #ifdef CONFIG_NET_NS > static inline struct net * cifs_net_ns(struct TCP_Server_Info *srv) > { > return srv->net; > } > <other CONFIG_NET_NS cases> > #else > static inline struct net * cifs_net_ns(struct TCP_Server_Info *srv) > { > return &init_n…
creator: Rob Landley
date: 2011-01-11T14:05:38-00:00

Re: [PATCH] Teach cifs about network namespaces (take 2)
type: item
description: From: Rob Landley <rlandley@parallels.com> Teach cifs about network namespaces, so mounting uses adresses/routing visible from the container rather than from init context. Signed-off-by: Rob Landley <rlandley@parallels.com> --- Updated with Matt's feedback and to apply to current linus-git. fs/cifs/cifsglob.h | 37 +++++++++++++++++++++++++++++++++++++ fs/cifs/connect.c | 14 ++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 606ca8b..8175d31 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -165,6 +165,9 @@ struct TCP_Server_Info { struct socket *ssocket; struct sockaddr_storage dstaddr; struct sockaddr_storage srcaddr; /* locally bind to this IP */ +#ifdef CONFIG_NET_NS + struct net *net; +#endif wait_queue_head_t response_q; wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/ struct list_head pending_mid_q; @@ -224,6 +227,40 @@ struct TCP_Server_Info { }; /* + * Macros to allow the TCP_Server_Info->net field and related code to drop out + * when CONFIG_NET_NS isn't set. + */ + +#ifdef CONFIG_NET_NS + +#define HAVE_NET_NS 1 + +static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv) +{ + return srv->net; +} + +static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net) +{ + srv->net = net; +} + +#else + +#define HAVE_NET_NS 0 + +static inline struct net *cifs_net_ns(struct TCP_Server_Info *srv) +{ + return &init_net; +} + +static inline void cifs_set_net_ns(struct TCP_Server_Info *srv, struct net *net) +{ +} + +#endif + +/* * Session structure. One of these for each uid session with a particular host */ struct cifsSesInfo { diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index a65d311..7dab1d3 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1577,6 +1577,10 @@ cifs_find_tcp_session(struct sockaddr *addr, struct smb_vol *vol) spin_lock(&cifs_tcp_ses_lock); list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { + …
creator: Rob Landley
date: 2011-01-11T18:04:54-00:00