From patchwork Thu Aug 23 01:26:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 1364101 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 334FFDF280 for ; Thu, 23 Aug 2012 01:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752150Ab2HWB2t (ORCPT ); Wed, 22 Aug 2012 21:28:49 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:49522 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751452Ab2HWB2M (ORCPT ); Wed, 22 Aug 2012 21:28:12 -0400 Received: by ghrr11 with SMTP id r11so89987ghr.19 for ; Wed, 22 Aug 2012 18:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=vYg4FPyRZra5Kk4K3pVuptBOA26yNHM4d9V9+Fdf+mA=; b=F6DO4IFDmEVHLnkyUE5GpcBtelsH9cuoEQ0gFj7jt5jd1SWHlMYZ2Qhfcpm6uhgmIi 7EZpI+yhqn1gwI63EcL1MreDBCdP9zfmzhPARbCZwY3tKiWDWIeHgNRaOpafp88jxoMt Y7QwDWZ2perfST9lzUe6w8UVhuHCOjCky/aEtDXULbyrQ74eE6uuHf+0l9UhNSKwxQ9d fjBn+gI/evTZ3iG6TSvIK7LcOYXqz8ymI91itWr3iKt2vj2nAbK4oEDls8PUtwU/QfsN DJmQMS8y82ZCgsF2KOMxqiTsnGAySm3OrqrZ0wfgDDnBRiogHDScyKpYIC8L/VTA3a9x ZR0g== Received: by 10.236.176.234 with SMTP id b70mr30255452yhm.55.1345685291629; Wed, 22 Aug 2012 18:28:11 -0700 (PDT) Received: from hj.localdomain.com ([58.194.229.103]) by mx.google.com with ESMTPS id p36sm10856450yhe.20.2012.08.22.18.28.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Aug 2012 18:28:11 -0700 (PDT) From: Asias He To: Pekka Enberg Cc: Sasha Levin , Ingo Molnar , Cyrill Gorcunov , kvm@vger.kernel.org Subject: [PATCH 2/2] kvm tools: Make tcp between guest/host virtual ip work in UIP mode Date: Thu, 23 Aug 2012 09:26:52 +0800 Message-Id: <1345685212-8081-2-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1345685212-8081-1-git-send-email-asias.hejun@gmail.com> References: <1345685212-8081-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This pach makes tcp between 'guest ip' and 'host virtual ip' work in UIP mode. (The defulat guest ip is 192.168.33.15, host virtual ip is 192.168.33.1) guest$ wget http://192.168.33.1/file guest$ ssh 192.168.33.1 Without this patch, user has to figure out the ip address of host's interface (e.g. eth0) and use that ip address to access host. With this patch, user can simply use the virtual host ip. Signed-off-by: Asias He --- tools/kvm/net/uip/tcp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/kvm/net/uip/tcp.c b/tools/kvm/net/uip/tcp.c index cf46bac..b966d8e 100644 --- a/tools/kvm/net/uip/tcp.c +++ b/tools/kvm/net/uip/tcp.c @@ -3,6 +3,7 @@ #include #include #include +#include static int uip_tcp_socket_close(struct uip_tcp_socket *sk, int how) { @@ -66,8 +67,11 @@ static struct uip_tcp_socket *uip_tcp_socket_alloc(struct uip_tx_arg *arg, u32 s sk->fd = socket(AF_INET, SOCK_STREAM, 0); sk->addr.sin_family = AF_INET; - sk->addr.sin_addr.s_addr = dip; sk->addr.sin_port = dport; + sk->addr.sin_addr.s_addr = dip; + + if (ntohl(dip) == arg->info->host_ip) + sk->addr.sin_addr.s_addr = inet_addr("127.0.0.1"); ret = connect(sk->fd, (struct sockaddr *)&sk->addr, sizeof(sk->addr)); if (ret) {