Skip to content
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

net/portmapper: fix UPnP probing #2572

Merged
merged 1 commit into from
Aug 4, 2021
Merged

net/portmapper: fix UPnP probing #2572

merged 1 commit into from
Aug 4, 2021

Conversation

bradfitz
Copy link
Member

@bradfitz bradfitz commented Aug 3, 2021

Prior to Tailscale 1.12 it detected UPnP on any port.
Starting with Tailscale 1.11.x, it stopped detecting UPnP on all ports.

Then use the Location header to find the rootDesc.xml, rather than hard-coding the URL + port.

And remove the three goroutines doing redundant & racing rootDesc.xml fetches.

And use netns so it works while using exit nodes.

Works against pfSense now.

Updates #2109

@bradfitz
Copy link
Member Author

bradfitz commented Aug 3, 2021

I'm now getting, against pfSense:

root@tailtest:~# ./tailscaled debug -portmap
2021/08/02 22:07:16 portmapper: unexpected PMP probe response: {OpCode:128 ResultCode:3 SecondsSinceEpoch:8671 MappingValidSeconds:0 InternalPort:0 ExternalPort:0 PublicAddr:0.0.0.0}
2021/08/02 22:07:16 portmapper: Got PCP response: epoch: 8671
2021/08/02 22:07:16 UPnP reply from 192.168.1.1:2189: HTTP/1.1 200 OK
CACHE-CONTROL: max-age=120
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uuid:bee7052b-49e8-3597-b545-55a1e38ac11::urn:schemas-upnp-org:device:InternetGatewayDevice:1
EXT:
SERVER: FreeBSD/12.2-STABLE UPnP/1.1 MiniUPnPd/2.2.1
LOCATION: http://192.168.1.1:2189/rootDesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 1627958564
BOOTID.UPNP.ORG: 1627958564
CONFIGID.UPNP.ORG: 1337

2021/08/02 22:07:16 Probe: {PCP:true PMP:false UPnP:true}
2021/08/02 22:07:16 no mapping
2021/08/02 22:07:16 Getting root desc: http://192.168.1.1:2189/rootDesc.xml
2021/08/02 22:07:16 XXX meth1: [0xc000315200]
2021/08/02 22:07:16 XXX client = &{{0xc000336000 0xc000212000 http://192.168.1.1:2189/rootDesc.xml Service ID urn:upnp-org:serviceId:WANIPConn1 : urn:schemas-upnp-org:service:WANIPConnection:1}}
2021/08/02 22:07:16 XXX meth2: error requesting root device details from "http://192.168.1.1:2189/rootDesc.xml": Get "http://192.168.1.1:2189/rootDesc.xml": context canceled
2021/08/02 22:07:16 XXX meth3: error requesting root device details from "http://192.168.1.1:2189/rootDesc.xml": Get "http://192.168.1.1:2189/rootDesc.xml": context canceled
2021/08/02 22:07:16 XXX addAny = SOAP fault: 

net/portmapper/upnp.go Outdated Show resolved Hide resolved
net/portmapper/upnp.go Outdated Show resolved Hide resolved
@bradfitz bradfitz force-pushed the bradfitz/debug_portmap branch 5 times, most recently from 7dc51f7 to d339759 Compare August 4, 2021 15:44
@bradfitz bradfitz marked this pull request as ready for review August 4, 2021 15:44
net/portmapper/disabled_stubs.go Show resolved Hide resolved
net/portmapper/portmapper.go Outdated Show resolved Hide resolved
net/portmapper/portmapper.go Outdated Show resolved Hide resolved
net/portmapper/portmapper.go Outdated Show resolved Hide resolved
@bradfitz bradfitz force-pushed the bradfitz/debug_portmap branch 2 times, most recently from 59d3113 to 72aa6d5 Compare August 4, 2021 19:18
@bradfitz bradfitz requested a review from crawshaw August 4, 2021 19:18
Copy link
Member

@crawshaw crawshaw left a comment

Choose a reason for hiding this comment

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

woo tests

net/portmapper/upnp.go Outdated Show resolved Hide resolved
net/portmapper/upnp.go Outdated Show resolved Hide resolved
Prior to Tailscale 1.12 it detected UPnP on any port.
Starting with Tailscale 1.11.x, it stopped detecting UPnP on all ports.

Then start plumbing its discovered Location header port number to the
code that was assuming port 5000.

Fixes #2109

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
@bradfitz bradfitz merged commit fdc081c into main Aug 4, 2021
@bradfitz bradfitz deleted the bradfitz/debug_portmap branch August 4, 2021 19:49
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.

None yet

3 participants