From patchwork Wed Oct 1 07:09:07 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rami Rosen X-Patchwork-Id: 2162 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 261EFDDE1C for ; Wed, 1 Oct 2008 17:09:16 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751907AbYJAHJK (ORCPT ); Wed, 1 Oct 2008 03:09:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751542AbYJAHJK (ORCPT ); Wed, 1 Oct 2008 03:09:10 -0400 Received: from wf-out-1314.google.com ([209.85.200.171]:3159 "EHLO wf-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551AbYJAHJI (ORCPT ); Wed, 1 Oct 2008 03:09:08 -0400 Received: by wf-out-1314.google.com with SMTP id 27so432873wfd.4 for ; Wed, 01 Oct 2008 00:09:07 -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=pwyTKhrhB17PM4nJC9GApkbbFpHMPfEmGBqnVYE/M34=; b=k0ohjkZfJ2VSlN43IdTshRBowMwC/6uAvm29iq0jaY8mSnqOI40/PDkrHwYufK32GX kkLKMLagLiiiTRc7jqfozuy5Hz0eoIuflxAqXyuQ3YL4llQy89hq4uJ8TABmtWnEpfn5 KiPLaq9kQiG+n55nVAieiR+x5PTOAsyNj8sYs= 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=QQtWmHZPrbSLvoBDjfOP3N1v5a9h298Uobm968+R0L1hM9KaPMpUblm3iRz1tnZOoL A2vrK/C7uNaYGr+3SqaU0b2Ao4ZtjslEe2snShV+NwZRvUx8i9CE4nQkA3A2nDi7OoTe WCfyEcYL80xHo6lk/dCiE6+9jwe9c4aNBUSCI= Received: by 10.142.109.16 with SMTP id h16mr3209170wfc.190.1222844947944; Wed, 01 Oct 2008 00:09:07 -0700 (PDT) Received: by 10.142.204.4 with HTTP; Wed, 1 Oct 2008 00:09:07 -0700 (PDT) Message-ID: Date: Wed, 1 Oct 2008 10:09:07 +0300 From: "Rami Rosen" To: davem@davemloft.net, "David Stevens" Subject: Re: [PATCH 2/2] ipv6: add mc_count to inet6_dev 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 adds mc_count to struct inet6_dev and updates increment/decrement/initilaize of this field. 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/net/if_inet6.h b/include/net/if_inet6.h index c8effa4..9e9139c 100644 --- a/include/net/if_inet6.h +++ b/include/net/if_inet6.h @@ -163,6 +163,7 @@ struct inet6_dev struct inet6_ifaddr *addr_list; struct ifmcaddr6 *mc_list; + int mc_count; /* Number of installed mcasts */ struct ifmcaddr6 *mc_tomb; rwlock_t mc_lock; unsigned char mc_qrv; diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index e7c03bc..835521d 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c @@ -922,6 +922,7 @@ int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr) mc->next = idev->mc_list; idev->mc_list = mc; + mc->idev->mc_count++; write_unlock_bh(&idev->lock); mld_del_delrec(idev, &mc->mca_addr); @@ -943,7 +944,7 @@ int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr) if (--ma->mca_users == 0) { *map = ma->next; write_unlock_bh(&idev->lock); - + idev->mc_count--; igmp6_group_dropped(ma); ma_put(ma); @@ -2288,6 +2289,7 @@ void ipv6_mc_init_dev(struct inet6_dev *idev) (unsigned long)idev); idev->mc_tomb = NULL; idev->mc_ifc_count = 0; + idev->mc_count=0; setup_timer(&idev->mc_ifc_timer, mld_ifc_timer_expire, (unsigned long)idev); idev->mc_qrv = MLD_QRV_DEFAULT;