Page MenuHomeFreeBSD

linux: Allow connect() on DGRAM sockets with port 0
Needs ReviewPublic

Authored by obiwac on Mon, Oct 12, 6:10 PM.

Details

Summary

Linux allows connect() on a UDP socket with destination port 0, which FreeBSD
rejects in in_pcbconnect() and in6_pcbladdr() with EADDRNOTAVAIL. Some Linux
programs (e.g. the new Android CLI tool) rely on this for routability checks,
however.

Add an INP_CONNECT_PORT_ZERO flag to inp_flags2 which the linuxulator
sets on DGRAM socket creation, allowing them to bypass the port
0 guard in the IPv4 and IPv6 connect paths.

Test Plan

I have compiled a program that tries to connect to the zero port on FreeBSD and on Linux. Running the FreeBSD binary on FreeBSD, connect() fails with EADDRNOTAVAIL, which is the normal behaviour on FreeBSD. Running the Linux binary on FreeBSD, connect() succeeds.

The Android CLI also now works on FreeBSD.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 78078
Build 74961: arc lint + arc unit