Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
openslp
openslp.unicastactivediscovery.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File openslp.unicastactivediscovery.diff of Package openslp
--- ./common/slp_property.c.orig 2020-04-14 15:08:20.348451688 +0000 +++ ./common/slp_property.c 2020-04-14 15:08:54.924372499 +0000 @@ -183,6 +183,8 @@ static int SetDefaultValues(void) {"net.slp.DABackupLocalReg", "false", 0}, {"net.slp.hardMTU", "false", 0}, + + {"net.slp.DAUnicastActiveDiscoveryInterval", "300", 0}, }; int i; --- ./etc/slp.conf.orig 2020-04-14 15:09:32.316286853 +0000 +++ ./etc/slp.conf 2020-04-15 10:26:03.099174216 +0000 @@ -203,6 +203,13 @@ # scope discovery. (Default setting is true). ;net.slp.useDHCP = true +# A 32 bit integer giving the time to wait until an unicast active discovery +# request is retried, being because the DA was not reachable on startup +# or the DA was declared dead. Unicast active discovery requests are made +# to DAs configured via net.slp.DAAddresses or via DHCP. Use a value of +# zero to disable this feature. (Default is 300) +;net.slp.DAUnicastActiveDiscoveryInterval = 300 + #---------------------------------------------------------------------------- # Security #---------------------------------------------------------------------------- --- ./slpd/slpd_knownda.c.orig 2020-04-14 13:39:45.596618043 +0000 +++ ./slpd/slpd_knownda.c 2020-04-15 10:22:56.867595994 +0000 @@ -82,6 +82,16 @@ size_t G_ifaceurlsLen = 0; /* Used to filter out our own DA urls */ /*=========================================================================*/ +typedef struct _KnownDAUnicastActiveDiscoveryEntry +{ + struct _KnownDAUnicastActiveDiscoveryEntry *next; /* next entry in the list */ + struct sockaddr_storage peeraddr; /* DA address */ + time_t age; /* retry logic */ +} KnownDAUnicastActiveDiscoveryEntry; + +KnownDAUnicastActiveDiscoveryEntry *G_UnicastActiveDiscoveryList; + + /*-------------------------------------------------------------------------*/ int MakeActiveDiscoveryRqst(int ismcast, SLPBuffer * buffer) /* Pack a buffer with service:directory-agent SrvRqst * @@ -228,6 +238,95 @@ FINISHED: } +static void SLPDKnownDAAddUnicastActiveDiscovery(struct sockaddr_storage *peeraddr) +{ + KnownDAUnicastActiveDiscoveryEntry *entry; + + for (entry = G_UnicastActiveDiscoveryList; entry; entry = entry->next) + if (SLPNetCompareAddrs(peeraddr, &entry->peeraddr) == 0) + return; + entry = xmalloc(sizeof(*entry)); + if (entry) + { + entry->next = G_UnicastActiveDiscoveryList; + entry->peeraddr = *peeraddr; + entry->age = -1; + G_UnicastActiveDiscoveryList = entry; + } +} + + +/*-------------------------------------------------------------------------*/ +static void MakeUnicastActiveDiscovery(struct sockaddr_storage *daaddr) +/* Get an outgoing socket to the DA and set it up to make */ +/* the service:directoryagent request */ +/*-------------------------------------------------------------------------*/ +{ + SLPDSocket * sock; + + SLPDKnownDAAddUnicastActiveDiscovery(daaddr); + sock = SLPDOutgoingConnect(1, daaddr); + if (sock) + { + SLPBuffer buf = 0; + if (MakeActiveDiscoveryRqst(0, &buf) == 0) + { + SLPListLinkTail(&(sock->sendlist), (SLPListItem *) buf); + if (sock->state == STREAM_CONNECT_IDLE) + sock->state = STREAM_WRITE_FIRST; + } + } +} + + +void SLPDKnownDARestartUnicastActiveDiscovery(struct sockaddr_storage *peeraddr) +{ + KnownDAUnicastActiveDiscoveryEntry *entry; + + for (entry = G_UnicastActiveDiscoveryList; entry; entry = entry->next) + if (SLPNetCompareAddrs(peeraddr, &entry->peeraddr) == 0) + { + entry->age = 0; + break; + } +} + + +static void SLPDKnownDAFreeUnicastActiveDiscoveryList() +{ + KnownDAUnicastActiveDiscoveryEntry *entry; + + while ((entry = G_UnicastActiveDiscoveryList) != 0) + { + G_UnicastActiveDiscoveryList = entry->next; + xfree(entry); + } +} + + +void SLPDKnownDAUnicastActiveDiscoveryAge(time_t seconds) +{ + KnownDAUnicastActiveDiscoveryEntry *entry; + + if (!G_SlpdProperty.DAUnicastActiveDiscoveryInterval) + return; + for (entry = G_UnicastActiveDiscoveryList; entry; entry = entry->next) + { + if (entry->age == -1) + continue; + entry->age += seconds; + if (entry->age > G_SlpdProperty.DAUnicastActiveDiscoveryInterval) + { + char addr_str[INET6_ADDRSTRLEN]; + SLPDLog("SLPD: retrying unicast active discovery for %s\n", + SLPNetSockAddrStorageToString(&entry->peeraddr, addr_str, sizeof(addr_str))); + entry->age = -1; + MakeUnicastActiveDiscovery(&entry->peeraddr); + } + } +} + + /*-------------------------------------------------------------------------*/ void SLPDKnownDARegisterAll(SLPMessage * daadvert, int immortalonly) /* registers all services with specified DA */ @@ -477,7 +576,6 @@ int SLPDKnownDAFromDHCP() /* returns zero on success, Non-zero on failure */ /*=========================================================================*/ { - SLPBuffer buf; DHCPContext ctx; SLPDSocket * sock; struct sockaddr_storage daaddr; @@ -499,23 +597,7 @@ int SLPDKnownDAFromDHCP() daaddr.ss_family = AF_INET; memcpy(&(((struct sockaddr_in *) &daaddr)->sin_addr.s_addr), alp, 4); if (&(((struct sockaddr_in *) &daaddr)->sin_addr.s_addr)) - { - /*-------------------------------------------------------- - Get an outgoing socket to the DA and set it up to make - the service:directoryagent request - --------------------------------------------------------*/ - sock = SLPDOutgoingConnect(1, &daaddr); - if (sock) - { - buf = 0; - if (MakeActiveDiscoveryRqst(0, &buf) == 0) - { - SLPListLinkTail(&(sock->sendlist), (SLPListItem *) buf); - if (sock->state == STREAM_CONNECT_IDLE) - sock->state = STREAM_WRITE_FIRST; - } - } - } + MakeUnicastActiveDiscovery(&daaddr); ctx.addrlistlen -= 4; alp += 4; } @@ -538,7 +620,6 @@ int SLPKnownDAFromProperties() struct sockaddr_storage daaddr; int daaddr_isset; SLPDSocket * sock; - SLPBuffer buf; if (G_SlpdProperty.DAAddresses && *G_SlpdProperty.DAAddresses) { @@ -599,23 +680,7 @@ int SLPKnownDAFromProperties() } if (daaddr_isset) - { - /*--------------------------------------------------------*/ - /* Get an outgoing socket to the DA and set it up to make */ - /* the service:directoryagent request */ - /*--------------------------------------------------------*/ - sock = SLPDOutgoingConnect(1, &daaddr); - if (sock) - { - buf = 0; - if (MakeActiveDiscoveryRqst(0, &buf) == 0) - { - SLPListLinkTail(&(sock->sendlist), (SLPListItem *) buf); - if (sock->state == STREAM_CONNECT_IDLE) - sock->state = STREAM_WRITE_FIRST; - } - } - } + MakeUnicastActiveDiscovery(&daaddr); slider1 = slider2; } xfree(temp); @@ -737,6 +802,7 @@ int SLPDKnownDADeinit() } SLPDatabaseDeinit(&G_SlpdKnownDAs); + SLPDKnownDAFreeUnicastActiveDiscoveryList(); if(G_ifaceurls) xfree(G_ifaceurls); @@ -1628,8 +1694,10 @@ void SLPDKnownDAStaleDACheck(int seconds if (!entry->entryvalue) { /* No DAAdvert received for this DA within the check period */ + struct sockaddr_storage peeraddr = entry->msg->peer; SLPDLogDAAdvertisement("Removed - stale", entry); SLPDatabaseRemove(dh, entry); + SLPDKnownDARestartUnicastActiveDiscovery(&peeraddr); } else entry->entryvalue--; /* Decrement the "time to stale" count */ --- ./slpd/slpd_knownda.h.orig 2020-04-14 14:58:00.329868579 +0000 +++ ./slpd/slpd_knownda.h 2020-04-14 14:58:34.837789901 +0000 @@ -76,6 +76,9 @@ void SLPDKnownDAImmortalRefresh(int seco void SLPDKnownDADeRegisterWithAllDas(SLPMessage * msg, SLPBuffer buf); void SLPDKnownDARegisterWithAllDas(SLPMessage * msg, SLPBuffer buf); +void SLPDKnownDARestartUnicastActiveDiscovery(struct sockaddr_storage *peeraddr); +void SLPDKnownDAUnicastActiveDiscoveryAge(time_t seconds); + #ifdef DEBUG void SLPDKnownDADump(void); #endif --- ./slpd/slpd_main.c.orig 2020-04-14 14:58:52.665749252 +0000 +++ ./slpd/slpd_main.c 2020-04-14 15:02:58.197189452 +0000 @@ -355,6 +355,7 @@ void HandleSigAlrm(void) SLPDKnownDAPassiveDAAdvert(SLPD_AGE_INTERVAL, 0); SLPDKnownDAStaleDACheck(SLPD_AGE_INTERVAL); SLPDKnownDAActiveDiscovery(SLPD_AGE_INTERVAL); + SLPDKnownDAUnicastActiveDiscoveryAge(SLPD_AGE_INTERVAL); SLPDDatabaseAge(SLPD_AGE_INTERVAL, G_SlpdProperty.isDA); SLPDDatabaseWatcher(); } --- ./slpd/slpd_outgoing.c.orig 2020-04-14 13:39:55.208595992 +0000 +++ ./slpd/slpd_outgoing.c 2020-04-14 14:57:12.217978274 +0000 @@ -129,6 +129,7 @@ void OutgoingStreamReconnect(SLPList * s /*Since we can't connect, remove it as a DA*/ SLPDKnownDARemove(&(sock->peeraddr)); + SLPDKnownDARestartUnicastActiveDiscovery(&(sock->peeraddr)); sock->state = SOCKET_CLOSE; return; } @@ -632,6 +633,7 @@ void SLPDOutgoingRetry(time_t seconds) SLPNetSockAddrStorageToString(&sock->peeraddr, addr_str, sizeof(addr_str))); SLPDKnownDARemove(&(sock->peeraddr)); + SLPDKnownDARestartUnicastActiveDiscovery(&(sock->peeraddr)); del = sock; } else @@ -711,6 +713,7 @@ void SLPDOutgoingAge(time_t seconds) { /* Remove peer from KnownDAs since it might be dead */ SLPDKnownDARemove(&(sock->peeraddr)); + SLPDKnownDARestartUnicastActiveDiscovery(&(sock->peeraddr)); del = sock; } } @@ -720,6 +723,7 @@ void SLPDOutgoingAge(time_t seconds) { /* Remove peer from KnownDAs since it might be dead */ SLPDKnownDARemove(&(sock->peeraddr)); + SLPDKnownDARestartUnicastActiveDiscovery(&(sock->peeraddr)); del = sock; } } --- ./slpd/slpd_property.c.orig 2020-04-14 15:06:35.220692470 +0000 +++ ./slpd/slpd_property.c 2020-04-14 15:07:54.204511568 +0000 @@ -256,6 +256,8 @@ void SLPDPropertyReinit(void) G_SlpdProperty.isDABackup = SLPPropertyAsBoolean("net.slp.isDABackup"); G_SlpdProperty.DABackupInterval = SLPPropertyAsInteger("net.slp.DABackupInterval"); G_SlpdProperty.DABackupLocalReg = SLPPropertyAsBoolean("net.slp.DABackupLocalReg"); + + G_SlpdProperty.DAUnicastActiveDiscoveryInterval = SLPPropertyAsInteger("net.slp.DAUnicastActiveDiscoveryInterval"); } /** Initialize the slpd property management subsystem. --- ./slpd/slpd_property.h.orig 2020-04-14 15:06:27.804709463 +0000 +++ ./slpd/slpd_property.h 2020-04-14 15:07:58.988500609 +0000 @@ -124,6 +124,8 @@ typedef struct _SLPDProperty int isDABackup; int DABackupInterval; int DABackupLocalReg; + + int DAUnicastActiveDiscoveryInterval; } SLPDProperty; extern SLPDProperty G_SlpdProperty;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor