[netdata] add version number to DNS/SRP service entries (#10752)

This commit adds a version field (`uint8_t`) to DNS/SRP Anycast and
Unicast Service entries in `NetworkData::Service::Manager`.

For Unicast entries, the version the version field is placed after
the existing fields, specifically after the IPv6 address and port number fields.
For Anycast entries it is added as the in server data as part of the
Server TLV.

When processing Network Data service entries, the version field is
optional and if absent, version number zero is assumed.

The `NetworkData::Publisher` now considers entries with the same or
higher version number when deciding whether to add or remove its own
entry, preferring those with a higher version.

In SRP client, when `AutoStart` mode is used and if there are multiple
Unicast, Service entries, the client prefers the one with larger
version number.

When selecting an anycast entry, the existing rules regarding sequence
numbers are still used. If multiple entries with the same sequence
number exist, the client will assume the minimum version number among
all such entries.

This commit also updates the `test_network_data` unit test, validating
the new format and related methods.

`test_netdata_publisher.py` is also updated to check service entries
with different version numbers.
This commit is contained in:
Abtin Keshavarzian
2024-12-23 18:59:06 -08:00
committed by GitHub
parent 588e93cd15
commit 4c378f798d
16 changed files with 611 additions and 241 deletions
+6 -6
View File
@@ -2515,16 +2515,16 @@ class NodeImpl:
self.send_command('netdata register')
self._expect_done()
def netdata_publish_dnssrp_anycast(self, seqnum):
self.send_command(f'netdata publish dnssrp anycast {seqnum}')
def netdata_publish_dnssrp_anycast(self, seqnum, version=0):
self.send_command(f'netdata publish dnssrp anycast {seqnum} {version}')
self._expect_done()
def netdata_publish_dnssrp_unicast(self, address, port):
self.send_command(f'netdata publish dnssrp unicast {address} {port}')
def netdata_publish_dnssrp_unicast(self, address, port, version=0):
self.send_command(f'netdata publish dnssrp unicast {address} {port} {version}')
self._expect_done()
def netdata_publish_dnssrp_unicast_mleid(self, port):
self.send_command(f'netdata publish dnssrp unicast {port}')
def netdata_publish_dnssrp_unicast_mleid(self, port, version=0):
self.send_command(f'netdata publish dnssrp unicast {port} {version}')
self._expect_done()
def netdata_unpublish_dnssrp(self):