From: Peter Maydell <peter.maydell@linaro.org>
To: Jing Huang <jing.huang.pku@gmail.com>
Cc: Riku Voipio <riku.voipio@iki.fi>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Fix ping issue for linux-user guest
Date: Wed, 11 Jul 2012 15:44:48 +0100 [thread overview]
Message-ID: <CAFEAcA-mEn5JBaYYtwigdQNMzsSKv_JWXM0fB5NgAFR4Mc5jow@mail.gmail.com> (raw)
In-Reply-To: <CAK8mDgperYdSHNQewtzYRQosn1q6=yy7MSZs9HLC=vUwqCe6SQ@mail.gmail.com>
Thanks for this patch. Review comments below...
(cc'ing the linux-user maintainer)
On 11 July 2012 14:56, Jing Huang <jing.huang.pku@gmail.com> wrote:
> 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.
These are two separate issues in two separate areas, so they
should be in separate patches.
> 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);
This patch won't apply, because your mail client or mail server has
wrapped long lines.
Also, qemu coding style doesn't allow >80 column lines. Please
run your patch through scripts/checkpatch.pl.
> + if(cmsg->cmsg_type == SO_TIMESTAMP) {
> + /*copy msg_name to target_msgh*/
> + target_msgh->msg_namelen = msgh->msg_namelen;
This is odd. We're in the middle of a loop which is for handling a
list of cmsgs, but we're operating on the msgh. So if there's
more than one SO_TIMESTAMP cmsg in the list we'll do this twice.
It seems unlikely that this should really be restricted to just
SO_TIMESTAMP.
I think what you actually want is for do_sendrcvmsg() to do
this conversion. This would parallel the way that it already
does an incoming conversion on msg_namelen/msg_name.
Also you need to do byteswapping (see the do_sendrcvmsg() code)
not just copy the length and memcpy the data.
> + 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
This looks wrong -- shouldn't the system headers provide this?
Even if not, defining a constant in the middle of code isn't very
good style.
> + case ICMP_FILTER:
> + /*struct icmp_filter takes an u32 value*/
> + optname = ICMP_FILTER;
> + if (optlen < sizeof(uint32_t))
> + return -TARGET_EINVAL;
Coding style requires braces. Again, checkpatch.pl will tell you this.
> +
> + 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. */
>
-- PMM
next prev parent reply other threads:[~2012-07-11 14:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 13:56 [Qemu-devel] [PATCH] Fix ping issue for linux-user guest Jing Huang
2012-07-11 14:44 ` Peter Maydell [this message]
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=CAFEAcA-mEn5JBaYYtwigdQNMzsSKv_JWXM0fB5NgAFR4Mc5jow@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=jing.huang.pku@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).