From patchwork Wed Oct 1 07:04:48 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rami Rosen X-Patchwork-Id: 2161 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id D2AEBDDE1A for ; Wed, 1 Oct 2008 17:04:54 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751767AbYJAHEu (ORCPT ); Wed, 1 Oct 2008 03:04:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751458AbYJAHEu (ORCPT ); Wed, 1 Oct 2008 03:04:50 -0400 Received: from rv-out-0506.google.com ([209.85.198.237]:9087 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750898AbYJAHEt (ORCPT ); Wed, 1 Oct 2008 03:04:49 -0400 Received: by rv-out-0506.google.com with SMTP id k40so440199rvb.1 for ; Wed, 01 Oct 2008 00:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:mime-version:content-type; bh=ZRQJ8i78T+wTPi0PTvu4s0Y6EWkHfc4NgF9Kva3WnHo=; b=MmB8yocx3cuJlfsEZeSwtyMsGNxlHTMRtYBMRYOjZ/s44bHJch9AzIt8sf6Cs7SVKH iwTptMXbotTMVLiwd3Hg5p7fVVhrmzG+/zFF10CrgjU7Zd2hS7ILsskCjfgLFmkk2su/ Jl/iXdzSVsb0xjM/B5jBWmjv4bYLHK8JWdP6c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:mime-version:content-type; b=jV7GXG2Z5NCNQw1NUdrL/F1T+cR3ah2D4x/8UDHw0HwIlapAtpbHmY3rvq3Y+w3rFj 6fr4UHTgFW5cbOeSpHhpHB5PdIz7rkspm2r2svk4JLJXIjMYUi9S1+EWio16Ttkdhwag jRJ/WHar7dS0tWqUrU2qxJKvUtmGTiAx/7zEM= Received: by 10.142.147.15 with SMTP id u15mr3209877wfd.181.1222844688826; Wed, 01 Oct 2008 00:04:48 -0700 (PDT) Received: by 10.142.204.4 with HTTP; Wed, 1 Oct 2008 00:04:48 -0700 (PDT) Message-ID: Date: Wed, 1 Oct 2008 10:04:48 +0300 From: "Rami Rosen" To: davem@davemloft.net, "David Stevens" Subject: [PATCH 1/2] ipv4: add mc_count to in_device. Cc: netdev@vger.kernel.org, netdev-owner@vger.kernel.org, "Pekka Savola" MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi, This patch add mc_count to struct in_device and updates increment/decrement/initilaize of this field in IPv4 and in IPv6. - Also printing the vfs /proc entry (/proc/net/igmp) is adjusted to use the new mc_count. Regards, Rami Rosen Signed-off-by: Rami Rosen On Wed, Oct 1, 2008 at 9:57 AM, Rami Rosen wrote: > Hi, > - This patch set adds mc_count to struct in_device (IPv4) and to > struct inet6_dev (IPv6) and updates increment/decrement/initialization > of this field in IPv4 and in IPv6. > > - Also printing the /proc entry (/proc/net/igmp) is adjusted to use > the new mc_count. > > - Thanks to David Stevens for his feedback. > > Regards, > Rami Rosen > > On Thu, Sep 25, 2008 at 10:35 AM, David Stevens wrote: >> netdev-owner@vger.kernel.org wrote on 09/24/2008 11:44:45 PM: >> >>> Hi, >>> >>> - I had noticed a long ago that the IP addresses under >>> /proc/net/igmp are in Hexa format. I am preparing a patch to fix it >>> and it will be send very soon. >> >> I don't think we can do that, since I believe netstat expects >> to see this the way it is. Maybe if we change netstat to support >> both and wait a year for all distros to get it... :-) >> >> >>> So indeed , the count (mc_count of netdevice) shows both IPv4 and IPv6 >> igmp >>> groups, but in current implementation it is not immediate >>> to change it. Currently, net_device struct does not have specific >>> fields for ipv4 or ipv6. One way of preparing a patch >>> is to change net_device to have mc_count4 and mc_count6; >>> I am really willing to prepare such a patch, but I am not sure such a >>> change in net_device is a proper and a justified >>> change to do. >> >> These belong with mc_list in inet6_dev and in_device. Really, >> I'd just add "mc_count" as a field right next to mc_list and inc/dec >> it when calling the group join/leave functions-- use the list lock >> to protect it. The structure it's in distinguishes the protocol, >> and the names are otherwise common. >> >> +-DLS >> >> > diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h index c6f51ad..06fcdb4 100644 --- a/include/linux/inetdevice.h +++ b/include/linux/inetdevice.h @@ -25,6 +25,7 @@ struct in_device struct in_ifaddr *ifa_list; /* IP ifaddr chain */ rwlock_t mc_list_lock; struct ip_mc_list *mc_list; /* IP multicast filter chain */ + int mc_count; /* Number of installed mcasts */ spinlock_t mc_tomb_lock; struct ip_mc_list *mc_tomb; unsigned long mr_v1_seen; diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index f70fac6..7f9e337 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -1234,6 +1234,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) write_lock_bh(&in_dev->mc_list_lock); im->next=in_dev->mc_list; in_dev->mc_list=im; + in_dev->mc_count++; write_unlock_bh(&in_dev->mc_list_lock); #ifdef CONFIG_IP_MULTICAST igmpv3_del_delrec(in_dev, im->multiaddr); @@ -1282,6 +1283,7 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr) if (--i->users == 0) { write_lock_bh(&in_dev->mc_list_lock); *ip = i->next; + in_dev->mc_count--; write_unlock_bh(&in_dev->mc_list_lock); igmp_group_dropped(i); @@ -1330,6 +1332,7 @@ void ip_mc_init_dev(struct in_device *in_dev) setup_timer(&in_dev->mr_gq_timer, igmp_gq_timer_expire, (unsigned long)in_dev); in_dev->mr_ifc_count = 0; + in_dev->mc_count = 0; setup_timer(&in_dev->mr_ifc_timer, igmp_ifc_timer_expire, (unsigned long)in_dev); in_dev->mr_qrv = IGMP_Unsolicited_Report_Count; @@ -1369,8 +1372,8 @@ void ip_mc_destroy_dev(struct in_device *in_dev) write_lock_bh(&in_dev->mc_list_lock); while ((i = in_dev->mc_list) != NULL) { in_dev->mc_list = i->next; + in_dev->mc_count--; write_unlock_bh(&in_dev->mc_list_lock); - igmp_group_dropped(i); ip_ma_put(i); @@ -2383,7 +2386,7 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v) if (state->in_dev->mc_list == im) { seq_printf(seq, "%d\t%-10s: %5d %7s\n", - state->dev->ifindex, state->dev->name, state->dev->mc_count, querier); + state->dev->ifindex, state->dev->name, state->in_dev->mc_count, querier); } seq_printf(seq,