diff mbox

[1/2] ipv4: add mc_count to in_device.

Message ID b25312890810010004p15e85df1u69125c7fa47ae01f@mail.gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Rami Rosen Oct. 1, 2008, 7:04 a.m. UTC
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 <ramirose@gmail.com>



On Wed, Oct 1, 2008 at 9:57 AM, Rami Rosen <roszenrami@gmail.com> 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 <dlstevens@us.ibm.com> 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
>>
>>
>

Comments

David Miller Oct. 7, 2008, 10:35 p.m. UTC | #1
From: "Rami Rosen" <roszenrami@gmail.com>
Date: Wed, 1 Oct 2008 10:04:48 +0300

> 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.
> 
> Signed-off-by: Rami Rosen <ramirose@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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,