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

Ensure UPnP Lease is deleted on a graceful stop off safenode services #1861

Open
Az80386 opened this issue Jun 8, 2024 · 2 comments
Open
Assignees

Comments

@Az80386
Copy link

Az80386 commented Jun 8, 2024

Sample verbose log from miniupnpd service when safenode service attempts to connect via --upnp flag:

miniupnpd[492564]: HTTP REQUEST from 10.131.0.114:55664 : GET /rootDesc.xml (HTTP/1.1)
miniupnpd[492564]: Host: 10.131.0.114:34865
miniupnpd[492564]: HTTP REQUEST from 10.131.0.114:55668 : GET /WANIPCn.xml (HTTP/1.1)
miniupnpd[492564]: Host: 10.131.0.114:34865
miniupnpd[492564]: HTTP REQUEST from 10.131.0.114:55676 : POST /ctl/IPConn (HTTP/1.1)
miniupnpd[492564]: Host: 10.131.0.114:34865
miniupnpd[492564]: SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress
miniupnpd[492564]: HTTP REQUEST from 10.131.0.114:55690 : POST /ctl/IPConn (HTTP/1.1)
miniupnpd[492564]: Host: 10.131.0.114:34865
miniupnpd[492564]: SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping
miniupnpd[492564]: AddPortMapping: ext port 39133 to 10.131.0.114:39133 protocol UDP for: rust-libp2p mapping leaseduration=3600 rhost=
miniupnpd[492564]: UPnP permission rule 0 matched : port mapping accepted
miniupnpd[492564]: redirecting port 39133 to 10.131.0.114:39133 protocol UDP for: rust-libp2p mapping
miniupnpd[492564]: level=0 type=8
miniupnpd[492564]: ifindex = 3  10.131.0.114
miniupnpd[492564]: ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1 (ver=1)
miniupnpd[492564]: SSDP M-SEARCH from 10.131.0.114:57089 ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
miniupnpd[492564]: Single search found
miniupnpd[492564]: SendSSDPResponse(): 0 bytes to 10.131.0.114:57089 ST: HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uuid:00000000-0000-0000-0000-000000000000::urn:schemas-upnp-org:device:InternetGatewayDevice:1
EXT:
SERVER: Ubuntu/6.5.0-35-generic UPnP/1.1 MiniUPnPd/2.3.6
LOCATION: http://10.131.0.114:34865/rootDesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 1717887081
BOOTID.UPNP.ORG: 1717887081
CONFIGID.UPNP.ORG: 1337

When the safenode service is requested to stop, it doesn't request a deletion of the lease of the port mapping requested on initial spin up. For example, there is no log of a #DeletePortMapping (below was manually triggered outside of safenode service):

miniupnpd[492564]: level=0 type=8
miniupnpd[492564]: ifindex = 3  10.131.0.114
miniupnpd[492564]: ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1 (ver=1)
miniupnpd[492564]: SSDP M-SEARCH from 10.131.0.114:47360 ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
miniupnpd[492564]: Single search found
miniupnpd[492564]: SendSSDPResponse(): 0 bytes to 10.131.0.114:47360 ST: HTTP/1.1 200 OK
CACHE-CONTROL: max-age=1800
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
USN: uuid:00000000-0000-0000-0000-000000000000::urn:schemas-upnp-org:device:InternetGatewayDevice:1
EXT:
SERVER: Ubuntu/6.5.0-35-generic UPnP/1.1 MiniUPnPd/2.3.6
LOCATION: http://10.131.0.114:34865/rootDesc.xml
OPT: "http://schemas.upnp.org/upnp/1/0/"; ns=01
01-NLS: 1717887081
BOOTID.UPNP.ORG: 1717887081
CONFIGID.UPNP.ORG: 1337

miniupnpd[492564]: HTTP REQUEST from 10.131.0.114:51736 : GET /rootDesc.xml (HTTP/1.1)
miniupnpd[492564]: Host: 10.131.0.114:34865
miniupnpd[492564]: HTTP REQUEST from 10.131.0.114:51746 : POST /ctl/IPConn (HTTP/1.1)
miniupnpd[492564]: Host: 10.131.0.114:34865
miniupnpd[492564]: SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetStatusInfo
miniupnpd[492564]: HTTP REQUEST from 10.131.0.114:51760 : POST /ctl/IPConn (HTTP/1.1)
miniupnpd[492564]: Host: 10.131.0.114:34865
miniupnpd[492564]: SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress
miniupnpd[492564]: HTTP REQUEST from 10.131.0.114:51774 : POST /ctl/IPConn (HTTP/1.1)
miniupnpd[492564]: Host: 10.131.0.114:34865
miniupnpd[492564]: SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#DeletePortMapping
miniupnpd[492564]: DeletePortMapping: external port: 39133, protocol: UDP
miniupnpd[492564]: removing redirect rule port 39133 UDP
miniupnpd[492564]: Trying to delete nat rule at index 4
miniupnpd[492564]: Trying to delete filter rule at index 4
miniupnpd[492564]: postrouting rule #0: MASQUERADE 10.131.0.114 52506
miniupnpd[492564]: postrouting rule #1: MASQUERADE 10.131.0.114 50537
miniupnpd[492564]: postrouting rule #2: MASQUERADE 10.131.0.114 57901
miniupnpd[492564]: postrouting rule #3: MASQUERADE 10.131.0.114 60521
miniupnpd[492564]: postrouting rule #4: MASQUERADE 10.131.0.114 39133
miniupnpd[492564]: Trying to delete peer rule at index 4
@mickvandijke mickvandijke self-assigned this Jul 19, 2024
@mickvandijke
Copy link
Contributor

This should be handled by libp2p. But after peeking at their code, it seems that there is no option for a graceful shutdown that also removes the upnp port mappings. Guess we'll have to wait for them to implement this.

@mickvandijke
Copy link
Contributor

Opened an issue for it: libp2p/rust-libp2p#5532

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

No branches or pull requests

2 participants