[mythtv] Proposed change to Network Communications

Stephen Worthington stephen_agent at jsw.gen.nz
Wed Mar 8 14:06:55 UTC 2017

On Tue, 7 Mar 2017 16:00:48 -0500, you wrote:

>MythTV Developers
>I propose a change to the Host Address Backend setup.
>In the Local Backend section add a checkbox "Listen on all addresses". 
>This should be the default for a new system. If checked, it should force 
>"Listen on Link-Local addresses" to be checked.
>Under "Master Backend", add a checkbox "This Backend is Master". When 
>that is selected, the IP address text input will be a dropdown box with 
>the IPv4 address and IPv6 address above as options. When that is 
>unselected, the IP Address field is disabled from input.
>Listening on all addresses solves the problem of an interface that is 
>down when the backend starts up. New Interfaces automatically are 
>listened on when they are attached. I tested by plugging in a USB wifi 
>dongle after starting the backend, and it is able to receive 
>communications on that device.
>The only time I can imagine listening on all ip addresses is unwanted is 
>if you are running two backends on the same machine, with different ip 
>addresses for each. This seems an unusual situation but can be handled 
>by deselecting "Listen on all addresses".
>Providing the "This Backend is Master" and drop down list will help with 
>IPV6 addresses which are somewhat painful to manually type. Also it will 
>prevent a horrible situation where you supply one of the backend's 
>alternate IP addresses as the Master backend IP address and it starts up 
>as a slave then connects to itself as master backend, so it is a slave 
>to itself. I expect bad things would happen.
>Please let me know of any comments to this proposal.
>I have tried a quick change to make it listen on all addresses and a 
>cursory test appears to be fine that way.

There are some interesting complications from listening on all
addresses.  When you have a PC that has more than one network
interface, you normally do not want software to listen on all of those
network interfaces, as each interface will have a different purpose.
For example, it is now fairly common to have a guest VLAN where you
allow access for other people's devices to the Internet, but not to
the rest of the home network.  If that VLAN is run from the same PC as
MythTV is running on, then listening on all interfaces will
potentially make the MythTV backend available to devices on the guest
VLAN.  Another common use for a second Ethernet card is to run your
network tuners, so that they do not have to fight the normal traffic
to get their packets to the MythTV backend.  It is not desirable to
have the backend listening on that interface, although it probably
does not cause any real trouble as I think MythTV backends do not
normally cause much traffic without being triggered to do so by
something connecting to them.

Since a MythTV box is often the only Linux box on a home network, it
is often given extra jobs such as running a VLAN, because Linux can
easily do that sort of thing.  My MythTV box, for example, runs my
OpenVPN server.

It is not uncommon for a Linux box to be the main firewall gateway for
a home network, in which case it will have two Ethernet cards, one for
the WAN connection to the Internet and one for the home network LAN.
Having the backend listening on the WAN port is very undesirable, but
since such a box would normally have a firewall on the WAN port, it
might not be a problem as the firewall should block traffic to the
MythTV ports unless it has rules to do otherwise.

I am sure there are lots of other examples.  So while I think a listen
on all addresses option would be very useful, I am not so sure it
should be the default.

There are also other better ways to handle this startup problem, with
the gold standard for a server program being to use the rtnetlink


The program listens for changes via that interface and when it sees an
IP address or interface appear that it needs to bind, it does so at
that time and also handles unbinding when things go away.  Doing that
in mythbackend is clearly lots more work than a listen on all
addresses option though, and as developer time is a scarce resource,
it might be better to go with listen on all interfaces.  Another
(probably much simpler) option is to bind using the IP_FREEBIND


That allows binding when an address or interface is not up yet, and
the binding will become active only when the address or interface
becomes available (if ever).

Also, it may not actually be necessary to have a special listen on all
addresses option.  I was under the impression that if you used the
special address of, that would cause listening on all IPv4
interfaces, and using :: would cause listening on all IPv4 and IPv6
interfaces.  That seems to be how it works in MySQL.  It probably
depends on how Qt handles that sort of thing though - I know little
about Qt.

More information about the mythtv-dev mailing list