Blame SOURCES/bz1341720-zealous-local-address-matching.patch

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