]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixes a bug in primary IP selection.
authorOndrej Zajicek <santiago@crfreenet.org>
Wed, 29 Aug 2012 10:42:49 +0000 (12:42 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Wed, 29 Aug 2012 10:42:49 +0000 (12:42 +0200)
sysdep/unix/krt.c

index 2bd1bc446c6276dbcf354a47cfbac079cc8579bd..2128e1363b63b17b1c9ac6fcce44880b95ab36e1 100644 (file)
@@ -113,13 +113,19 @@ kif_request_scan(void)
     tm_start(kif_scan_timer, 1);
 }
 
-static inline int
-prefer_scope(struct ifa *a, struct ifa *b)
-{ return (a->scope > SCOPE_LINK) && (b->scope <= SCOPE_LINK); }
-
 static inline int
 prefer_addr(struct ifa *a, struct ifa *b)
-{ return ipa_compare(a->ip, b->ip) < 0; }
+{ 
+  int sa = a->scope > SCOPE_LINK;
+  int sb = b->scope > SCOPE_LINK;
+
+  if (sa < sb)
+    return 0;
+  else if (sa > sb)
+    return 1;
+  else
+    return ipa_compare(a->ip, b->ip) < 0;
+}
 
 static inline struct ifa *
 find_preferred_ifa(struct iface *i, ip_addr prefix, ip_addr mask)
@@ -130,7 +136,7 @@ find_preferred_ifa(struct iface *i, ip_addr prefix, ip_addr mask)
     {
       if (!(a->flags & IA_SECONDARY) &&
          ipa_equal(ipa_and(a->ip, mask), prefix) &&
-         (!b || prefer_scope(a, b) || prefer_addr(a, b)))
+         (!b || prefer_addr(a, b)))
        b = a;
     }