From fe8ae46b757275ea85c6c91e21a85cc276e18e55 Mon Sep 17 00:00:00 2001 From: ozaki-r Date: Mon, 25 May 2015 07:17:17 +0000 Subject: [PATCH] Fix specifying an interface for IPV6_JOIN_GROUP Using always an interface of index=1 is not good idea; it varies depending on runtime environments. We can use index=0 instead, which allows the kernel to pick an appropriate interface for mcast. --- tests/net/mcast/t_mcast.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/net/mcast/t_mcast.c b/tests/net/mcast/t_mcast.c index 333d77297172f..995d90c68ff77 100644 --- a/tests/net/mcast/t_mcast.c +++ b/tests/net/mcast/t_mcast.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mcast.c,v 1.15 2015/05/19 04:14:04 ozaki-r Exp $ */ +/* $NetBSD: t_mcast.c,v 1.16 2015/05/25 07:17:17 ozaki-r Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include #ifdef __RCSID -__RCSID("$NetBSD: t_mcast.c,v 1.15 2015/05/19 04:14:04 ozaki-r Exp $"); +__RCSID("$NetBSD: t_mcast.c,v 1.16 2015/05/25 07:17:17 ozaki-r Exp $"); #else extern const char *__progname; #define getprogname() __progname @@ -132,12 +132,12 @@ addmc(int s, struct addrinfo *ai, bool bug) if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ifc, sizeof(ifc)) == -1) return -1; - ifc = 1; + ifc = 1; /* XXX should pick a proper interface */ if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifc, sizeof(ifc)) == -1) return -1; #else - ifc = 1; + ifc = 0; /* Let pick an appropriate interface */ #endif m6.ipv6mr_interface = ifc; m6.ipv6mr_multiaddr = s6->sin6_addr;