[PATCH 2/2] kvm tools: Make tcp between guest/host virtual ip work in UIP mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <asias.hejun@xxxxxxxxx>
---
 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 <linux/virtio_net.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
+#include <arpa/inet.h>
 
 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) {
-- 
1.7.11.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux