Skip to content

Commit

Permalink
Fix specifying an interface for IPV6_JOIN_GROUP
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ozaki-r committed May 25, 2015
1 parent c0bf82e commit fe8ae46
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions 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.
Expand Down Expand Up @@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
#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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fe8ae46

Please sign in to comment.