Opened 18 years ago

Closed 15 years ago

#2467 closed defect (fixed)

upnp server sends unreachable IPs rendering the server invisible

Reported by: lpgcritter at nasquan dot com Owned by: Nigel
Priority: minor Milestone: unknown
Component: mythtv Version: 0.20
Severity: medium Keywords:
Cc: Ticket locked: no

Description

For a mythbackend machine with multiple network card / IPs, the mythtv upnp server will send all the IPs in the UDP datagram to the requesting client machine. It seems that the upnp client ignores all the packets if one of the IPs sent (or the first IP sent?) is unreachable (even if there are accesible), rendering the upnp server device invisible to the upnp client.

My fix is to instead of getting all the IPs on the machine, just use the one specified by BackendServerIP in the config.

Index: upnp.cpp
===================================================================
--- upnp.cpp    (revision 11291)
+++ upnp.cpp    (working copy)
@@ -222,6 +222,10 @@
 {
     sStrList.clear();

+    sStrList.append(gContext->GetSetting("BackendServerIP"));
+
+    return( sStrList.count() );
+
     QSocketDevice socket( QSocketDevice::Datagram );

     struct ifreq  ifReqs[ 16 ];

Change History (10)

comment:1 Changed 17 years ago by jk at nerdworks dott org

The IP address(es) the upnp service uses should be configureable.

Scenario:
Mythbackend server with two interfaces. eth0 is used for communication between frontends and backend and intranet. eth1 is connected to wireless router which upnp gadgets connects to. eth1 has several IP addresses, each connected to a different upnp service. I.e. TwonkyMedia? for streaming radio and MythTV for streaming TV.

Just my two cents.

--
Joran Kvalvaag

comment:2 Changed 17 years ago by dblain

Resolution: fixed
Status: newclosed

(In [13208]) Fixes #2467 - Uses BackendIPAddress setting for IP address with upnp stack

comment:3 Changed 16 years ago by anonymous

Resolution: fixed
Status: closednew

This issue is visible again in rev 15184 and it seems the patch above is not included in the upnputil.cpp

comment:4 Changed 16 years ago by anonymous

Quick update... actually as the code has changed and apparently the IP addess wasn't the problem (it's in mythbackend code now) but missing UPnP/DescXmlPath setting which caused the server to disappear as server couldn't locate CMGR_scpd.xml. Should the database been updated with the UPnP/DescXmlPath automatically? Now I had to insert it manually.

On the other hand mythfrontend still has this issue as it get all the interface IP addresses which causes issues.

comment:5 Changed 16 years ago by Nigel

The DescXmlPath? setting might by a side effect of [15051]. Do you have any debug output (backend) of the error? (before you added the database setting)

Same for the multiple interfaces - frontend debug please.

-v upnp or -v upnp,network

comment:6 Changed 16 years ago by anonymous

Here's the backend log with -v upnp,network. I added some extra logging to HTTPRequest (last couple of lines in the log):

---
2007-12-21 17:55:47.821 Using runtime prefix = /usr/local
2007-12-21 17:55:47.840 DBHostName is not set in mysql.txt
2007-12-21 17:55:47.842 Assuming localhost
2007-12-21 17:55:47.843 Empty LocalHostName.
2007-12-21 17:55:47.844 Using localhost value of tux
2007-12-21 17:55:47.846 MCP::DefaultUPnP() - No default UPnP backend
2007-12-21 17:55:47.860 New DB connection, total: 1
2007-12-21 17:55:47.868 Connected to database 'mythconverg' at host: localhost
2007-12-21 17:55:47.871 Closing DB connection named 'DBManager0'
2007-12-21 17:55:47.874 Connected to database 'mythconverg' at host: localhost
2007-12-21 17:55:47.877 Current Schema Version: 1202
Starting up as the master server.
2007-12-21 17:55:47.890 New DB connection, total: 2
2007-12-21 17:55:47.893 Connected to database 'mythconverg' at host: localhost
2007-12-21 17:55:47.902 New DB connection, total: 3
2007-12-21 17:55:47.904 Connected to database 'mythconverg' at host: localhost
2007-12-21 17:55:48.523 New DB scheduler connection
2007-12-21 17:55:48.526 Connected to database 'mythconverg' at host: localhost
2007-12-21 17:55:48.530 UPnp - Constructor
2007-12-21 17:55:48.532 MediaServer::Begin
2007-12-21 17:55:48.558 ThreadPool:AddWorkerThread - HTTP_WorkerThread
2007-12-21 17:55:48.562 UPnp::Initialize - Begin
2007-12-21 17:55:48.564 UPnp::Initialize - Starting TaskQueue
2007-12-21 17:55:48.567 UPnp::Initialize - Creating SSDP Thread at port 6544
2007-12-21 17:55:48.571 UPnp::Initialize - End
2007-12-21 17:55:48.574 MediaServer::Loading UPnp Description
2007-12-21 17:55:48.581 MediaServer::Registering MythXML Service.
2007-12-21 17:55:48.585 MediaServer::Registering MSRR Service.
2007-12-21 17:55:48.587 MediaServer::Registering CMGR Service.
2007-12-21 17:55:48.589 MediaServer::Registering CDS Service.
2007-12-21 17:55:48.591 MediaServer::Registering UPnpCDSTv Extension
2007-12-21 17:55:48.592 MediaServer::Registering UPnpCDSMusic Extension
2007-12-21 17:55:48.594 MediaServer::Registering UPnpCDSVideo Extension
2007-12-21 17:55:48.596 UPnp::Start - Starting SSDP Thread (Multicast)
2007-12-21 17:55:48.598 UPnp::Start - Enabling Notifications
2007-12-21 17:55:48.599 SSDP::EnableNotifications() - creating new task
2007-12-21 17:55:48.602 SSDP::EnableNotifications() - sending NTS_byebye
2007-12-21 17:55:48.604 LookupUDN(urn:schemas-upnp-org:device:MediaServer:1) sName=UPnP/UDN/MediaServer, sUDN=b2187616-f0de-491e-bdf6-aadccd41189e
2007-12-21 17:55:49.742 LookupUDN(urn:schemas-mythtv-org:device:MasterMediaServer:1) sName=UPnP/UDN/MasterMediaServer, sUDN=79c2d071-ab44-49f3-981d-28d19acc4d77
2007-12-21 17:55:49.913 SSDP::EnableNotifications() - sending NTS_alive
2007-12-21 17:55:49.915 SSDP::EnableNotifications() - Task added to UPnP queue
2007-12-21 17:55:49.917 UPnp::Start - Returning
2007-12-21 17:55:49.918 MediaServer::End
2007-12-21 17:55:49.919 Main::Registering HttpStatus Extension
2007-12-21 17:55:49.921 mythbackend version: 0.21.20071211-1 www.mythtv.org
2007-12-21 17:55:49.922 Enabled verbose msgs:  important general upnp network
2007-12-21 17:55:49.925 AutoExpire: CalcParams(): Max required Free Space: 1.0 GB w/freq: 15 min
2007-12-21 17:55:51.069 HTTPRequest::FormatFileReponse - file does not exist.
2007-12-21 17:55:51.553 Reschedule requested for id -1.
2007-12-21 17:55:51.673 Scheduled 6 items in 0.1 = 0.08 match + 0.04 place
2007-12-21 17:55:51.685 Seem to be woken up by USER
2007-12-21 17:55:51.688 MythEvent: SCHEDULE_CHANGE
2007-12-21 17:55:55.923 UPnpCMGR::ProcessRequest - Method (GetServDesc)
2007-12-21 17:55:55.928 HTTPRequest::FormatFileReponse - file does not exist.
2007-12-21 17:55:55.935 HTTPRequest::FormatFileReponse - file does not exist.
2007-12-21 17:57:08.532 AutoExpire: CalcParams(): Max required Free Space: 1.0 GB w/freq: 15 min
--- 

Mythfrontend log, which is a bit low on detail as it doesn't seem to have upnp stuff even though upnp logs were requested:

