write to TUN/TAP : Invalid argument (fd=-1,code=22)
@ordex is already working on this.
Since Sep 16, 2024.
- Dominant language
- C
- Stars
- 14.6k
- Forks
- 3.4k
- PR merge metrics
- No merged PRs in 30d
Description
Linux, kernel 6.2 (but the error is OLD, for sure starting from 5.x kernels and opevnpn 2.5) Multiple linux clients.
TUN mode, UDP. Client. Openvpn version whatever, every.
Openvpn throws this error every time it receives a MULTICAST packet from another client:
ovpn-client[2175382]: write to TUN/TAP : Invalid argument (fd=-1,code=22)
Example packet from strace (internal packet after decryption, being sent to TUN interface):
write(6, "\xfb\x00\x00\x43\x50\xc0\x00\x00\x01\x11\x7a\xee\x--\x--\x--\x--\xe0\x00\x00\xfb\x14\xe9\x14\xe9\x00\x2f\x14\x14\x00\x00\x00\x00"..., 67) = -1 EINVAL (Invalid argument)
OR:
write(6, "\xfb\x00\x00\x3d\x5b\x4f\x00\x00\x01\x11\x70\x64\x--\x--\x--\x--\xe0\x00\x00\xfc\xd6\x57\x14\xeb\x00\x29\x06\xb3\x22\x37\x00\x00"..., 61) = -1 EINVAL (Invalid argument)
Those are UDP multicast packets sent to addresses like 224.0.0.251 or similar.
Packets never reach the TUN interface so those are not visible in any network analysis.
Removing/adding MULTICAST option on the tun interface does not change anything. No iptables involved.
Openvpn logs reach enormous sizes.
IMHO Openvpn should not route multicast packets by default. (Those above came from win10 with installed openvpn)
\x--\x--\x--\x-- - internal vpn IP removed from packet data for security reasons.
Ask if any more info is needed.
[edit]
Current workaround is to remove client-to-client directive on the server side, allowing packets to go through TUN interface instead of internal openvpn mechanism.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.