Skip to contentSkip to conversation

Adding some setsockopt() options

PATCH In review Shu-Chun Weng via Qemu-devel 5 participants 9 messages Aug 22, 2019 – Sep 7, 2019

lore
Share & tools
lore
#0 lore raw

cover Adding some setsockopt() options

Shu-Chun Weng (2):
linux-user: add missing UDP and IPv6 setsockopt options
linux-user: time stamping options for setsockopt()

 linux-user/generic/sockbits.h |  4 ++++
 linux-user/mips/sockbits.h    |  4 ++++
 linux-user/syscall.c          | 16 +++++++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#1 lore raw

PATCH 1/2 linux-user: add missing UDP and IPv6 setsockopt options

UDP: SOL_UDP manipulate options at UDP level. All six options currently defined in linux source include/uapi/linux/udp.h take integer values.

IPv6: IPV6_ADDR_PREFERENCES (RFC5014: Source address selection) was not supported.

---
 linux-user/syscall.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
linux-user/syscall.c +5 -1
index 8367cb138d..8dc4255f12 100644
@@ -49,8 +49,10 @@
 #include <sys/sysinfo.h>
 #include <sys/signalfd.h>
 //#include <sys/user.h>
+#include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
+#include <netinet/udp.h>
 #include <linux/wireless.h>
 #include <linux/icmp.h>
 #include <linux/icmpv6.h>
@@ -1837,7 +1839,8 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
 
     switch(level) {
     case SOL_TCP:
-        /* TCP options all take an 'int' value.  */
+    case SOL_UDP:
+        /* TCP and UDP options all take an 'int' value.  */
         if (optlen < sizeof(uint32_t))
             return -TARGET_EINVAL;
 
@@ -2488,6 +2491,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         case IPV6_RECVDSTOPTS:
         case IPV6_2292DSTOPTS:
         case IPV6_TCLASS:
+        case IPV6_ADDR_PREFERENCES:
 #ifdef IPV6_RECVPATHMTU
         case IPV6_RECVPATHMTU:
 #endif
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] linux-user: add missing UDP and IPv6 setsockopt options

Le 23/08/2019 à 01:14, Shu-Chun Weng via Qemu-devel a écrit :

Quoted 27 lines

UDP: SOL_UDP manipulate options at UDP level. All six options currently defined in linux source include/uapi/linux/udp.h take integer values.

IPv6: IPV6_ADDR_PREFERENCES (RFC5014: Source address selection) was not supported.

---
 linux-user/syscall.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
linux-user/syscall.c +2 -0
index 8367cb138d..8dc4255f12 100644
@@ -49,8 +49,10 @@
 #include <sys/sysinfo.h>
 #include <sys/signalfd.h>
 //#include <sys/user.h>
+#include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
+#include <netinet/udp.h>
 #include <linux/wireless.h>
 #include <linux/icmp.h>
 #include <linux/icmpv6.h>

