From: Tomas Krcka <tomas.krcka@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Riku Voipio <riku.voipio@iki.fi>,
Laurent Vivier <laurent@vivier.eu>,
Tomas Krcka <tomas.krcka@gmail.com>
Subject: [PATCH 1/2] linux-user: add do_setsockopt SOL_CAN_RAW CAN_RAW_FILTER support
Date: Wed, 6 May 2020 15:21:13 +0200 [thread overview]
Message-ID: <20200506132114.76406-1-tomas.krcka@gmail.com> (raw)
Signed-off-by: Tomas Krcka <tomas.krcka@gmail.com>
---
linux-user/syscall.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 05f03919ff..88d4c85b70 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -56,6 +56,7 @@
#include <linux/wireless.h>
#include <linux/icmp.h>
#include <linux/icmpv6.h>
+#include <linux/can/raw.h>
#include <linux/errqueue.h>
#include <linux/random.h>
#ifdef CONFIG_TIMERFD
@@ -2111,6 +2112,39 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
goto unimplemented;
}
break;
+ case SOL_CAN_RAW:
+ switch (optname) {
+ case CAN_RAW_FILTER:
+ {
+ if (optlen % sizeof(struct can_filter) != 0) {
+ return -TARGET_EINVAL;
+ }
+
+ struct can_filter *can_filters = NULL;
+ if (optlen != 0) {
+ can_filters = g_new0(struct can_filter, optlen);
+
+ if (!can_filters) {
+ return -TARGET_ENOMEM;
+ }
+ if (copy_from_user(can_filters, optval_addr, optlen)) {
+ g_free(can_filters);
+ return -TARGET_EFAULT;
+ }
+ for (val = 0; val < optlen / sizeof(struct can_filter); val++) {
+ can_filters[val].can_id = tswap32(can_filters[val].can_id);
+ can_filters[val].can_mask = tswap32(can_filters[val].can_mask);
+ }
+ }
+ ret = get_errno(setsockopt(sockfd, level, optname,
+ can_filters, optlen));
+ g_free(can_filters);
+ break;
+ }
+ default:
+ goto unimplemented;
+ }
+ break;
case SOL_RAW:
switch (optname) {
case ICMP_FILTER:
--
2.17.1
next reply other threads:[~2020-05-06 14:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-06 13:21 Tomas Krcka [this message]
2020-05-06 13:21 ` [PATCH 2/2] linux-user: add do_setsockopt CAN_RAW_FD_FRAMES support Tomas Krcka
2020-05-12 20:20 ` Laurent Vivier
2020-05-12 20:09 ` [PATCH 1/2] linux-user: add do_setsockopt SOL_CAN_RAW CAN_RAW_FILTER support Laurent Vivier
2020-05-12 21:05 ` Tomas Krcka
2020-05-13 8:56 ` Laurent Vivier
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=20200506132114.76406-1-tomas.krcka@gmail.com \
--to=tomas.krcka@gmail.com \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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).