(usagi-users 03389) Re: MLDv2 linux implementation questions

David Stevens <[email protected]>
Newsgroups gmane.linux.ipv6.usagi.users
Message-ID <OF42E34BA3.27370578-ON88257020.00615B14-88257020.0061C1C4@us.ibm.com>
Hoerdt,
        Here's a fix. I'm going to see if I can do the further
optimization of leaving the group when the filter is (INCLUDE,empty)
for this case, since that would use less socket buffer space, but
this alone corrects the problem.

                                        +-DLS

(in-line for viewing, attached for applying)
--- linux-2.6.11.12/net/ipv6/mcast.c    2005-03-01 23:38:25.000000000 
-0800
+++ linux-2.6.11.12MCT/net/ipv6/mcast.c 2005-06-14 10:31:24.000000000 
-0700
@@ -188,6 +188,16 @@ int ipv6_sock_mc_join(struct sock *sk, i
        if (!ipv6_addr_is_multicast(addr))
                return -EINVAL;
 
+       read_lock_bh(&ipv6_sk_mc_lock);
+       for (mc_lst=np->ipv6_mc_list; mc_lst; mc_lst=mc_lst->next) {
+               if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
+                   ipv6_addr_equal(&mc_lst->addr, addr)) {
+                       read_unlock_bh(&ipv6_sk_mc_lock);
+                       return -EADDRINUSE;
+               }
+       }
+       read_unlock_bh(&ipv6_sk_mc_lock);
+
        mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist), 
GFP_KERNEL);
 
        if (mc_lst == NULL)
mct.patch (application/octet-stream, 675 B)
--- linux-2.6.11.12/net/ipv6/mcast.c	2005-03-01 23:38:25.000000000 -0800
+++ linux-2.6.11.12MCT/net/ipv6/mcast.c	2005-06-14 10:31:24.000000000 -0700
@@ -188,6 +188,16 @@ int ipv6_sock_mc_join(struct sock *sk, i
 	if (!ipv6_addr_is_multicast(addr))
 		return -EINVAL;
 
+	read_lock_bh(&ipv6_sk_mc_lock);
+	for (mc_lst=np->ipv6_mc_list; mc_lst; mc_lst=mc_lst->next) {
+		if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
+		    ipv6_addr_equal(&mc_lst->addr, addr)) {
+			read_unlock_bh(&ipv6_sk_mc_lock);
+			return -EADDRINUSE;
+		}
+	}
+	read_unlock_bh(&ipv6_sk_mc_lock);
+
 	mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist), GFP_KERNEL);
 
 	if (mc_lst == NULL)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.