---
2007-12-21 17:57:59.190 Current Schema Version: 1202
2007-12-21 17:57:59.191 mythfrontend version: 0.21.20071211-1 www.mythtv.org
2007-12-21 17:57:59.191 Enabled verbose msgs:  important general upnp network
2007-12-21 17:57:59.274 The theme (blootube-wide) is missing a themeinfo.xml file
2007-12-21 17:57:59.304 The theme (Gray-OSD) is missing a themeinfo.xml file
2007-12-21 17:57:59.305 Theme Gray-OSD missing preview image.
2007-12-21 17:57:59.307 The theme (isthmus) is missing a themeinfo.xml file
2007-12-21 17:57:59.308 Theme isthmus missing preview image.
2007-12-21 17:57:59.310 The theme (Iulius) is missing a themeinfo.xml file
2007-12-21 17:57:59.311 The theme (Iulius-OSD) is missing a themeinfo.xml file
2007-12-21 17:57:59.311 Theme Iulius-OSD missing preview image.
2007-12-21 17:57:59.314 The theme (MePo-wide) is missing a themeinfo.xml file
2007-12-21 17:57:59.393 The theme (Minimalist-wide) is missing a themeinfo.xml file
2007-12-21 17:57:59.394 The theme (MythCenter) is missing a themeinfo.xml file
2007-12-21 17:57:59.394 The theme (MythCenter-wide) is missing a themeinfo.xml file
2007-12-21 17:57:59.395 The theme (oldosd) is missing a themeinfo.xml file
2007-12-21 17:57:59.395 The theme (Retro) is missing a themeinfo.xml file
2007-12-21 17:57:59.396 The theme (Retro-OSD) is missing a themeinfo.xml file
2007-12-21 17:57:59.396 Theme Retro-OSD missing preview image.
2007-12-21 17:57:59.400 The theme (Titivillus) is missing a themeinfo.xml file
2007-12-21 17:57:59.401 The theme (Titivillus-OSD) is missing a themeinfo.xml file
2007-12-21 17:57:59.401 Theme Titivillus-OSD missing preview image.
2007-12-21 17:57:59.578 The theme (blootube-wide) is missing a themeinfo.xml file
2007-12-21 17:57:59.646 The theme (Gray-OSD) is missing a themeinfo.xml file
2007-12-21 17:57:59.647 The theme (isthmus) is missing a themeinfo.xml file
2007-12-21 17:57:59.647 The theme (Iulius) is missing a themeinfo.xml file
2007-12-21 17:57:59.649 The theme (Iulius-OSD) is missing a themeinfo.xml file
2007-12-21 17:57:59.650 The theme (MePo-wide) is missing a themeinfo.xml file
2007-12-21 17:57:59.742 The theme (Minimalist-wide) is missing a themeinfo.xml file
2007-12-21 17:57:59.760 The theme (MythCenter) is missing a themeinfo.xml file
2007-12-21 17:57:59.769 The theme (MythCenter-wide) is missing a themeinfo.xml file
2007-12-21 17:57:59.780 The theme (oldosd) is missing a themeinfo.xml file
2007-12-21 17:57:59.780 The theme (Retro) is missing a themeinfo.xml file
2007-12-21 17:57:59.790 The theme (Retro-OSD) is missing a themeinfo.xml file
2007-12-21 17:57:59.791 The theme (Titivillus) is missing a themeinfo.xml file
2007-12-21 17:57:59.799 The theme (Titivillus-OSD) is missing a themeinfo.xml file
2007-12-21 17:58:00.057 Total desktop dim: 640x480, with 1 screen[s].
2007-12-21 17:58:00.059 Using screen 0, 640x480 at 0,0
2007-12-21 17:58:00.063 Switching to square mode (G.A.N.T.)
2007-12-21 17:58:00.079 Using the Qt painter
mythtv: could not connect to socket
mythtv: Connection refused
2007-12-21 17:58:00.080 lirc_init failed for mythtv, see preceding messages
2007-12-21 17:58:00.080 Joystick disabled.
2007-12-21 17:58:01.093 Loading from: /usr/local/share/mythtv/themes/G.A.N.T./base.xml
2007-12-21 17:58:01.109 Loading from: /usr/local/share/mythtv/themes/default/base.xml
2007-12-21 17:58:01.178 Registering Internal as a media playback plugin.
2007-12-21 17:58:01.205 Unable to initialize plugin 'mythbookmarkmanager'.
2007-12-21 17:58:01.208 Unable to initialize plugin 'mythdvd'.
2007-12-21 17:58:01.291 MonitorRegisterExtensions(0x100, gif,jpg,png)
2007-12-21 17:58:01.443 MythMusic adding CD-Writer: 0,0,0 -- Maxtor 6Y120M0
2007-12-21 17:58:01.444 MythMusic adding CD-Writer: 2,0,0 -- CardReader CF RW
2007-12-21 17:58:03.016 Failed to run 'cdrecord --scanbus -dev=ATAPI'
2007-12-21 17:58:03.066 MonitorRegisterExtensions(0x40, ogg,mp3,aac,flac)
2007-12-21 17:58:03.202 Starting media monitor.
---

