qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: tom.deseyn@gmail.com
To: qemu-devel@nongnu.org, laurent@vivier.eu
Cc: riku.voipio@iki.fi, Tom Deseyn <tom.deseyn@gmail.com>
Subject: [Qemu-devel] [PATCH v5] Add getsockopt for settable SOL_IPV6 options
Date: Mon,  7 Jan 2019 10:24:00 +0100	[thread overview]
Message-ID: <20190107092400.8038-1-tom.deseyn@gmail.com> (raw)
In-Reply-To: <199d2900-1f2c-4940-ae2a-d6832501f1f0@vivier.eu>

From: Tom Deseyn <tom.deseyn@gmail.com>

v2: default to unimplemented
v3: match kernel behavior
v4: braces code-style
v5: pointer code-style

Signed-off-by: Tom Deseyn <tom.deseyn@gmail.com>
---
 linux-user/syscall.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 280137da8c..a6f6e9c1f7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2352,6 +2352,47 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
             break;
         }
         break;
+    case SOL_IPV6:
+        switch (optname) {
+        case IPV6_MTU_DISCOVER:
+        case IPV6_MTU:
+        case IPV6_V6ONLY:
+        case IPV6_RECVPKTINFO:
+        case IPV6_UNICAST_HOPS:
+        case IPV6_MULTICAST_HOPS:
+        case IPV6_MULTICAST_LOOP:
+        case IPV6_RECVERR:
+        case IPV6_RECVHOPLIMIT:
+        case IPV6_2292HOPLIMIT:
+        case IPV6_CHECKSUM: {
+            void *target_addr;
+            if (get_user_u32(len, optlen)) {
+                return -TARGET_EFAULT;
+            }
+            if (len < 0) {
+                return -TARGET_EINVAL;
+            }
+            lv = sizeof(val);
+            ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
+            if (ret < 0) {
+                return ret;
+            }
+            if (lv < len) {
+                len = lv;
+            }
+            if (put_user_u32(len, optlen)) {
+                return -TARGET_EFAULT;
+            }
+            target_addr = lock_user(VERIFY_WRITE, optval_addr, len, 0);
+            tswap32s((uint32_t *)&val);
+            memcpy(target_addr, &val, len);
+            unlock_user(target_addr, optval_addr, len);
+            break;
+        }
+        default:
+            goto unimplemented;
+        }
+        break;
     default:
     unimplemented:
         gemu_log("getsockopt level=%d optname=%d not yet supported\n",
-- 
2.19.2

  parent reply	other threads:[~2019-01-07  9:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-13 13:06 [Qemu-devel] [PATCH] Add getsockopt for settable SOL_IPV6 options tom.deseyn
2018-12-13 13:37 ` [Qemu-devel] [PATCH v2] " tom.deseyn
2018-12-13 13:57   ` Laurent Vivier
2018-12-14 15:41     ` [Qemu-devel] [PATCH v3] " tom.deseyn
2018-12-23  9:21       ` no-reply
2019-01-07  5:50       ` Tom Deseyn
2019-01-07  7:12         ` Laurent Vivier
2019-01-07  8:27           ` [Qemu-devel] [PATCH v4] " tom.deseyn
2019-01-07  9:14             ` no-reply
2019-01-07  9:24           ` tom.deseyn [this message]
2018-12-13 22:11   ` [Qemu-devel] [PATCH v2] " no-reply
2018-12-13 21:28 ` [Qemu-devel] [PATCH] " no-reply

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=20190107092400.8038-1-tom.deseyn@gmail.com \
    --to=tom.deseyn@gmail.com \
    --cc=laurent@vivier.eu \
    --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).