netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [IPv6] Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493
@ 2007-10-10 15:04 Brian Haley
  2007-10-10 20:45 ` David Stevens
  0 siblings, 1 reply; 6+ messages in thread
From: Brian Haley @ 2007-10-10 15:04 UTC (permalink / raw)
  To: David Miller, YOSHIFUJI Hideaki; +Cc: netdev@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]

Hi,

 From RFC 3493, Section 5.2:

       IPV6_MULTICAST_IF

          Set the interface to use for outgoing multicast packets.  The
          argument is the index of the interface to use.  If the
          interface index is specified as zero, the system selects the
          interface (for example, by looking up the address in a routing
          table and using the resulting interface).

This patch adds support for (index == 0) to reset the value to it's 
original state, allowing the system to choose the best interface.  IPv4 
already behaves this way.

-Brian


Signed-off-by: Brian Haley <brian.haley@hp.com>

[-- Attachment #2: ipv6.multicast_if.patch --]
[-- Type: text/x-patch, Size: 417 bytes --]

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 532425d..309284e 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -539,6 +539,13 @@ done:
 	case IPV6_MULTICAST_IF:
 		if (sk->sk_type == SOCK_STREAM)
 			goto e_inval;
+
+		if (val == 0) {
+			np->mcast_oif = 0;
+			retv = 0;
+			break;
+		}
+
 		if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
 			goto e_inval;
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [IPv6] Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493
  2007-10-10 15:04 [IPv6] Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493 Brian Haley
@ 2007-10-10 20:45 ` David Stevens
  2007-10-10 21:20   ` Brian Haley
  0 siblings, 1 reply; 6+ messages in thread
From: David Stevens @ 2007-10-10 20:45 UTC (permalink / raw)
  To: Brian Haley
  Cc: David Miller, netdev@vger.kernel.org, netdev-owner,
	YOSHIFUJI Hideaki

What about just checking for 0 in the later test?

        if (val && __dev_get_by_index(val) == NULL) {
...


                                        +-DLS


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [IPv6] Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493
  2007-10-10 20:45 ` David Stevens
@ 2007-10-10 21:20   ` Brian Haley
  2007-10-10 21:48     ` David Stevens
  0 siblings, 1 reply; 6+ messages in thread
From: Brian Haley @ 2007-10-10 21:20 UTC (permalink / raw)
  To: David Stevens
  Cc: David Miller, netdev@vger.kernel.org, netdev-owner,
	YOSHIFUJI Hideaki

David Stevens wrote:
> What about just checking for 0 in the later test?
> 
>         if (val && __dev_get_by_index(val) == NULL) {

We could fail the next check right before that though:

           if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
                   goto e_inval;

I just mimicked what the IPv4 code does in do_ip_setsockopt().

-Brian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [IPv6] Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493
  2007-10-10 21:20   ` Brian Haley
@ 2007-10-10 21:48     ` David Stevens
  2007-10-10 23:42       ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: David Stevens @ 2007-10-10 21:48 UTC (permalink / raw)
  To: Brian Haley
  Cc: David Miller, netdev@vger.kernel.org, netdev-owner,
	YOSHIFUJI Hideaki

Brian Haley <brian.haley@hp.com> wrote on 10/10/2007 02:20:45 PM:

> David Stevens wrote:
> > What about just checking for 0 in the later test?
> > 
> >         if (val && __dev_get_by_index(val) == NULL) {
> 
> We could fail the next check right before that though:

        Right, the semantics there would be "if we have a bound
dev if, that's the only legal value here." Setting it to '0' in
that case doesn't really do anythng, anyway. But I don't care
about that semantic difference-- could even add "val &&" to the
bound_dev_if check.
        What I don't like is that your "if" creates an identical
duplicate code path for the functional part of it. In this case
it's trivial (the asignment), but makes the code look more
complex than it really is. If v4 does it that way, I don't
like that either. :-)
        I agree with it in general, and may not be worth the
trouble, but I'd personally prefer something like:

        if (sk->sk_type == SOCK_STREAM)
                goto e_inval;
        if (val && sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
                goto e_inval;

        if (val && __dev_get_by_index(val) != NULL) {
                retv = -ENODEV;
                break;
        }
[at this point all validity checks are done and we're following
        one code path to do the work; each check is easily
        identifiable.]

        np->mcast_oif = val;
        retv = 0;
        break;

Or maybe:

        if (sk->sk_type == SOCK_STREAM)
                goto e_inval;

        if (val) {
                if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
                        goto e_inval;
                if (__dev_get_by_index(val != NULL) {
                        retv = -ENODEV;
                        break;
                }
        }
        np->mcast_oif = val;
        retv = 0;
        break;

But anyway, I made the comment; I think some form of it
should go in. :-) If you like the original better, that's
ok with me, too.

                                                +-DLS


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [IPv6] Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493
  2007-10-10 21:48     ` David Stevens
@ 2007-10-10 23:42       ` David Miller
  2007-10-11  0:33         ` YOSHIFUJI Hideaki / 吉藤英明
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2007-10-10 23:42 UTC (permalink / raw)
  To: dlstevens; +Cc: brian.haley, netdev, netdev-owner, yoshfuji

From: David Stevens <dlstevens@us.ibm.com>
Date: Wed, 10 Oct 2007 14:48:38 -0700

> But anyway, I made the comment; I think some form of it
> should go in. :-) If you like the original better, that's
> ok with me, too.

Brian, please submit a new patch or resubmit the original
one, the choice is your's :-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [IPv6] Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493
  2007-10-10 23:42       ` David Miller
@ 2007-10-11  0:33         ` YOSHIFUJI Hideaki / 吉藤英明
  0 siblings, 0 replies; 6+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2007-10-11  0:33 UTC (permalink / raw)
  To: davem; +Cc: dlstevens, brian.haley, netdev, yoshfuji

In article <20071010.164256.59470114.davem@davemloft.net> (at Wed, 10 Oct 2007 16:42:56 -0700 (PDT)), David Miller <davem@davemloft.net> says:

> From: David Stevens <dlstevens@us.ibm.com>
> Date: Wed, 10 Oct 2007 14:48:38 -0700
> 
> > But anyway, I made the comment; I think some form of it
> > should go in. :-) If you like the original better, that's
> > ok with me, too.
> 
> Brian, please submit a new patch or resubmit the original
> one, the choice is your's :-)

I agree, too. :-)

--yoshfuji

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-10-11  0:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-10 15:04 [IPv6] Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493 Brian Haley
2007-10-10 20:45 ` David Stevens
2007-10-10 21:20   ` Brian Haley
2007-10-10 21:48     ` David Stevens
2007-10-10 23:42       ` David Miller
2007-10-11  0:33         ` YOSHIFUJI Hideaki / 吉藤英明

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).