If I run Intel's UPnp device sniffer I get:

---
HTTP/1.1 200  OK
SERVER:  Linux 2.6.22-14-generic, UPnP/1.0, MythTv 0.21.20071211-1
ST:  urn:schemas-upnp-org:device:MediaRenderer:1
CACHE-CONTROL:  max-age=3600
EXT: 
USN:  uuid:0880d362-2950-49cd-99f6-ef4c04ee571b::urn:schemas-upnp-org:device:MediaRenderer:1
LOCATION:  http://10.5.5.1:6547/getDeviceDesc
DATE:  21 Dec 2007 18:02:10
Content-Length: 0
----
HTTP/1.1 200  OK
SERVER:  Linux 2.6.22-14-generic, UPnP/1.0, MythTv 0.21.20071211-1
ST:  urn:schemas-upnp-org:device:MediaRenderer:1
CACHE-CONTROL:  max-age=3600
EXT: 
USN:  uuid:0880d362-2950-49cd-99f6-ef4c04ee571b::urn:schemas-upnp-org:device:MediaRenderer:1
LOCATION:  http://192.168.1.106:6547/getDeviceDesc
DATE:  21 Dec 2007 18:02:10
Content-Length: 0
---

So upnp seems to be active though no upnp activity is logged?

comment:7 Changed 16 years ago by Nigel

Thanks for the extra debug. I think David just fixed the backend issue in [15220].
Your HTTPRequest::FormatFileReponse? debug looks useful. We should add something like that. Feel free to attach "svn diff libs/libmythupnp"
I don't quite understand what the problem is with the frontend. The output seems to indicate that UPnP isn't being used to locate a backend, so it will not show any UPnP output. The sniffer output (which I assume was from a different frontend run) seems to show multiple frontend requests (to the different backend addresses), but that shouldn't be a problem, because one of them will be responded to first. David may have to debug this further.

comment:8 Changed 16 years ago by Nigel

(In [15231]) UPnpCMGR::ProcessRequest?(CMGRM_GetServiceDescription) uses the filename which is set at object creation time, so this passes the share path in to the xtor. Should fix the current UPnP issue. See #4355. See #4317. See #2467.

Note 1) the frontend MediaRenderer? shouldn't need to share anything(?),

so its xtor gets an empty string.

Note 2) I suspect [15220] can be reverted,

but I will wait for David Blain to verify that

comment:9 Changed 16 years ago by Nigel

Owner: changed from dblain to Nigel
Status: newassigned

I still suspect [15220] can be reverted, but after Isaac's library non-circular-dep. re-org, it isn't as important.
The backend can still send unreachable IPs if BackendServerIP is non-routable on a given network, but given the possibility of a backend server being on multiple networks, this is difficult to fix. At the moment, the best we can hope to do is check if BackendServerIP is similar to any of the networks that match GetIPAddressList().
I should email Joran and ask how he (anonymous?) is doing it at the moment.

comment:10 Changed 15 years ago by stuartm

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.