Bug 210255 - IP_UNICAST_IF has no effect on connect()ed UDP sockets
Summary: IP_UNICAST_IF has no effect on connect()ed UDP sockets
Status: NEW
Alias: None
Product: Networking
Classification: Unclassified
Component: IPV4 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-18 15:06 UTC by Lennart Poettering
Modified: 2020-11-18 15:06 UTC (History)
0 users

See Also:
Kernel Version: 5.9.0-36.fc34.x86_64
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Lennart Poettering 2020-11-18 15:06:51 UTC
The IP_UNICAST_IF sockopt has an effect for unconnected UDP sockets, and is used as key for the route lookup. However, when using connect() on an UDP socket, then the routing decision is already done at connect() time, and unlike the routing decision for unconnected sockets the IP_UNICAST_IF sockopt is not taken into consideration then.

I figure this was simply forgotten when IP_UNICAST_IF was added, but I am pretty sure this should be corrected so that connected and unconnected UDP sockets behave more alike.

(SO_BINDTODEVICE/SO_BINDTOINDEX actually works on both equally, but given they do a lot more than IP_UNICAST_IF they are no replacement)

(This was noticed in context of the UDP/DNS code in systemd-resolved, see this for further discussion: https://github.com/systemd/systemd/issues/11935#issuecomment-618691018)

(The research on this was done by hvenev, not me, I am just propagating his findings here.)

Note You need to log in before you can comment on or make changes to this bug.