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