Skip to content

netcore: ip version mismatch on socket methods causes panic #175

@npry

Description

@npry

This snippet in Elixir triggers a panic inside smoltcp:

{:ok, dev} = Tailscale.connect("my_state.json", auth_key: System.get_env("TS_RS_AUTHKEY"))
{:ok, sock} = Tailscale.Udp.bind(dev, :ip6, 1234)
Tailscale.Udp.send(udp, {1, 2, 3, 4}, 1234, "abc")
thread 'tokio-rt-worker' (22172) panicked at ...\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\smoltcp-0.13.0\src\wire\ip.rs:627:18:
IP version mismatch: src=Ipv6(fd7a:115c:a1e0::redacted) dst=Ipv4(1.2.3.4)

Expect the same thing happens anywhere we use sockets, since all the methods take an undifferentiated IpAddr — there's no difference at the type level between an IPv4 socket and and IPv6 one.

We should catch this mismatch in ts_netstack_smoltcp_core and return an error rather than allowing it to panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions