diff options
author | Christopher R. Hertel <crh@samba.org> | 2000-07-09 02:10:24 +0000 |
---|---|---|
committer | Christopher R. Hertel <crh@samba.org> | 2000-07-09 02:10:24 +0000 |
commit | 119f965f494d881c69704a346443aeb4bfcbe3ef (patch) | |
tree | c1111afab8e259f16c50c1d2d2834d47a9ca1139 | |
parent | a3deb502e32a5b6fb1027e6fccb8de131f319dc5 (diff) | |
download | samba-119f965f494d881c69704a346443aeb4bfcbe3ef.tar.gz samba-119f965f494d881c69704a346443aeb4bfcbe3ef.tar.bz2 samba-119f965f494d881c69704a346443aeb4bfcbe3ef.zip |
Quick change to short-circuit WINS queries if the WINS server returns a
Negative Name Query Response. We should't wait through the timeouts and
retry twice if we've been told "No Such Entry".
(This used to be commit 2bbd16903db02aacb729d1ad140056b180e2a776)
-rw-r--r-- | source3/libsmb/namequery.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 8fb607bd8f..82c8c8f93d 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -271,7 +271,18 @@ struct in_addr *name_query(int fd,const char *name,int name_type, if ((p2=receive_nmb_packet(fd,90,nmb->header.name_trn_id))) { struct nmb_packet *nmb2 = &p2->packet.nmb; debug_nmb_packet(p2); - + + if( 0 == nmb2->header.opcode /* A query response */ + && !(bcast) /* from a WINS server */ + && 0x03 == nmb2->header.rcode /* Name doesn't exist */ + ) { + /* If we get a Negative Name Query Response from a WINS + * server, we should give up. + */ + free_packet(p2); + return( NULL ); + } + if (nmb2->header.opcode != 0 || nmb2->header.nm_flags.bcast || nmb2->header.rcode || @@ -499,13 +510,16 @@ static BOOL resolve_wins(const char *name, int name_type, wins_ip = *interpret_addr2(lp_wins_server()); wins_ismyip = ismyip(wins_ip); + DEBUG(3, ("resolve_wins: WINS server == <%s>\n", inet_ntoa(wins_ip)) ); if((wins_ismyip && !global_in_nmbd) || !wins_ismyip) { - sock = open_socket_in( SOCK_DGRAM, 0, 3, - interpret_addr(lp_socket_address()), True ); - + sock = open_socket_in( SOCK_DGRAM, 0, 3, + interpret_addr(lp_socket_address()), + True ); if (sock != -1) { - *return_iplist = name_query(sock, name, name_type, False, - True, wins_ip, return_count); + *return_iplist = name_query( sock, name, + name_type, False, + True, wins_ip, + return_count); if(*return_iplist != NULL) { close(sock); return True; |