Skip to content

creation of "connected socket" returns unsupported #395

@codemonkeylabs-de

Description

@codemonkeylabs-de

Hi, while troubleshooting performance issues regarding the integration of the boringtun library into a project I am working on, I ran into the following like of code:

socket2::Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::UDP))?;

Now, creating a UDP socket of type STREAM (as opposed to DGRAM) is quite likely an error since it doesn't make much sense. This call returns an IoError(Os { code: 93, kind: Uncategorized, message: "Protocol not supported" } and the wireguard peer lookup happens on every packet received in the anonymous UDP handler thus reducing throughput to a crawl.

The fix is ofc easy enough (i.e. changing the socket type to DGRAM), I tried this myself and performance is as expected greatly improved to at least the same order of magnitude as the cloudflare warp app.. but this is what bugs me: beyond the actual problem, it strikes me as quite unlikely this is the code that cloudflare uses in production; I mean, a bug like this suggests perhaps I am not using the correct branch? Comments welcome. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions