Skip to content

sendmmsg fails with EINVAL on Android #1511

Closed
@link2xt

Description

@link2xt

While trying to get quinn-based file transfer (chatmail/core#4007) working on Android, we discovered that no UDP packets are sent.

I compiled a CLI application deltachat-repl with NDK and ran it in Termux under strace to find out what is happening. Apparently all sendmmsg calls failed with EINVAL error.

Example of the first sendmmsg call:

2228  sendmmsg(18,  <unfinished ...>                                  
2229  futex(0x78c180a568, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>
2225  epoll_pwait(3,  <unfinished ...>           
2224  futex(0x78bfdf6068, FUTEX_WAIT_PRIVATE, 1, NULL <unfinished ...>
2228  <... sendmmsg resumed>[{msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(38795), sin_addr=inet_addr("192.168.178.181")}, msg_namelen=16, msg_iov=[{iov_base="\311\0\0\0\1\24\326\340\2350\360\376\2206O\230Q\317\326\274P\256\321yG\333\10\6\350\237\266\36"..., iov_len=1200}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_IP, cmsg_type=IP_TOS, cmsg_data=[0x2, 0, 0, 0]}], msg_controllen=24, msg_flags=0}}], 1, 0) = -1 EINVAL (Invalid argument)

Normally, on Linux, sendmmsg call looks like this:

413989 sendmmsg(17,  <unfinished ...>
413985 <... epoll_wait resumed>[{events=EPOLLOUT, data={u32=0, u64=0}}], 1024, 987) = 1  
413985 epoll_wait(3,  <unfinished ...>                                                                                                                        
413989 <... sendmmsg resumed>[{msg_hdr={msg_name={sa_family=AF_INET, sin_port=htons(33499), sin_addr=inet_addr("192.168.178.181")}, msg_namelen=16, msg_iov=[{iov_base="\306\0\0\0\1\24\371~\254V<\27\27\203\247\201sY\362\325\233\357\323\377\304\2\10\27\\\327\375\n"..., iov_len=1200}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_IP, cmsg_type=IP_TOS, cmsg_data=[0x2, 0, 0, 0]}], msg_controllen=24, msg_flags=0}, msg_len=1200}], 1, 0) = 1

The difference I see is msg_len=1200 when running on Linux, but not on Android, but this is a return value, it is written by the syscall on success.

Sending UDP packets with ncat from Termux works, so it is not a problem with a general network permission.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions