netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipvs: Fix inappropriate output of procfs
@ 2017-10-15 11:54 KUWAZAWA Takuya
  2017-10-15 14:11 ` Julian Anastasov
  0 siblings, 1 reply; 3+ messages in thread
From: KUWAZAWA Takuya @ 2017-10-15 11:54 UTC (permalink / raw)
  To: Wensong Zhang, Simon Horman, Julian Anastasov
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S. Miller, netdev, lvs-devel, netfilter-devel, coreteam,
	linux-kernel

Information about ipvs in different network namespace can be seen via procfs.

How to reproduce:

  # ip netns add ns01
  # ip netns add ns02
  # ip netns exec ns01 ip a add dev lo 127.0.0.1/8
  # ip netns exec ns02 ip a add dev lo 127.0.0.1/8
  # ip netns exec ns01 ipvsadm -A -t 10.1.1.1:80
  # ip netns exec ns02 ipvsadm -A -t 10.1.1.2:80

The ipvsadm displays information about its own network namespace only.

  # ip netns exec ns01 ipvsadm -Ln
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
    -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
  TCP  10.1.1.1:80 wlc

  # ip netns exec ns02 ipvsadm -Ln
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
    -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
  TCP  10.1.1.2:80 wlc

But I can see information about other network namespace via procfs.

  # ip netns exec ns01 cat /proc/net/ip_vs
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
    -> RemoteAddress:Port Forward Weight ActiveConn InActConn
  TCP  0A010101:0050 wlc
  TCP  0A010102:0050 wlc

  # ip netns exec ns02 cat /proc/net/ip_vs
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
    -> RemoteAddress:Port Forward Weight ActiveConn InActConn
  TCP  0A010102:0050 wlc

Signed-off-by: KUWAZAWA Takuya <albatross0@gmail.com>
---
 net/netfilter/ipvs/ip_vs_ctl.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 4f940d7..b3245f9 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -2034,12 +2034,16 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
 		seq_puts(seq,
 			 "  -> RemoteAddress:Port Forward Weight ActiveConn InActConn\n");
 	} else {
+		struct net *net = seq_file_net(seq);
+		struct netns_ipvs *ipvs = net_ipvs(net);
 		const struct ip_vs_service *svc = v;
 		const struct ip_vs_iter *iter = seq->private;
 		const struct ip_vs_dest *dest;
 		struct ip_vs_scheduler *sched = rcu_dereference(svc->scheduler);
 		char *sched_name = sched ? sched->name : "none";
 
+		if (svc->ipvs != ipvs)
+			return 0;
 		if (iter->table == ip_vs_svc_table) {
 #ifdef CONFIG_IP_VS_IPV6
 			if (svc->af == AF_INET6)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ipvs: Fix inappropriate output of procfs
  2017-10-15 11:54 [PATCH] ipvs: Fix inappropriate output of procfs KUWAZAWA Takuya
@ 2017-10-15 14:11 ` Julian Anastasov
  2017-11-06 14:26   ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Julian Anastasov @ 2017-10-15 14:11 UTC (permalink / raw)
  To: KUWAZAWA Takuya
  Cc: Wensong Zhang, Simon Horman, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, netdev, lvs-devel,
	netfilter-devel, coreteam, linux-kernel


	Hello,

On Sun, 15 Oct 2017, KUWAZAWA Takuya wrote:

> Information about ipvs in different network namespace can be seen via procfs.
> 
> How to reproduce:
> 
>   # ip netns add ns01
>   # ip netns add ns02
>   # ip netns exec ns01 ip a add dev lo 127.0.0.1/8
>   # ip netns exec ns02 ip a add dev lo 127.0.0.1/8
>   # ip netns exec ns01 ipvsadm -A -t 10.1.1.1:80
>   # ip netns exec ns02 ipvsadm -A -t 10.1.1.2:80
> 
> The ipvsadm displays information about its own network namespace only.
> 
>   # ip netns exec ns01 ipvsadm -Ln
>   IP Virtual Server version 1.2.1 (size=4096)
>   Prot LocalAddress:Port Scheduler Flags
>     -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
>   TCP  10.1.1.1:80 wlc
> 
>   # ip netns exec ns02 ipvsadm -Ln
>   IP Virtual Server version 1.2.1 (size=4096)
>   Prot LocalAddress:Port Scheduler Flags
>     -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
>   TCP  10.1.1.2:80 wlc
> 
> But I can see information about other network namespace via procfs.
> 
>   # ip netns exec ns01 cat /proc/net/ip_vs
>   IP Virtual Server version 1.2.1 (size=4096)
>   Prot LocalAddress:Port Scheduler Flags
>     -> RemoteAddress:Port Forward Weight ActiveConn InActConn
>   TCP  0A010101:0050 wlc
>   TCP  0A010102:0050 wlc
> 
>   # ip netns exec ns02 cat /proc/net/ip_vs
>   IP Virtual Server version 1.2.1 (size=4096)
>   Prot LocalAddress:Port Scheduler Flags
>     -> RemoteAddress:Port Forward Weight ActiveConn InActConn
>   TCP  0A010102:0050 wlc
> 
> Signed-off-by: KUWAZAWA Takuya <albatross0@gmail.com>

	Looks good to me

Acked-by: Julian Anastasov <ja@ssi.bg>

	Simon, please apply to ipvs tree.

> ---
>  net/netfilter/ipvs/ip_vs_ctl.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index 4f940d7..b3245f9 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -2034,12 +2034,16 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
>  		seq_puts(seq,
>  			 "  -> RemoteAddress:Port Forward Weight ActiveConn InActConn\n");
>  	} else {
> +		struct net *net = seq_file_net(seq);
> +		struct netns_ipvs *ipvs = net_ipvs(net);
>  		const struct ip_vs_service *svc = v;
>  		const struct ip_vs_iter *iter = seq->private;
>  		const struct ip_vs_dest *dest;
>  		struct ip_vs_scheduler *sched = rcu_dereference(svc->scheduler);
>  		char *sched_name = sched ? sched->name : "none";
>  
> +		if (svc->ipvs != ipvs)
> +			return 0;
>  		if (iter->table == ip_vs_svc_table) {
>  #ifdef CONFIG_IP_VS_IPV6
>  			if (svc->af == AF_INET6)
> -- 
> 1.8.3.1

Regards

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ipvs: Fix inappropriate output of procfs
  2017-10-15 14:11 ` Julian Anastasov
@ 2017-11-06 14:26   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2017-11-06 14:26 UTC (permalink / raw)
  To: Julian Anastasov
  Cc: KUWAZAWA Takuya, Wensong Zhang, Simon Horman, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, netdev, lvs-devel,
	netfilter-devel, coreteam, linux-kernel

On Sun, Oct 15, 2017 at 05:11:28PM +0300, Julian Anastasov wrote:
> On Sun, 15 Oct 2017, KUWAZAWA Takuya wrote:
> 
> > Information about ipvs in different network namespace can be seen via procfs.
> > 
> > How to reproduce:
> > 
> >   # ip netns add ns01
> >   # ip netns add ns02
> >   # ip netns exec ns01 ip a add dev lo 127.0.0.1/8
> >   # ip netns exec ns02 ip a add dev lo 127.0.0.1/8
> >   # ip netns exec ns01 ipvsadm -A -t 10.1.1.1:80
> >   # ip netns exec ns02 ipvsadm -A -t 10.1.1.2:80
> > 
> > The ipvsadm displays information about its own network namespace only.
> > 
> >   # ip netns exec ns01 ipvsadm -Ln
> >   IP Virtual Server version 1.2.1 (size=4096)
> >   Prot LocalAddress:Port Scheduler Flags
> >     -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
> >   TCP  10.1.1.1:80 wlc
> > 
> >   # ip netns exec ns02 ipvsadm -Ln
> >   IP Virtual Server version 1.2.1 (size=4096)
> >   Prot LocalAddress:Port Scheduler Flags
> >     -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
> >   TCP  10.1.1.2:80 wlc
> > 
> > But I can see information about other network namespace via procfs.
> > 
> >   # ip netns exec ns01 cat /proc/net/ip_vs
> >   IP Virtual Server version 1.2.1 (size=4096)
> >   Prot LocalAddress:Port Scheduler Flags
> >     -> RemoteAddress:Port Forward Weight ActiveConn InActConn
> >   TCP  0A010101:0050 wlc
> >   TCP  0A010102:0050 wlc
> > 
> >   # ip netns exec ns02 cat /proc/net/ip_vs
> >   IP Virtual Server version 1.2.1 (size=4096)
> >   Prot LocalAddress:Port Scheduler Flags
> >     -> RemoteAddress:Port Forward Weight ActiveConn InActConn
> >   TCP  0A010102:0050 wlc
> > 
> > Signed-off-by: KUWAZAWA Takuya <albatross0@gmail.com>
> 
> 	Looks good to me
> 
> Acked-by: Julian Anastasov <ja@ssi.bg>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-06 14:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-15 11:54 [PATCH] ipvs: Fix inappropriate output of procfs KUWAZAWA Takuya
2017-10-15 14:11 ` Julian Anastasov
2017-11-06 14:26   ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).