All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jing Huang <jing.huang.pku@gmail.com>
To: lu_zero@gentoo.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Fix ping issue for linux-user guest
Date: Wed, 11 Jul 2012 13:56:45 +0000	[thread overview]
Message-ID: <CAK8mDgperYdSHNQewtzYRQosn1q6=yy7MSZs9HLC=vUwqCe6SQ@mail.gmail.com> (raw)

This patch fix ping issues for linux-user guest.

* The do_setsockopts function in linux-user does not support SOL_RAW
socket which is used in ping net tool.

* The recvmsg in main_loop of ping could not fetch
sockaddr_in struct. That is because do_sendrecvmsg in linux-user does
not pass the msg->msg_name to the target.

We fix the above issues.


Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
---
 syscall.c        |    24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff -git a/linux-user/syscall.c b/linux-user/syscall.c
index 5346554..3343345 e43f56
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1349,7 +1349,13 @@target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(len));

         if (cmsg->cmsg_level != TARGET_SOL_SOCKET || cmsg->cmsg_type
!= SCM_RIGHTS) {
-            gemu_log("Unsupported ancillary data: %d/%d\n",
cmsg->cmsg_level, cmsg->cmsg_type);
+            if(cmsg->cmsg_type == SO_TIMESTAMP) {
+                /*copy msg_name to target_msgh*/
+                target_msgh->msg_namelen = msgh->msg_namelen;
+                memcpy(g2h((void *)(unsigned
long)(target_ulong)target_msgh->msg_name), msgh->msg_name,
msgh->msg_namelen);
+            } else {
+                gemu_log("Unsupported ancillary data: %d/%d\n",
cmsg->cmsg_level, cmsg->cmsg_type);
+            }
             memcpy(target_data, data, len);
         } else {
             int *fd = (int *)data;
@@ -1442,6 +1448,23 @@
             goto unimplemented;
         }
         break;
+    case SOL_RAW:
+    	switch (optname) {
+#define ICMP_FILTER 1
+        case ICMP_FILTER:
+            /*struct icmp_filter takes an u32 value*/
+            optname = ICMP_FILTER;
+            if (optlen < sizeof(uint32_t))
+                return -TARGET_EINVAL;
+
+            if (get_user_u32(val, optval_addr))
+                return -TARGET_EFAULT;
+            ret = get_errno(setsockopt(sockfd, level, optname, (char
*)&val, sizeof(val)));
+            break;
+        default:
+            goto unimplemented;
+        }
+        break;
     case TARGET_SOL_SOCKET:
         switch (optname) {
             /* Options with 'int' argument.  */

             reply	other threads:[~2012-07-11 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 13:56 Jing Huang [this message]
2012-07-11 14:44 ` [Qemu-devel] [PATCH] Fix ping issue for linux-user guest Peter Maydell
2012-07-11 15:01 ` Dunrong Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAK8mDgperYdSHNQewtzYRQosn1q6=yy7MSZs9HLC=vUwqCe6SQ@mail.gmail.com' \
    --to=jing.huang.pku@gmail.com \
    --cc=lu_zero@gentoo.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.