10000 router: STUN implementation by jdslab · Pull Request #4740 · scionproto/scion · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

router: STUN implementation #4740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open

router: STUN implementation #4740

wants to merge 42 commits into from

Conversation

jdslab
Copy link
@jdslab jdslab commented Mar 25, 2025

Modification to border router dataplane to process STUN requests, as described in the design document and discussion.

@jdslab jdslab requested a review from jiceatscion as a code owner March 25, 2025 02:27
@jiceatscion
Copy link
Contributor

This change is Reviewable

Copy link
Contributor
@jiceatscion jiceatscion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds mostly good. I very much appreciated that you implemented the STUN detection as an error case and handle it on the Slow path. That makes the extra cost zero. Maybe you could consider also gating the feature with a command-line flag. I can imagine cases where users do not want to host the stun service, just to reduce attack surfaces no matter how small. Doc-wise, is the STUN/SCION headers overlap explained anywhere? The fact the STUN packet looks like a SCION packet with Next Header type 2 and Header length 1, needs to be memorialized somewhere if it hasn't been, and your code should refer to it, so that we never break that invariant accidentally.

Reviewed 15 of 15 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @jdslab)


demo/stun/test-client/main.go line 1 at r1 (raw file):

package main

Copyright? License?


demo/stun/test-server/main.go line 1 at r1 (raw file):

package main

Ditto


demo/stun/test.py line 4 at r1 (raw file):

# Copyright 2024 ETH Zurich
#
  1. It's new code, right?

demo/stun/test.py line 114 at r1 (raw file):

    def _run(self):
        time.sleep(10) # wait for everything to start up

How reliable is that time guess? Can we probe readiness instead? It is OK for a test take 10 seconds or even much more, but provided we don't have too many of those.

if err != nil {
return serrors.Wrap("processing STUN packet", err)
}
resp := stun.Response(txid, pkt.SrcAddr.AddrPort())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might need to make some changes to support this nowadays. The connected links do not set the packet's srcAddr because it is (until now) not used for anything. We might need to change that. Must the address really be repeated in the stun packet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, yes. Sending back the underlay source address (as seen by the router) is at the core of how STUN works:

"The STUN server copies that source transport address into an XOR-MAPPED-ADDRESS attribute in the STUN Binding response and sends the Binding response back to the STUN client."

https://datatracker.ietf.org/doc/html/rfc8489#section-2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duh! I'm stupid. Yeah, the address must make it back to the client somehow. Should we move the stun server directly into the underlay? After all, IP NAT is an underlay business. It would have no reason to exist without an IP-based underlay at least. Either way. I can re-expose the src to the upper layer if need be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the underlay seems like the logical place for the STUN functionality, provided we can also achieve some degree of reuse across various UDP/IP-based underlay implementations. I'm not yet deep enough in the details of the new underlay structure to say whether this would work without hitting additional issues, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0