* [PATCH] Fallback to ipv4 if we try to add join IPv4 multicast group via ipv4-mapped address.
@ 2007-10-02 9:59 Dmitry Baryshkov
2007-10-02 15:35 ` David Stevens
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Baryshkov @ 2007-10-02 9:59 UTC (permalink / raw)
To: linux-kernel, netdev
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index ae98818..c70a87d 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -38,6 +38,7 @@
#include <linux/times.h>
#include <linux/net.h>
#include <linux/in.h>
+#include <linux/igmp.h>
#include <linux/in6.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
@@ -183,6 +184,17 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr)
struct ipv6_mc_socklist *mc_lst;
struct ipv6_pinfo *np = inet6_sk(sk);
int err;
+ int addr_type = ipv6_addr_type(addr);
+
+ if (addr_type == IPV6_ADDR_MAPPED) {
+ __be32 v4addr = addr->s6_addr32[3];
+ struct ip_mreqn mreq;
+ mreq.imr_multiaddr.s_addr = v4addr;
+ mreq.imr_address.s_addr = INADDR_ANY;
+ mreq.imr_ifindex = ifindex;
+
+ return ip_mc_join_group(sk, &mreq);
+ }
if (!ipv6_addr_is_multicast(addr))
return -EINVAL;
@@ -256,6 +268,18 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, struct in6_addr *addr)
struct ipv6_pinfo *np = inet6_sk(sk);
struct ipv6_mc_socklist *mc_lst, **lnk;
+ int addr_type = ipv6_addr_type(addr);
+
+ if (addr_type == IPV6_ADDR_MAPPED) {
+ __be32 v4addr = addr->s6_addr32[3];
+ struct ip_mreqn mreq;
+ mreq.imr_multiaddr.s_addr = v4addr;
+ mreq.imr_address.s_addr = INADDR_ANY;
+ mreq.imr_ifindex = ifindex;
+
+ return ip_mc_leave_group(sk, &mreq);
+ }
+
write_lock_bh(&ipv6_sk_mc_lock);
for (lnk = &np->ipv6_mc_list; (mc_lst = *lnk) !=NULL ; lnk = &mc_lst->next) {
if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Fallback to ipv4 if we try to add join IPv4 multicast group via ipv4-mapped address.
2007-10-02 9:59 [PATCH] Fallback to ipv4 if we try to add join IPv4 multicast group via ipv4-mapped address Dmitry Baryshkov
@ 2007-10-02 15:35 ` David Stevens
2007-10-03 13:26 ` Dmitry Baryshkov
0 siblings, 1 reply; 3+ messages in thread
From: David Stevens @ 2007-10-02 15:35 UTC (permalink / raw)
To: Dmitry Baryshkov; +Cc: linux-kernel, netdev, netdev-owner
Dmitry,
Good catch; a couple comments:
> struct ipv6_pinfo *np = inet6_sk(sk);
> int err;
> + int addr_type = ipv6_addr_type(addr);
> +
> + if (addr_type == IPV6_ADDR_MAPPED) {
> + __be32 v4addr = addr->s6_addr32[3];
> + struct ip_mreqn mreq;
> + mreq.imr_multiaddr.s_addr = v4addr;
> + mreq.imr_address.s_addr = INADDR_ANY;
> + mreq.imr_ifindex = ifindex;
> +
> + return ip_mc_join_group(sk, &mreq);
> + }
ipv6_addr_type() returns a bitmask, so you should use:
if (addr_type & IPV6_ADDR_MAPPED) {
Also, you should have a blank line after the "mreq" declaration.
Ditto for both in ipv6_mc_sock_drop().
I don't expect the multicast source filtering interface will
behave well for mapped addresses, either. The mapped multicast
address won't appear to be a multicast address (and return
error there), and all the source filters would have to be
v4mapped addresses and modify the v4 source filters for this
to do as you expect. So, there's more to it (and it may be a
bit messy) to support mapped multicast addresses fully. I'll
think about that part some more.
+-DLS
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fallback to ipv4 if we try to add join IPv4 multicast group via ipv4-mapped address.
2007-10-02 15:35 ` David Stevens
@ 2007-10-03 13:26 ` Dmitry Baryshkov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2007-10-03 13:26 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
Hello,
David Stevens wrote:
> Dmitry,
> Good catch; a couple comments:
Thank you for the response.
>
>> struct ipv6_pinfo *np = inet6_sk(sk);
>> int err;
>> + int addr_type = ipv6_addr_type(addr);
>> +
>> + if (addr_type == IPV6_ADDR_MAPPED) {
>> + __be32 v4addr = addr->s6_addr32[3];
>> + struct ip_mreqn mreq;
>> + mreq.imr_multiaddr.s_addr = v4addr;
>> + mreq.imr_address.s_addr = INADDR_ANY;
>> + mreq.imr_ifindex = ifindex;
>> +
>> + return ip_mc_join_group(sk, &mreq);
>> + }
>
> ipv6_addr_type() returns a bitmask, so you should use:
>
> if (addr_type & IPV6_ADDR_MAPPED) {
I just c'n'pasted the code that checks for mapped addresses. In most
cases it's just ==, not bitmask operation.
>
> Also, you should have a blank line after the "mreq" declaration.
ok.
>
> Ditto for both in ipv6_mc_sock_drop().
> I don't expect the multicast source filtering interface will
> behave well for mapped addresses, either. The mapped multicast
> address won't appear to be a multicast address (and return
> error there), and all the source filters would have to be
> v4mapped addresses and modify the v4 source filters for this
> to do as you expect. So, there's more to it (and it may be a
> bit messy) to support mapped multicast addresses fully. I'll
> think about that part some more.
Didn't have time to test it throughly. I've only checked that call
succeeds and that all necessary igmp are sent. I hope, this weekend I'll
have more time to check.
--
With best wishes
Dmitry Baryshkov
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-03 13:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-02 9:59 [PATCH] Fallback to ipv4 if we try to add join IPv4 multicast group via ipv4-mapped address Dmitry Baryshkov
2007-10-02 15:35 ` David Stevens
2007-10-03 13:26 ` Dmitry Baryshkov
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).