Kernel: T8605: net/l2tp: allow unmanaged tunnel setup without route to peer - #1189
Conversation
…o peer Kernel-created L2TPv3 tunnels (genetlink L2TP_CMD_TUNNEL_CREATE without L2TP_ATTR_FD) used udp_sock_create() and kernel_connect(), which invoke __ip4_datagram_connect() / __ip6_datagram_connect(). Those paths insist on a successful FIB lookup at connect time. If no route to the configured remote existed yet, tunnel and interface creation failed. The data path already resolves routes on transmit (e.g. __ip_queue_xmit(), inet6_csk_route_socket()). This change defers requiring a route until packets are sent. Details: - UDP encapsulation: bind with udp_sock_create() after zeroing peer_udp_port, then l2tp_udp_sk_set_peer() sets daddr/dport and socket "connected" state without caching sk_dst from connect. - IPv4 L2TP/IP (l2tp_ip): on -ENETUNREACH / -EHOSTUNREACH from __ip4_datagram_connect(), l2tp_ip_connect_deferred() installs peer and bind-table updates without a connect-time route. - IPv6 L2TP/IP (l2tp_ip6): same for __ip6_datagram_connect(), including IPv4-mapped peers and scope / bound-device checks aligned with the normal connect path. Forwarding still only happens once the FIB can reach the peer. Until then outgoing packets follow the existing no-route drop path. Assisted-by: Cursor:claude-4.6-opus Signed-off-by: Christian Breunig <christian@breunig.cc>
|
👍 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🧰 Additional context used🔍 Remote MCP Context7Relevant facts found
Sources searched (Context7 / Linux kernel docs): results for L2TP tunnel socket creation, L2TP netlink API and attributes, and examples for UDP/IP tunnel socket creation. 📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughDefers L2TP tunnel peer route validation from creation to transmit time by splitting UDP socket creation and adding deferred connect/install paths for IPv4 and IPv6 (including IPv4-mapped peers), plus bind-table registration on deferred install. ChangesL2TP Route Deferral
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Comment |
sever-sever
left a comment
There was a problem hiding this comment.
Add a patch to the L2TP tunnel interfaces that lack routes to the peer to avoid fails.
|
Fix is verified in both rolling and sagitta: Config from the original report (loopback source, remote behind a static route, l2tpv3 in bridge) commits cleanly in a single commit on RouterA(fixed build), survives reboot, and forwards real L2 traffic end-to-end:
Topology: tcpdump: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@scripts/package-build/linux-kernel/patches/kernel/0004-l2tp-defer-route-at-tunnel-create.patch`:
- Around line 60-77: The new branch for AF_INET6 bypasses the IPv6 connect-time
validation from kernel_connect()/udp_sock_create6()/__ip6_datagram_connect(), so
revert to invoking the IPv6 connect path (call kernel_connect() on AF_INET6
sockets) or re-run the same validation checks for scope-less link-local
addresses and IPv4-mapped peers before marking the socket connected;
specifically, for the AF_INET6 branch that now sets sk->sk_v6_daddr and
inet6_sk()->flow_label, perform the same checks/logic as
__ip6_datagram_connect()/udp_sock_create6() (or call kernel_connect()) to ensure
interface-binding, scope validation and mapped-address handling are applied
prior to calling reuseport_has_conns_set(sk), sk_set_txhash(sk) and
atomic_set(&inet->inet_id, ...).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 91d15920-9d91-4eb7-9132-8745658a81ab
📒 Files selected for processing (1)
scripts/package-build/linux-kernel/patches/kernel/0004-l2tp-defer-route-at-tunnel-create.patch
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: codeql-analysis-call / Analyze (python)
- GitHub Check: Mergify Merge Protections
- GitHub Check: Summary
🔇 Additional comments (1)
scripts/package-build/linux-kernel/patches/kernel/0004-l2tp-defer-route-at-tunnel-create.patch (1)
82-109: LGTM!Also applies to: 118-119, 139-168, 176-196, 217-325, 333-355
Change summary
Kernel-created L2TPv3 tunnels (genetlink
L2TP_CMD_TUNNEL_CREATEwithoutL2TP_ATTR_FD) usedudp_sock_create()andkernel_connect(), which invoke__ip4_datagram_connect()/__ip6_datagram_connect(). Those paths insist on a successful FIB lookup at connect time. If no route to the configured remote existed yet, tunnel and interface creation failed.The data path already resolves routes on transmit (e.g.
__ip_queue_xmit(),inet6_csk_route_socket()). This change defers requiring a route until packets are sent.Details:
udp_sock_create()after zeroingpeer_udp_port, thenl2tp_udp_sk_set_peer()setsdaddr/dportand socket "connected" state without caching sk_dst from connect.-ENETUNREACH/-EHOSTUNREACHfrom__ip4_datagram_connect(),l2tp_ip_connect_deferred()installs peer and bind-table updates without a connect-time route.__ip6_datagram_connect(), including IPv4-mapped peers and scope / bound-device checks aligned with the normal connect path.Forwarding still only happens once the FIB can reach the peer. Until then outgoing packets follow the existing no-route drop path.
Types of changes
Related Task(s)
Related PR(s)
How to test / Smoketest result
Checklist: