conntrackd: cthelper: ssdp: Track UPnP eventing
PATCH v2 1/1 conntrackd: cthelper: ssdp: Track UPnP eventing
The UPnP Device Architecture spec provides a way for devices to connect back to control points, called "Eventing" (chapter 4). This sequence can look something like:
1) Outbound multicast M-SEARCH packet (dst: 1900/udp)
- Create expectation for unicast reply from <any host> to source port
2) Inbound unicast reply (there may be several of these from different devices)
- Find the device's URL, e.g.
LOCATION: http://192.168.1.123:1400/xml/device_description.xml
- Create expectation to track connections to this host:port (tcp)
3) Outbound connection to device's web server (there will be several of these)
- Watch for a SUBSCRIBE request
- Find the control point's callback URL, e.g.
CALLBACK: <http://192.168.1.124:3500/notify>
- Create expectation to open up inbound connections to this host:port
4) Inbound connections to control point's web server
- The device will send NOTIFY HTTP requests to inform the control point of new events. These can continue indefinitely. Each NOTIFY request arrives on a new TCP connection and may have a different source port.
Add the necessary code to create expectations for each of these connections and rewrite the IP in the CALLBACK URL. Tested with and without NAT.
--- doc/helper/conntrackd.conf | 10 +- src/helpers/ssdp.c | 477 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 480 insertions(+), 7 deletions(-)
doc/helper/conntrackd.conf +9 -1
@@ -84,7 +84,15 @@ Helper { QueueNum 5 QueueLen 10240 Policy ssdp { - ExpectMax 1 + ExpectMax 8 + ExpectTimeout 300 + } + } + Type ssdp inet tcp { + QueueNum 5 + QueueLen 10240 + Policy ssdp { + ExpectMax 8 ExpectTimeout 300 } }
src/helpers/ssdp.c +471 -6
522 lines not on this page · raw message
Signature · 1 line
2.11.0.390.gc69c2f50cf-goog
Quoted 5 lines · Kevin Cernekee
+ * nfct timeout add long-timewait inet tcp \
+ * established 1000 close 10time_wait10last_ack10
+ * nfct timeout add long-timewait inet tcptime_wait3600
+ * iptables -t raw -A OUTPUT -p udp --dport 1900 -j CT --helper ssdp \
+ * --timeout long-timewait
Oops, looks like this will not work (and it has a C&P error). Instead, I'll tweak the systemwide timeouts for now.
Is there a way that a conntrack user helper can change the timeout policy on a per-flow basis using NF_CT_NETLINK_TIMEOUT?
(It would be even better if the NOTIFY expectation can stay active after its parent conntrack disappears, but I wasn't able to find a way to do that.)
Pablo Neira Ayuso
maintainerQuoted 24 lines · Kevin Cernekee
The UPnP Device Architecture spec provides a way for devices to connect back to control points, called "Eventing" (chapter 4). This sequence can look something like:
1) Outbound multicast M-SEARCH packet (dst: 1900/udp)
- Create expectation for unicast reply from <any host> to source port2) Inbound unicast reply (there may be several of these from different devices)
- Find the device's URL, e.g.
LOCATION: http://192.168.1.123:1400/xml/device_description.xml
- Create expectation to track connections to this host:port (tcp)3) Outbound connection to device's web server (there will be several of these)
- Watch for a SUBSCRIBE request
- Find the control point's callback URL, e.g.
CALLBACK: <http://192.168.1.124:3500/notify>
- Create expectation to open up inbound connections to this host:port4) Inbound connections to control point's web server
- The device will send NOTIFY HTTP requests to inform the control point of new events. These can continue indefinitely. Each NOTIFY request arrives on a new TCP connection and may have a different source port.
Quoted 3 lines
Add the necessary code to create expectations for each of these connections and rewrite the IP in the CALLBACK URL. Tested with and without NAT.
I'm going to place this in the tree. Just follow up with fixes if required.
Thanks Kevin.