linux-user/syscall.c static abi_long do_setsockopt(int sockfd, int level, int optname, · line 1843

Quoted 6 lines
linux-user/syscall.c +2 -1
@@ -1837,7 +1839,8 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
 
     switch(level) {
     case SOL_TCP:
-        /* TCP options all take an 'int' value.  */
+    case SOL_UDP:
+        /* TCP and UDP options all take an 'int' value.  */

Could you also do_getsockopt()?

linux-user/syscall.c static abi_long do_getsockopt(int sockfd, int level, int optname, · line 2494

Quoted 8 lines
linux-user/syscall.c +1 -0
         if (optlen < sizeof(uint32_t))
             return -TARGET_EINVAL;
 
@@ -2488,6 +2491,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         case IPV6_RECVDSTOPTS:
         case IPV6_2292DSTOPTS:
         case IPV6_TCLASS:
+        case IPV6_ADDR_PREFERENCES:

Could update do_setsockopt() too?

linux-user/syscall.c static abi_long do_getsockopt(int sockfd, int level, int optname, · line 2497

Quoted 4 lines
linux-user/syscall.c +0 -0
 #ifdef IPV6_RECVPATHMTU
         case IPV6_RECVPATHMTU:
 #endif

Thanks,
Laurent

#3 lore raw

PATCH 2/2 linux-user: time stamping options for setsockopt()

In reply to Shu-Chun Weng via Qemu-devel

This change supports SO_TIMESTAMPNS and SO_TIMESTAMPING for setsocketopt() with SOL_SOCKET.

The TARGET_SO_TIMESTAMP{NS,ING} constants are already defined for alpha, hppa, and sparc. In include/uapi/asm-generic/socket.h:

In arch/mips/include/uapi/asm/socket.h:

---
 linux-user/generic/sockbits.h |  4 ++++
 linux-user/mips/sockbits.h    |  4 ++++
 linux-user/syscall.c          | 10 ++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)
linux-user/generic/sockbits.h +4 -0
index e44733c601..5cbafdb49b 100644
@@ -51,6 +51,10 @@
 #define TARGET_SO_PEERNAME             28
 #define TARGET_SO_TIMESTAMP            29
 #define TARGET_SCM_TIMESTAMP           TARGET_SO_TIMESTAMP
+#define TARGET_SO_TIMESTAMPNS          35
+#define TARGET_SCM_TIMESTAMPNS         TARGET_SO_TIMESTAMPNS
+#define TARGET_SO_TIMESTAMPING         37
+#define TARGET_SCM_TIMESTAMPING        TARGET_SO_TIMESTAMPING
 
 #define TARGET_SO_ACCEPTCONN           30
 
linux-user/mips/sockbits.h +4 -0
index 0f022cd598..1246b7d988 100644
@@ -63,6 +63,10 @@
 #define TARGET_SO_PEERNAME             28
 #define TARGET_SO_TIMESTAMP            29
 #define SCM_TIMESTAMP          SO_TIMESTAMP
+#define TARGET_SO_TIMESTAMPNS          35
+#define SCM_TIMESTAMPNS         SO_TIMESTAMPNS
+#define TARGET_SO_TIMESTAMPING         37
+#define SCM_TIMESTAMPING        SO_TIMESTAMPING
 
 #define TARGET_SO_PEERSEC              30
 #define TARGET_SO_SNDBUFFORCE          31
linux-user/syscall.c +8 -2
index 8dc4255f12..bac00d3fd4 100644
@@ -2230,8 +2230,14 @@ set_timeout:
                 optname = SO_PASSSEC;
                 break;
         case TARGET_SO_TIMESTAMP:
-		optname = SO_TIMESTAMP;
-		break;
+                optname = SO_TIMESTAMP;
+                break;
+        case TARGET_SO_TIMESTAMPNS:
+                optname = SO_TIMESTAMPNS;
+                break;
+        case TARGET_SO_TIMESTAMPING:
+                optname = SO_TIMESTAMPING;
+                break;
         case TARGET_SO_RCVLOWAT:
 		optname = SO_RCVLOWAT;
 		break;
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] linux-user: time stamping options for setsockopt()

Le 23/08/2019 à 01:14, Shu-Chun Weng via Qemu-devel a écrit :

Quoted 20 lines

This change supports SO_TIMESTAMPNS and SO_TIMESTAMPING for setsocketopt() with SOL_SOCKET.

The TARGET_SO_TIMESTAMP{NS,ING} constants are already defined for alpha, hppa, and sparc. In include/uapi/asm-generic/socket.h:

In arch/mips/include/uapi/asm/socket.h:

---
 linux-user/generic/sockbits.h |  4 ++++
 linux-user/mips/sockbits.h    |  4 ++++
 linux-user/syscall.c          | 10 ++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)
linux-user/generic/sockbits.h +0 -0
index e44733c601..5cbafdb49b 100644

linux-user/generic/sockbits.h line 57

Quoted 7 lines
linux-user/generic/sockbits.h +4 -0
@@ -51,6 +51,10 @@
 #define TARGET_SO_PEERNAME             28
 #define TARGET_SO_TIMESTAMP            29
 #define TARGET_SCM_TIMESTAMP           TARGET_SO_TIMESTAMP
+#define TARGET_SO_TIMESTAMPNS          35
+#define TARGET_SCM_TIMESTAMPNS         TARGET_SO_TIMESTAMPNS
+#define TARGET_SO_TIMESTAMPING         37
+#define TARGET_SCM_TIMESTAMPING        TARGET_SO_TIMESTAMPING

We must not rely on TARGET_SO_TIMESTAMP and TARGET_SO_TIMESTAMPNS but on the _OLD and _NEW versions.

See:

6d5d5dde9adb ("linux-user: fix to handle variably sized SIOCGSTAMP with new kernels")

So the existing definitions must be removed and the _NEW and _OLD versions added.

Thanks,
Laurent

#5 lore raw
In reply to Shu-Chun Weng via Qemu-devel
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Subject: [Qemu-devel] [PATCH 0/2] Adding some setsockopt() options
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Submodule 'capstone' (https://git.qemu.org/git/capstone.git) registered for path 'capstone'
Submodule 'dtc' (https://git.qemu.org/git/dtc.git) registered for path 'dtc'
Submodule 'roms/QemuMacDrivers' (https://git.qemu.org/git/QemuMacDrivers.git) registered for path 'roms/QemuMacDrivers' Submodule 'roms/SLOF' (https://git.qemu.org/git/SLOF.git) registered for path 'roms/SLOF'
Submodule 'roms/edk2' (https://git.qemu.org/git/edk2.git) registered for path 'roms/edk2'
Submodule 'roms/ipxe' (https://git.qemu.org/git/ipxe.git) registered for path 'roms/ipxe'
Submodule 'roms/openbios' (https://git.qemu.org/git/openbios.git) registered for path 'roms/openbios'
Submodule 'roms/openhackware' (https://git.qemu.org/git/openhackware.git) registered for path 'roms/openhackware'
Submodule 'roms/opensbi' (https://git.qemu.org/git/opensbi.git) registered for path 'roms/opensbi'
Submodule 'roms/qemu-palcode' (https://git.qemu.org/git/qemu-palcode.git) registered for path 'roms/qemu-palcode'
Submodule 'roms/seabios' (https://git.qemu.org/git/seabios.git/) registered for path 'roms/seabios'
Submodule 'roms/seabios-hppa' (https://git.qemu.org/git/seabios-hppa.git) registered for path 'roms/seabios-hppa'
Submodule 'roms/sgabios' (https://git.qemu.org/git/sgabios.git) registered for path 'roms/sgabios'
Submodule 'roms/skiboot' (https://git.qemu.org/git/skiboot.git) registered for path 'roms/skiboot'
Submodule 'roms/u-boot' (https://git.qemu.org/git/u-boot.git) registered for path 'roms/u-boot'
Submodule 'roms/u-boot-sam460ex' (https://git.qemu.org/git/u-boot-sam460ex.git) registered for path 'roms/u-boot-sam460ex' Submodule 'slirp' (https://git.qemu.org/git/libslirp.git) registered for path 'slirp'
Submodule 'tests/fp/berkeley-softfloat-3' (https://git.qemu.org/git/berkeley-softfloat-3.git) registered for path 'tests/fp/berkeley-softfloat-3' Submodule 'tests/fp/berkeley-testfloat-3' (https://git.qemu.org/git/berkeley-testfloat-3.git) registered for path 'tests/fp/berkeley-testfloat-3' Submodule 'ui/keycodemapdb' (https://git.qemu.org/git/keycodemapdb.git) registered for path 'ui/keycodemapdb'
Cloning into 'capstone'...
Submodule path 'capstone': checked out '22ead3e0bfdb87516656453336160e0a37b066bf'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '88f18909db731a627456f26d779445f84e449536'
Cloning into 'roms/QemuMacDrivers'...
Submodule path 'roms/QemuMacDrivers': checked out '90c488d5f4a407342247b9ea869df1c2d9c8e266'
Cloning into 'roms/SLOF'...
Submodule path 'roms/SLOF': checked out '7bfe584e321946771692711ff83ad2b5850daca7'
Cloning into 'roms/edk2'...
Submodule path 'roms/edk2': checked out '20d2e5a125e34fc8501026613a71549b2a1a3e54'
Submodule 'SoftFloat' (https://github.com/ucb-bar/berkeley-softfloat-3.git) registered for path 'ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3' Submodule 'CryptoPkg/Library/OpensslLib/openssl' (https://github.com/openssl/openssl) registered for path 'CryptoPkg/Library/OpensslLib/openssl' Cloning into 'ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3'...
Submodule path 'roms/edk2/ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3': checked out 'b64af41c3276f97f0e181920400ee056b9c88037' Cloning into 'CryptoPkg/Library/OpensslLib/openssl'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl': checked out '50eaac9f3337667259de725451f201e784599687' Submodule 'boringssl' (https://boringssl.googlesource.com/boringssl) registered for path 'boringssl'
Submodule 'krb5' (https://github.com/krb5/krb5) registered for path 'krb5'
Submodule 'pyca.cryptography' (https://github.com/pyca/cryptography.git) registered for path 'pyca-cryptography'
Cloning into 'boringssl'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/boringssl': checked out '2070f8ad9151dc8f3a73bffaa146b5e6937a583f' Cloning into 'krb5'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/krb5': checked out 'b9ad6c49505c96a088326b62a52568e3484f2168' Cloning into 'pyca-cryptography'...
Submodule path 'roms/edk2/CryptoPkg/Library/OpensslLib/openssl/pyca-cryptography': checked out '09403100de2f6f1cdd0d484dcb8e620f1c335c8f' Cloning into 'roms/ipxe'...
Submodule path 'roms/ipxe': checked out 'de4565cbe76ea9f7913a01f331be3ee901bb6e17'
Cloning into 'roms/openbios'...
Submodule path 'roms/openbios': checked out 'c79e0ecb84f4f1ee3f73f521622e264edd1bf174'
Cloning into 'roms/openhackware'...
Submodule path 'roms/openhackware': checked out 'c559da7c8eec5e45ef1f67978827af6f0b9546f5'
Cloning into 'roms/opensbi'...
Submodule path 'roms/opensbi': checked out 'ce228ee0919deb9957192d723eecc8aaae2697c6'
Cloning into 'roms/qemu-palcode'...
Submodule path 'roms/qemu-palcode': checked out 'bf0e13698872450164fa7040da36a95d2d4b326f'
Cloning into 'roms/seabios'...
Submodule path 'roms/seabios': checked out 'a5cab58e9a3fb6e168aba919c5669bea406573b4'
Cloning into 'roms/seabios-hppa'...
Submodule path 'roms/seabios-hppa': checked out '0f4fe84658165e96ce35870fd19fc634e182e77b'
Cloning into 'roms/sgabios'...
Submodule path 'roms/sgabios': checked out 'cbaee52287e5f32373181cff50a00b6c4ac9015a'
Cloning into 'roms/skiboot'...
Submodule path 'roms/skiboot': checked out '261ca8e779e5138869a45f174caa49be6a274501'
Cloning into 'roms/u-boot'...
Submodule path 'roms/u-boot': checked out 'd3689267f92c5956e09cc7d1baa4700141662bff'
Cloning into 'roms/u-boot-sam460ex'...
Submodule path 'roms/u-boot-sam460ex': checked out '60b3916f33e617a815973c5a6df77055b2e3a588'
Cloning into 'slirp'...
Submodule path 'slirp': checked out '126c04acbabd7ad32c2b018fe10dfac2a3bc1210'
Cloning into 'tests/fp/berkeley-softfloat-3'...
Submodule path 'tests/fp/berkeley-softfloat-3': checked out 'b64af41c3276f97f0e181920400ee056b9c88037'
Cloning into 'tests/fp/berkeley-testfloat-3'...
Submodule path 'tests/fp/berkeley-testfloat-3': checked out '5a59dcec19327396a011a17fd924aed4fec416b3'
Cloning into 'ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out '6b3d716e2b6472eb7189d3220552280ef3d832ce'
Switched to a new branch 'test'
47a9de7 linux-user: time stamping options for setsockopt()
834cca5 linux-user: add missing UDP and IPv6 setsockopt options

=== OUTPUT BEGIN ===
1/2 Checking commit 834cca5e31a3 (linux-user: add missing UDP and IPv6 setsockopt options)
ERROR: Author email address is mangled by the mailing list
#2:
Author: Shu-Chun Weng via Qemu-devel <[email protected]>

total: 1 errors, 0 warnings, 26 lines checked

Patch 1/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

2/2 Checking commit 47a9de7dca1c (linux-user: time stamping options for setsockopt())
ERROR: Author email address is mangled by the mailing list
#2:
Author: Shu-Chun Weng via Qemu-devel <[email protected]>

total: 1 errors, 0 warnings, 36 lines checked

Patch 2/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#6 lore raw
In reply to Shu-Chun Weng via Qemu-devel

23.08.2019. 01.15, "Shu-Chun Weng via Qemu-devel" <[email protected]> је написао/ла:

Quoted 11 lines

Shu-Chun Weng (2):
linux-user: add missing UDP and IPv6 setsockopt options
linux-user: time stamping options for setsockopt()

 linux-user/generic/sockbits.h |  4 ++++
 linux-user/mips/sockbits.h    |  4 ++++
 linux-user/syscall.c          | 16 +++++++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)

--

Very good! Great news! This may solve some package building problems for Debian (using chroot).

May I suggest to you collecting all your outstanding linux user patches into a single series? That way the reviews would be easier and also the risk of forgetting some patch would be smaller.

謝謝 !

Aleksandar

Quoted 3 lines

2.23.0.187.g17f5b7556c-goog

#7 lore raw
In reply to Shu-Chun Weng via Qemu-devel

Ping. Patchwork links:

http://patchwork.ozlabs.org/patch/1151884/
http://patchwork.ozlabs.org/patch/1151883/

Quoted 13 lines · Shu-Chun Weng

Shu-Chun Weng (2):
linux-user: add missing UDP and IPv6 setsockopt options
linux-user: time stamping options for setsockopt()

 linux-user/generic/sockbits.h |  4 ++++
 linux-user/mips/sockbits.h    |  4 ++++
 linux-user/syscall.c          | 16 +++++++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)

--
2.23.0.187.g17f5b7556c-goog

#8 lore raw

Hi Shu-Chun Weng via Qemu-devel!

We received your email, but were unable to deliver it because it contains content which has been blacklisted by the list admin. Please remove your application/pkcs7-signature attachments and send again.

You are also advised to configure your email client to send emails in plain text to avoid additional errors in the future:

https://useplaintext.email

If you have any questions, please reply to this email to reach the mail admin. We apologise for the inconvenience.