|
|
e7e33b |
From b9560cc74c99e96f97490608b292f23735252aaf Mon Sep 17 00:00:00 2001
|
|
|
e7e33b |
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
|
|
e7e33b |
Date: Wed, 14 Sep 2016 22:31:56 +0200
|
|
|
e7e33b |
Subject: [PATCH] High: zealous local address matching with the same subnet
|
|
|
e7e33b |
entries
|
|
|
e7e33b |
|
|
|
e7e33b |
Previously, having booth components on the same subnet could seriously
|
|
|
e7e33b |
confuse self-determination of those tolerating fuzziness when doing so
|
|
|
e7e33b |
(i.e., not site nor arbitrator).
|
|
|
e7e33b |
|
|
|
e7e33b |
It would be the case when there are two (or more) addresses sharing the
|
|
|
e7e33b |
same network part of the address as one of the actual hosts's addresses
|
|
|
e7e33b |
(assigned to one of its interfaces), and the exactly matching one is
|
|
|
e7e33b |
listed _after_ at least a single network-part-match-only one ("fuzzy"
|
|
|
e7e33b |
match). Due to the original requirement that any subsequent candidate
|
|
|
e7e33b |
would have to beat a running winner in the length of the network prefix,
|
|
|
e7e33b |
such exact match could never have been tested and hence missed.
|
|
|
e7e33b |
(IOW, algorithm used to search for local, not global maximum in some
|
|
|
e7e33b |
circumstances).
|
|
|
e7e33b |
|
|
|
e7e33b |
Now we allow further examination of the candidate with the same length
|
|
|
e7e33b |
of the network prefix as a running winner, which -- moreover -- cannot
|
|
|
e7e33b |
be the exact match because now, it terminates the search immediately.
|
|
|
e7e33b |
---
|
|
|
e7e33b |
src/transport.c | 22 ++++++++++++++--------
|
|
|
e7e33b |
1 file changed, 14 insertions(+), 8 deletions(-)
|
|
|
e7e33b |
|
|
|
e7e33b |
diff --git a/src/transport.c b/src/transport.c
|
|
|
e7e33b |
index b3e4432..1d620a0 100644
|
|
|
e7e33b |
--- a/src/transport.c
|
|
|
e7e33b |
+++ b/src/transport.c
|
|
|
e7e33b |
@@ -237,15 +237,21 @@ int _find_myself(int family, struct booth_site **mep, int fuzzy_allowed)
|
|
|
e7e33b |
BOOTH_IPADDR_LEN);
|
|
|
e7e33b |
}
|
|
|
e7e33b |
|
|
|
e7e33b |
- /* First try with exact addresses, then optionally with subnet matching. */
|
|
|
e7e33b |
- if (ifa->ifa_prefixlen > address_bits_matched) {
|
|
|
e7e33b |
- find_address(ipaddr,
|
|
|
e7e33b |
- ifa->ifa_family, ifa->ifa_prefixlen,
|
|
|
e7e33b |
- fuzzy_allowed, &me, &address_bits_matched);
|
|
|
e7e33b |
- if (me) {
|
|
|
e7e33b |
- log_debug("found myself at %s (%d bits matched)",
|
|
|
e7e33b |
- site_string(me), address_bits_matched);
|
|
|
e7e33b |
+ if (ifa->ifa_prefixlen >= address_bits_matched) {
|
|
|
e7e33b |
+ /* First attempt exact match with addresses in the config,
|
|
|
e7e33b |
+ then optionally with subnet matching. */
|
|
|
e7e33b |
+ if (find_address(ipaddr,
|
|
|
e7e33b |
+ ifa->ifa_family, ifa->ifa_prefixlen,
|
|
|
e7e33b |
+ fuzzy_allowed, &me, &address_bits_matched)
|
|
|
e7e33b |
+ == EXACT_MATCH) {
|
|
|
e7e33b |
+ log_debug("found exactly myself at %s (%d bits matched)",
|
|
|
e7e33b |
+ site_string(me), address_bits_matched);
|
|
|
e7e33b |
+ break;
|
|
|
e7e33b |
}
|
|
|
e7e33b |
+ if (me)
|
|
|
e7e33b |
+ log_debug("running winner to determine myself at %s"
|
|
|
e7e33b |
+ " (%d bits matched)",
|
|
|
e7e33b |
+ site_string(me), address_bits_matched);
|
|
|
e7e33b |
}
|
|
|
e7e33b |
}
|
|
|
e7e33b |
h = NLMSG_NEXT(h, status);
|
|
|
e7e33b |
--
|
|
|
e7e33b |
2.4.11
|
|
|
e7e33b |
|