Skip to content

Commit d7f452c

Browse files
committed
net/portmapper: send discovery packet for IGD specifically.
There appear to be devices out there which send only their first descriptor in response to a discovery packet for `ssdp:all`, for example the Sagemcom FAST3890V3 only sends urn:schemas-wifialliance-org:device:WFADevice:1 Send both ssdp:all and a discovery frame for InternetGatewayDevice specifically. Updates tailscale#3557 Signed-off-by: Denton Gentry <dgentry@tailscale.com>
1 parent 09eaba9 commit d7f452c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

net/portmapper/portmapper.go

+16
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,16 @@ func (c *Client) Probe(ctx context.Context) (res ProbeResult, err error) {
749749
// See https://github.com/tailscale/tailscale/issues/3197 for
750750
// an example of a device that strictly implements UPnP, and
751751
// only responds to multicast queries.
752+
//
753+
// Then we send a discovery packet looking for
754+
// urn:schemas-upnp-org:device:InternetGatewayDevice:1 specifically, not
755+
// just ssdp:all, because there appear to be devices which only send
756+
// their first descriptor (like urn:schemas-wifialliance-org:device:WFADevice:1)
757+
// in response to ssdp:all. https://github.com/tailscale/tailscale/issues/3557
752758
metricUPnPSent.Add(1)
753759
uc.WriteTo(uPnPPacket, upnpAddr)
754760
uc.WriteTo(uPnPPacket, upnpMulticastAddr)
761+
uc.WriteTo(uPnPIGDPacket, upnpMulticastAddr)
755762
}
756763

757764
buf := make([]byte, 1500)
@@ -877,6 +884,15 @@ var uPnPPacket = []byte("M-SEARCH * HTTP/1.1\r\n" +
877884
"MAN: \"ssdp:discover\"\r\n" +
878885
"MX: 2\r\n\r\n")
879886

887+
// Send a discovery frame for InternetGatewayDevice, since some devices respond
888+
// to ssdp:all with only their first descriptor (which is often not IGD).
889+
// https://github.com/tailscale/tailscale/issues/3557
890+
var uPnPIGDPacket = []byte("M-SEARCH * HTTP/1.1\r\n" +
891+
"HOST: 239.255.255.250:1900\r\n" +
892+
"ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1\r\n" +
893+
"MAN: \"ssdp:discover\"\r\n" +
894+
"MX: 2\r\n\r\n")
895+
880896
// PCP/PMP metrics
881897
var (
882898
// metricPXPResponse counts the number of times we received a PMP/PCP response.

0 commit comments

Comments
 (0)