From: Peter Maydell <peter.maydell@linaro.org>
To: Jing Huang <jing.huang.pku@gmail.com>
Cc: riku.voipio@iki.fi, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/3] linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
Date: Mon, 16 Jul 2012 15:36:35 +0100 [thread overview]
Message-ID: <CAFEAcA9zT56enMpZtsO+q5YvLYZFntPsvyKM1e7ZPMqtatec8Q@mail.gmail.com> (raw)
In-Reply-To: <1342433652-3339-1-git-send-email-jing.huang.pku@gmail.com>
On 16 July 2012 11:14, Jing Huang <jing.huang.pku@gmail.com> wrote:
> This patch makes do_setsockopt() support SOL_RAW ICMP_FILTER socket option.
>
> Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
> ---
> linux-user/syscall.c | 20 ++++++++++++++++++++
> 1 files changed, 20 insertions(+), 0 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 28c8ba5..fc8690d 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -60,6 +60,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
> #include <netinet/ip.h>
> #include <netinet/tcp.h>
> #include <linux/wireless.h>
> +#include <linux/icmp.h>
> #include "qemu-common.h"
> #ifdef TARGET_GPROF
> #include <sys/gmon.h>
> @@ -1442,6 +1443,25 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
> goto unimplemented;
> }
> break;
> + case SOL_RAW:
> + switch (optname) {
> + case ICMP_FILTER:
> + /*struct icmp_filter takes an u32 value*/
Please add spaces after the "/*" and before the "*/".
> + optname = ICMP_FILTER;
Pointless assignment, as Dunrong says.
> + 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)));
Agreed with Dunrong, this is a pointless cast; setsockopt() takes a
void* for the optval pointer.
(Compare posix spec and see the other calls to setsockopt in this
function. The prototype of the internal kernel function implementing
setsockopt is not relevant because that is not the API that the
kernel exposes to userspace.)
> + break;
> + default:
> + goto unimplemented;
> + }
> + break;
> case TARGET_SOL_SOCKET:
> switch (optname) {
> /* Options with 'int' argument. */
> --
> 1.7.8.6
>
-- PMM
prev parent reply other threads:[~2012-07-16 14:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-16 10:14 [Qemu-devel] [PATCH v2 2/3] linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option Jing Huang
2012-07-16 3:23 ` Dunrong Huang
2012-07-16 8:13 ` Jing Huang
2012-07-16 14:36 ` Peter Maydell [this message]
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=CAFEAcA9zT56enMpZtsO+q5YvLYZFntPsvyKM1e7ZPMqtatec8Q@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).