Thread: [Openslp-devel] [PATCH] semi-automatically refresh listening interfaces
Brought to you by:
jcalcote
From: Gavin L. <ga...@co...> - 2012-10-04 23:58:29
Attachments:
openslp-hup.patch
|
I had a case recently where a particular WinXP PC would almost always start up the OpenSLPd service prior to bringing up the network interface (presumably due to a slow DHCP server or something), which of course meant that SLP queries on that network were not answered, since SLPD currently only checks the interface list on startup. So I fixed that. The attached patch (against the OpenSLP 2.0 beta 2 release tarball) makes the following changes to SLPD: * on the Linux side, sending SIGHUP to SLPD will result in it closing and reopening the listening sockets (thereby adding or removing supported interfaces as required), in addition to prior behaviour (reinitialising the settings files and DA list). Current outgoing connections and dynamic registrations are unaffected, but there will be a brief period when the server is unresponsive to new incoming queries from the network. * on the Windows side, it will interpret the SERVICE_CONTROL_PARAMCHANGE command as an equivalent SIGHUP request. (This provides a way to update the config files semi-live, as on Linux.) * on the Windows side, it will also automatically ask Windows to notify it of a change in the IP address table, and also treat that as a SIGHUP. * minor code tidy-ups and status reporting fixes. Caveats: * this patch has only been tested on Windows (XP and 7); the changes affecting the Linux side should be harmless (and beneficial) but I have not verified that. * automatic detection of IPv6 address changes only works on Vista+, but that should be ok as IPv6 generally doesn't work on XP anyway. * IPv6 detection has not been tested (all the networks I have access to use only IPv4), but since the code is the same as for IPv4 it should work fine. * the SIGHUP code may get triggered several times by one logical change (presumably due to multiple internal changes); for example when a disabled network interface is re-enabled it tends to run twice on XP and 3-4 times on Win7 (note that different notification APIs are used on each). While inefficient this does not appear harmful, so I'm leaving it as is. The reinits are throttled by the main loop timeout, currently 1s. * the Linux side will not automatically detect IP address changes; code or hook scripts to do the autodetection on Linux are left as an exercise for some other intrepid soul. * this is my first foray into the OpenSLP codebase, so I may have missed updating something necessary, or done something inefficiently -- but it seems to be working ok so far. I'm sure things could be improved though (such as reinitialising only the listening sockets, not accepted sockets). |
From: Gavin L. <ga...@co...> - 2012-10-26 03:32:10
Attachments:
openslp-hup2.patch
|
I've attached a variation of the previous patch (still against the 2.0 beta 2 tarball) which handles the reinit slightly differently from the original. This one will start listening on any newly discovered (or configured) interfaces, without closing or stopping any previously opened incoming sockets. The advantage over the previous patch is that it will cause less disruption to ongoing communications, particularly if only a secondary interface is changing. The disadvantage is that if the service is left running for a long time on a network that keeps assigning it different addresses (presumably via a DHCP server with a bad memory) then it will gradually eat up more and more resources, and probably eventually fail. (I'm not sure which tradeoff is better overall.) A suggested improvement (which again I'm not quite familiar enough with the code to do at this point) would be to track which sockets are associated with a particular interface and close them if their interface is not still present during the reinit. Note that for code simplicity it's currently assuming that if the TCP listen socket exists then all the other related sockets are still ok too. |
From: John C. <joh...@gm...> - 2012-11-28 19:49:46
|
Hi Gavin, Your dynamic ifc reinit patch has been incorporated into the repository. Thanks for your efforts. Regards, John > -----Original Message----- > From: Gavin Lambert [mailto:ga...@co...] > Sent: Thursday, October 25, 2012 9:32 PM > To: ope...@li... > Subject: [Openslp-devel] [PATCHv2] semi-automatically refresh listening > interfaces > > I've attached a variation of the previous patch (still against the 2.0 beta > 2 tarball) which handles the reinit slightly differently from the original. > > This one will start listening on any newly discovered (or configured) > interfaces, without closing or stopping any previously opened incoming > sockets. > > The advantage over the previous patch is that it will cause less disruption to > ongoing communications, particularly if only a secondary interface is > changing. The disadvantage is that if the service is left running for a long time > on a network that keeps assigning it different addresses (presumably via a > DHCP server with a bad memory) then it will gradually eat up more and more > resources, and probably eventually fail. (I'm not sure which tradeoff is better > overall.) > > A suggested improvement (which again I'm not quite familiar enough with > the code to do at this point) would be to track which sockets are associated > with a particular interface and close them if their interface is not still present > during the reinit. > > Note that for code simplicity it's currently assuming that if the TCP listen > socket exists then all the other related sockets are still ok too. |
From: Gavin L. <ga...@co...> - 2013-03-01 02:17:04
|
Hi John, Just noticed a minor bug (sorry, it was in my original patch): In slpd/slp_win32.c line 135 (InterfaceMonitorInit): - if (!(self->pNotifyIpInterfaceChange && self->pNotifyIpInterfaceChange)) + if (!(self->pNotifyIpInterfaceChange && self->pCancelMibChangeNotify2)) It won't actually cause any problems in practice, as one of these won't exist without the other. But this is more correct. Also the comment at line 146 (regarding casting) can be removed; this was from an older version of the code, which was solved differently in the final patch (see line 77). Regards, Gavin > -----Original Message----- > From: John Calcote [mailto:joh...@gm...] > Sent: Thursday, 29 November 2012 08:50 > To: 'Gavin Lambert'; ope...@li... > Subject: RE: [Openslp-devel] [PATCHv2] semi-automatically refresh > listening interfaces > > Hi Gavin, > > Your dynamic ifc reinit patch has been incorporated into the repository. > Thanks for your efforts. > > Regards, > John > > > -----Original Message----- > > From: Gavin Lambert [mailto:ga...@co...] > > Sent: Thursday, October 25, 2012 9:32 PM > > To: ope...@li... > > Subject: [Openslp-devel] [PATCHv2] semi-automatically refresh > > listening interfaces > > > > I've attached a variation of the previous patch (still against the 2.0 > beta > > 2 tarball) which handles the reinit slightly differently from the > original. > > > > This one will start listening on any newly discovered (or configured) > > interfaces, without closing or stopping any previously opened incoming > > sockets. > > > > The advantage over the previous patch is that it will cause less > disruption to > > ongoing communications, particularly if only a secondary interface is > > changing. The disadvantage is that if the service is left running for > > a > long time > > on a network that keeps assigning it different addresses (presumably > > via a DHCP server with a bad memory) then it will gradually eat up > > more and more resources, and probably eventually fail. (I'm not sure > > which tradeoff is > better > > overall.) > > > > A suggested improvement (which again I'm not quite familiar enough > > with the code to do at this point) would be to track which sockets are > associated > > with a particular interface and close them if their interface is not > > still > present > > during the reinit. > > > > Note that for code simplicity it's currently assuming that if the TCP > listen > > socket exists then all the other related sockets are still ok too. |
From: John C. <joh...@gm...> - 2013-03-01 02:35:14
|
Thanks Gavin. changeset: 1766:cdaeb8be5165 tag: tip user: John Calcote <joh...@gm...> date: Thu Feb 28 18:59:10 2013 -0700 summary: glambert: Fix to win32 interface change notify code. John > -----Original Message----- > From: Gavin Lambert [mailto:ga...@co...] > Sent: Thursday, February 28, 2013 6:40 PM > To: 'John Calcote' > Cc: ope...@li... > Subject: RE: [Openslp-devel] [PATCHv2] semi-automatically refresh listening > interfaces > > Hi John, > > Just noticed a minor bug (sorry, it was in my original patch): > > In slpd/slp_win32.c line 135 (InterfaceMonitorInit): > > - if (!(self->pNotifyIpInterfaceChange && > self->pNotifyIpInterfaceChange)) > + if (!(self->pNotifyIpInterfaceChange && > self->pCancelMibChangeNotify2)) > > It won't actually cause any problems in practice, as one of these won't exist > without the other. But this is more correct. > > Also the comment at line 146 (regarding casting) can be removed; this was > from an older version of the code, which was solved differently in the final > patch (see line 77). > > Regards, > Gavin > > > -----Original Message----- > > From: John Calcote [mailto:joh...@gm...] > > Sent: Thursday, 29 November 2012 08:50 > > To: 'Gavin Lambert'; ope...@li... > > Subject: RE: [Openslp-devel] [PATCHv2] semi-automatically refresh > > listening interfaces > > > > Hi Gavin, > > > > Your dynamic ifc reinit patch has been incorporated into the repository. > > Thanks for your efforts. > > > > Regards, > > John > > > > > -----Original Message----- > > > From: Gavin Lambert [mailto:ga...@co...] > > > Sent: Thursday, October 25, 2012 9:32 PM > > > To: ope...@li... > > > Subject: [Openslp-devel] [PATCHv2] semi-automatically refresh > > > listening interfaces > > > > > > I've attached a variation of the previous patch (still against the > > > 2.0 > > beta > > > 2 tarball) which handles the reinit slightly differently from the > > original. > > > > > > This one will start listening on any newly discovered (or > > > configured) interfaces, without closing or stopping any previously > > > opened incoming sockets. > > > > > > The advantage over the previous patch is that it will cause less > > disruption to > > > ongoing communications, particularly if only a secondary interface > > > is changing. The disadvantage is that if the service is left > > > running for a > > long time > > > on a network that keeps assigning it different addresses (presumably > > > via a DHCP server with a bad memory) then it will gradually eat up > > > more and more resources, and probably eventually fail. (I'm not > > > sure which tradeoff is > > better > > > overall.) > > > > > > A suggested improvement (which again I'm not quite familiar enough > > > with the code to do at this point) would be to track which sockets > > > are > > associated > > > with a particular interface and close them if their interface is not > > > still > > present > > > during the reinit. > > > > > > Note that for code simplicity it's currently assuming that if the > > > TCP > > listen > > > socket exists then all the other related sockets are still ok too. > |