Skip to content

Commit

Permalink
linux-user: add missing UDP get/setsockopt option
Browse files Browse the repository at this point in the history
SOL_UDP manipulate options at UDP level. All six options currently defined
in linux source include/uapi/linux/udp.h take integer values.

Signed-off-by: Shu-Chun Weng <scw@google.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20201218193213.3566856-3-scw@google.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
  • Loading branch information
scweng authored and vivier committed Jan 20, 2021
1 parent 2bb963f commit fe51b0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions linux-user/strace.c
Expand Up @@ -7,6 +7,7 @@
#include <sys/mount.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <linux/if_packet.h>
#include <linux/netlink.h>
#include <sched.h>
Expand Down Expand Up @@ -2644,6 +2645,11 @@ static void do_print_sockopt(const char *name, abi_long arg1)
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
print_pointer(optval, 0);
break;
case SOL_UDP:
qemu_log("SOL_UDP,");
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
print_pointer(optval, 0);
break;
case SOL_IP:
qemu_log("SOL_IP,");
print_raw_param(TARGET_ABI_FMT_ld, optname, 0);
Expand Down
7 changes: 5 additions & 2 deletions linux-user/syscall.c
Expand Up @@ -53,6 +53,7 @@
//#include <sys/user.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>
Expand Down Expand Up @@ -2184,7 +2185,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;

Expand Down Expand Up @@ -2832,7 +2834,8 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
}
break;
case SOL_TCP:
/* TCP options all take an 'int' value. */
case SOL_UDP:
/* TCP and UDP options all take an 'int' value. */
int_case:
if (get_user_u32(len, optlen))
return -TARGET_EFAULT;
Expand Down

0 comments on commit fe51b0a

Please sign in to comment.