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

NATMap mapping failed, resulting in an observed address error #3057

Open
wlynxg opened this issue Nov 21, 2024 · 0 comments · May be fixed by #3058
Open

NATMap mapping failed, resulting in an observed address error #3057

wlynxg opened this issue Nov 21, 2024 · 0 comments · May be fixed by #3058

Comments

@wlynxg
Copy link
Contributor

wlynxg commented Nov 21, 2024

Version Information
github.com/libp2p/go-libp2p v0.37.0

I found that my libp2p node's address list had a NATMap address with port 0 and an observed address with port 0.

2024-11-21T09:15:44.482Z        DEBUG   net/identify    identify/id.go:486      sending snapshot        {"seq": 7, "protocols": ["/ipfs/id/1.0.0","/ipfs/id/push/1.0.0","/ipfs/ping/1.0.0","/libp2p/circuit/relay/0.2.0/stop"], "addrs": [...,"/ip4/100.64.138.163/tcp/0","/ip4/100.64.138.163/udp/0/quic-v1/webtransport/certhash/uEiAO2S9URsYyw-LBGIJytw3zQbw8pvXgomESq3PLp31PVg/certhash/uEiCxf6Zi2SitEayX9jE50_APDrBMbfR5m-U6F7HcBMnkFw","/ip4/{observed ip}/tcp/0",...]}

At the same time, I found that my NAT mapping had the following error due to too many mapped addresses:

2024-11-21T09:15:42.049Z        WARN    nat     nat/nat.go:239  failed to establish port mapping: SOAP fault. Code: s:Client | Explanation: UPnPError | Detail: <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>501</errorCode><errorDescription>Port mapping table id full !</errorDescription></UPnPError>

After debugging, I found that the problem is caused by:

  1. When NAT mapping fails, port 0 will be returned

    return 0

  2. When basic_host calls AllAddrs, it gets the mapping address from natmgr, and natmrg gets the mapping address from nat. However, nat does not determine the mapping failure, resulting in port 0 being returned.

    extMaddr := h.natmgr.GetMapping(listen)

    extAddr, ok := nmgr.nat.GetMapping(protocol, port)

    if !found {

  3. basic_host replaces the port observed by the observed address with 0

    _, extMaddrNoIP := ma.SplitFirst(extMaddr)

    finalAddrs = append(finalAddrs, ma.Join(ip, extMaddrNoIP))

@wlynxg wlynxg linked a pull request Nov 21, 2024 that will close this issue
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 a pull request may close this issue.

1 participant