diff mbox series

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

Message ID 20190822231443.172099-2-scw@google.com
State New
Headers show
Series Adding some setsockopt() options | expand

Commit Message

Cameron Esfahani via Aug. 22, 2019, 11:14 p.m. UTC
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.

Signed-off-by: Shu-Chun Weng <scw@google.com>
---
 linux-user/syscall.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Laurent Vivier Sept. 7, 2019, 2:10 p.m. UTC | #1
Le 23/08/2019 à 01:14, Shu-Chun Weng via Qemu-devel a écrit :
> 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.
> 
> Signed-off-by: Shu-Chun Weng <scw@google.com>
> ---
>  linux-user/syscall.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 8367cb138d..8dc4255f12 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -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.  */

Could you also do_getsockopt()?

>          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?

>  #ifdef IPV6_RECVPATHMTU
>          case IPV6_RECVPATHMTU:
>  #endif
> 

Thanks,
Laurent
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8367cb138d..8dc4255f12 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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