From patchwork Sat Jul 30 23:34:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Smith X-Patchwork-Id: 107524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CFC8FB6F72 for ; Sun, 31 Jul 2011 09:35:11 +1000 (EST) Received: from localhost ([::1]:37473 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QnJ3h-0007sC-UQ for incoming@patchwork.ozlabs.org; Sat, 30 Jul 2011 19:35:05 -0400 Received: from eggs.gnu.org ([140.186.70.92]:35328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QnJ3c-0007ra-8q for qemu-devel@nongnu.org; Sat, 30 Jul 2011 19:35:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QnJ3a-0007i3-Lv for qemu-devel@nongnu.org; Sat, 30 Jul 2011 19:35:00 -0400 Received: from speedy.comstyle.com ([206.51.28.2]:45066 helo=mail.comstyle.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QnJ3a-0007hy-HW for qemu-devel@nongnu.org; Sat, 30 Jul 2011 19:34:58 -0400 Received: from rox.home.comstyle.com (rox.home.comstyle.com [IPv6:2001:470:b01e:3:ca0a:a9ff:fe93:42c9]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: brad) by mail.comstyle.com (Postfix) with ESMTPSA id CE3819845D for ; Sat, 30 Jul 2011 19:34:50 -0400 (EDT) Date: Sat, 30 Jul 2011 19:34:49 -0400 From: Brad To: qemu-devel@nongnu.org Message-ID: <20110730233444.GA15976@rox.home.comstyle.com> References: <20110729231511.GA24006@rox.home.comstyle.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110729231511.GA24006@rox.home.comstyle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-comstyle-MailScanner-Information: Please contact the ISP for more information X-comstyle-MailScanner-ID: CE3819845D.A40CD X-comstyle-MailScanner: Found to be clean X-comstyle-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (not cached, score=-2.9, required 6, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_00 -1.90, T_FRT_STOCK2 0.01, T_RP_MATCHES_RCVD -0.01) X-comstyle-MailScanner-From: brad@comstyle.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.51.28.2 Subject: Re: [Qemu-devel] [PATCH] Fix forcing multicast msgs to loopback on OpenBSD. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Fri, Jul 29, 2011 at 07:15:11PM -0400, Brad wrote: > Fix forcing multicast msgs to loopback on OpenBSD. > > e.g. > $ sudo qemu -m 128 -no-fd-bootchk \ > -hda virtual.img -boot n -nographic \ > -net nic,vlan=0,model=rtl8139,macaddr=52:54:00:12:34:03 \ > -net user -tftp /usr/src/sys/arch/i386/compile/TEST -bootp pxeboot \ > -net nic,vlan=1,model=rtl8139,macaddr=52:54:00:23:03:01 \ > -net tap,vlan=1,script=no \ > -net nic,vlan=3,model=rtl8139,macaddr=52:54:00:23:03:03 \ > -net socket,vlan=3,mcast=230.0.0.1:10003 > setsockopt(SOL_IP, IP_MULTICAST_LOOP): Invalid argument > qemu: -net socket,vlan=3,mcast=230.0.0.1:10003: Device 'socket' could not be initialized > > > Signed-off-by: Brad Smith An updated diff taking Blue Swirl's comment into consideration. --- net/socket.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/net/socket.c b/net/socket.c index 11fe5f3..5cd0b9a 100644 --- a/net/socket.c +++ b/net/socket.c @@ -154,6 +154,12 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr struct ip_mreq imr; int fd; int val, ret; +#ifdef __OpenBSD__ + unsigned char loop; +#else + int loop; +#endif + if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) { fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) does not contain a multicast address\n", inet_ntoa(mcastaddr->sin_addr), @@ -197,9 +203,9 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr } /* Force mcast msgs to loopback (eg. several QEMUs in same host */ - val = 1; + loop = 1; ret=setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, - (const char *)&val, sizeof(val)); + (const char *)&loop, sizeof(loop)); if (ret < 0) { perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)"); goto fail;