FONNEMANN Mark, on sam. 29 avril 2017 18:25:26 +0000, wrote:
> 0 packets received by filter

Ok, so nothing going out from qemu. Could you try to apply the attached
patch to qemu-2.9 and see what it makes qemu print when you resolve a
domain from the guest?

Samuel
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -814,11 +814,18 @@ void sotranslate_out(struct socket *so,
 
     switch (addr->ss_family) {
     case AF_INET:
+        fprintf(stderr,"translating %x against %x %x\n",
+                so->so_faddr.s_addr,
+                slirp->vnetwork_mask.s_addr,
+                slirp->vnameserver_addr.s_addr);
         if ((so->so_faddr.s_addr & slirp->vnetwork_mask.s_addr) ==
                 slirp->vnetwork_addr.s_addr) {
             /* It's an alias */
+            fprintf(stderr,"it's an alias\n");
             if (so->so_faddr.s_addr == slirp->vnameserver_addr.s_addr) {
+                fprintf(stderr,"it's DNS\n");
                 if (get_dns_addr(&sin->sin_addr) < 0) {
+                    fprintf(stderr,"didn't get DNS address");
                     sin->sin_addr = loopback_addr;
                 }
             } else {
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -133,6 +133,10 @@ udp_input(register struct mbuf *m, int i
        lhost4->sin_addr = ip->ip_src;
        lhost4->sin_port = uh->uh_sport;
 
+        if (ntohs(uh->uh_dport) == 53 &&
+            ip->ip_dst.s_addr == slirp->vnameserver_addr.s_addr)
+            fprintf(stderr,"UDP packet for DNS server\n");
+
         /*
          *  handle DHCP/BOOTP
          */
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -165,6 +165,7 @@ static int get_dns_addr_resolv_conf(int
 #endif
     while (fgets(buff, 512, f) != NULL) {
         if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) {
+            fprintf(stderr,"got resolv.conf entry '%s'\n", buff2);
             char *c = strchr(buff2, '%');
             if (c) {
                 if_index = if_nametoindex(c + 1);
@@ -174,10 +175,16 @@ static int get_dns_addr_resolv_conf(int
             }
 
             if (!inet_pton(af, buff2, tmp_addr)) {
+                fprintf(stderr,"couldn't parse it\n");
                 continue;
             }
             /* If it's the first one, set it to dns_addr */
             if (!found) {
+                if (af == AF_INET)
+                {
+                    struct sockaddr_in *sin = tmp_addr;
+                    fprintf(stderr,"parsed %x\n", sin->sin_addr.s_addr);
+                }
                 memcpy(pdns_addr, tmp_addr, addrlen);
                 memcpy(cached_addr, tmp_addr, addrlen);
                 if (scope_id) {
@@ -219,6 +226,7 @@ int get_dns_addr(struct in_addr *pdns_ad
 
     if (dns_addr.s_addr != 0) {
         int ret;
+        fprintf(stderr,"dns_addr is cached: %x\n", dns_addr.s_addr);
         ret = get_dns_addr_cached(pdns_addr, &dns_addr, sizeof(dns_addr),
                                   &dns_addr_stat, &dns_addr_time);
         if (ret <= 0) {

Reply via email to