Skip to contentSkip to conversation

Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493, try2

IPv6 Applied Brian Haley 3 participants 3 messages Oct 11, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

net/ipv6/ipv6_sockglue.c +8 -5
index 532425d..1334fc1 100644
@@ -539,12 +539,15 @@ done:
 	case IPV6_MULTICAST_IF:
 		if (sk->sk_type == SOCK_STREAM)
 			goto e_inval;
-		if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
-			goto e_inval;
 
-		if (__dev_get_by_index(&init_net, val) == NULL) {
-			retv = -ENODEV;
-			break;
+		if (val) {
+			if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
+				goto e_inval;
+
+			if (__dev_get_by_index(&init_net, val) == NULL) {
+				retv = -ENODEV;
+				break;
+			}
 		}
 		np->mcast_oif = val;
 		retv = 0;
Acked-by
#1 lore raw
Quoted 27 lines
net/ipv6/ipv6_sockglue.c +8 -5
index 532425d..1334fc1 100644
@@ -539,12 +539,15 @@ done:
    case IPV6_MULTICAST_IF:
       if (sk->sk_type == SOCK_STREAM)
          goto e_inval;
-      if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
-         goto e_inval;
 
-      if (__dev_get_by_index(&init_net, val) == NULL) {
-         retv = -ENODEV;
-         break;
+      if (val) {
+         if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
+            goto e_inval;
+
+         if (__dev_get_by_index(&init_net, val) == NULL) {
+            retv = -ENODEV;
+            break;
+         }
       }
       np->mcast_oif = val;
       retv = 0;