summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-07-01 05:39:32 +0000
committerAndrew Tridgell <tridge@samba.org>2002-07-01 05:39:32 +0000
commit3563257247c9444f1b1489fb9f4faba3dc50959e (patch)
tree2c5e7507866e1afc7a79aeef7219a04954e97e55
parent2e917ea040d85f06b8e40b6fd178c08ee84797c9 (diff)
downloadsamba-3563257247c9444f1b1489fb9f4faba3dc50959e.tar.gz
samba-3563257247c9444f1b1489fb9f4faba3dc50959e.tar.bz2
samba-3563257247c9444f1b1489fb9f4faba3dc50959e.zip
bias the lookup sorting towards directly reachable IPs
(This used to be commit 514b91827a970a0041314af341b8c66a01668e4a)
-rw-r--r--source3/lib/interface.c8
-rw-r--r--source3/libsmb/namequery.c8
2 files changed, 16 insertions, 0 deletions
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index 85c49789c4..2704397fb2 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -355,3 +355,11 @@ struct in_addr *iface_ip(struct in_addr ip)
struct interface *i = iface_find(ip, True);
return(i ? &i->ip : &local_interfaces->ip);
}
+
+/*
+ return True if a IP is directly reachable on one of our interfaces
+*/
+BOOL iface_local(struct in_addr ip)
+{
+ return iface_find(ip, True) ? True : False;
+}
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 242601d1da..2bf72fbaac 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -317,6 +317,14 @@ static int ip_compare(struct in_addr *ip1, struct in_addr *ip2)
max_bits1 = MAX(bits1, max_bits1);
max_bits2 = MAX(bits2, max_bits2);
}
+
+ /* bias towards directly reachable IPs */
+ if (iface_local(*ip1)) {
+ max_bits1 += 32;
+ }
+ if (iface_local(*ip2)) {
+ max_bits2 += 32;
+ }
return max_bits2 - max_bits1;
}