From patchwork Tue Feb 2 02:36:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 576930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0D433140B0F for ; Tue, 2 Feb 2016 13:41:58 +1100 (AEDT) Received: from localhost ([::1]:54893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQQui-0001A7-3n for incoming@patchwork.ozlabs.org; Mon, 01 Feb 2016 21:41:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQQqe-00015K-Qm for qemu-devel@nongnu.org; Mon, 01 Feb 2016 21:37:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQQqd-0000JR-TG for qemu-devel@nongnu.org; Mon, 01 Feb 2016 21:37:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQQqd-0000JE-K3 for qemu-devel@nongnu.org; Mon, 01 Feb 2016 21:37:43 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 3E8F0804EB; Tue, 2 Feb 2016 02:37:43 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (vpn1-6-248.pek2.redhat.com [10.72.6.248]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u122aNSA024254; Mon, 1 Feb 2016 21:37:38 -0500 From: Jason Wang To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Tue, 2 Feb 2016 10:36:16 +0800 Message-Id: <1454380581-7881-13-git-send-email-jasowang@redhat.com> In-Reply-To: <1454380581-7881-1-git-send-email-jasowang@redhat.com> References: <1454380581-7881-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Samuel Thibault , Jason Wang , Guillaume Subiron Subject: [Qemu-devel] [PULL 12/17] slirp: Make udp_attach IPv6 compatible 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 From: Guillaume Subiron A sa_family_t is now passed in argument to udp_attach instead of using a hardcoded "AF_INET" to call qemu_socket(). This prepares for IPv6 support. Signed-off-by: Guillaume Subiron Signed-off-by: Samuel Thibault Reviewed-by: Thomas Huth Signed-off-by: Jason Wang --- slirp/ip_icmp.c | 2 +- slirp/udp.c | 7 ++++--- slirp/udp.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c index 3a29847..592f33a 100644 --- a/slirp/ip_icmp.c +++ b/slirp/ip_icmp.c @@ -162,7 +162,7 @@ icmp_input(struct mbuf *m, int hlen) if (icmp_send(so, m, hlen) == 0) { return; } - if(udp_attach(so) == -1) { + if (udp_attach(so, AF_INET) == -1) { DEBUG_MISC((dfd,"icmp_input udp_attach errno = %d-%s\n", errno,strerror(errno))); sofree(so); diff --git a/slirp/udp.c b/slirp/udp.c index 63776c0..94e19b7 100644 --- a/slirp/udp.c +++ b/slirp/udp.c @@ -169,7 +169,7 @@ udp_input(register struct mbuf *m, int iphlen) if (!so) { goto bad; } - if(udp_attach(so) == -1) { + if (udp_attach(so, AF_INET) == -1) { DEBUG_MISC((dfd," udp_attach errno = %d-%s\n", errno,strerror(errno))); sofree(so); @@ -277,9 +277,10 @@ int udp_output(struct socket *so, struct mbuf *m, } int -udp_attach(struct socket *so) +udp_attach(struct socket *so, sa_family_t af) { - if((so->s = qemu_socket(AF_INET,SOCK_DGRAM,0)) != -1) { + so->s = qemu_socket(af, SOCK_DGRAM, 0); + if (so->s != -1) { so->so_expire = curtime + SO_EXPIRE; insque(so, &so->slirp->udb); } diff --git a/slirp/udp.h b/slirp/udp.h index a04b8ce..15e73c1 100644 --- a/slirp/udp.h +++ b/slirp/udp.h @@ -76,7 +76,7 @@ struct mbuf; void udp_init(Slirp *); void udp_cleanup(Slirp *); void udp_input(register struct mbuf *, int); -int udp_attach(struct socket *); +int udp_attach(struct socket *, sa_family_t af); void udp_detach(struct socket *); struct socket * udp_listen(Slirp *, uint32_t, u_int, uint32_t, u_int, int);