diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-06-30 01:26:52 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:18:57 -0500 |
commit | c58c7c416412fd2ae90427f500b2d94996c36c48 (patch) | |
tree | 504136e98bf0749c562b8ac0104f663a9d9d0def /source4/libcli | |
parent | ddffc922dfdc2572dc622d5fdb89095d356a83e9 (diff) | |
download | samba-c58c7c416412fd2ae90427f500b2d94996c36c48.tar.gz samba-c58c7c416412fd2ae90427f500b2d94996c36c48.tar.bz2 samba-c58c7c416412fd2ae90427f500b2d94996c36c48.zip |
r8002: favor addresses on our local interfaces in NBT name resolution if
possible. This is needed because w2k3 will return bogus IPs in its
name resolution replies when it has an unplugged network interface.
(This used to be commit 2fafc230520fb5bbe9f763de94aaba87b56f5411)
Diffstat (limited to 'source4/libcli')
-rw-r--r-- | source4/libcli/resolve/nbtlist.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c index d5b01e06d9..0026c6fceb 100644 --- a/source4/libcli/resolve/nbtlist.c +++ b/source4/libcli/resolve/nbtlist.c @@ -66,8 +66,21 @@ static void nbtlist_handler(struct nbt_name_request *req) c->state = SMBCLI_REQUEST_ERROR; c->status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; } else { + struct nbt_name_query *q = &state->io_queries[i]; c->state = SMBCLI_REQUEST_DONE; - state->reply_addr = talloc_steal(state, state->io_queries[i].out.reply_addrs[0]); + /* favor a local address if possible */ + state->reply_addr = NULL; + for (i=0;i<q->out.num_addrs;i++) { + if (iface_is_local(q->out.reply_addrs[i])) { + state->reply_addr = talloc_steal(state, + q->out.reply_addrs[i]); + break; + } + } + if (state->reply_addr == NULL) { + state->reply_addr = talloc_steal(state, + q->out.reply_addrs[0]); + } } } |