summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1997-10-15 09:15:45 +0000
committerAndrew Tridgell <tridge@samba.org>1997-10-15 09:15:45 +0000
commit9d3cce7c68723954bf3e97ba5681aa60c31eb835 (patch)
treeb6065399782987c9eb241e00dabc71b074a65e8b
parentbe73ce8321d5714fcd74f71ed9f6532ca4e1090b (diff)
downloadsamba-9d3cce7c68723954bf3e97ba5681aa60c31eb835.tar.gz
samba-9d3cce7c68723954bf3e97ba5681aa60c31eb835.tar.bz2
samba-9d3cce7c68723954bf3e97ba5681aa60c31eb835.zip
fixed the freeze on logout bug. The fix has several parts:
1) add a new parameter to queue_netbios_packet(), the "reply_id", this is the id that should be used when sending a further response to the packet (such as a response after we get back a reply to a name query after senidnga WACK). reply_id is 0 (meaning unused) in most cases. 2) fix the id used in the reply in add_name_respond() from response_name_query_register() 3) remember to remove the response record at the end of response_name_query_register() 4) get the right IP address (it was 0.0.0.0) in response_name_query_register() 5) add a new field reply_id to struct response_record (This used to be commit e1e86c1a160c8302004ea58e4f0f5874dd179dae)
-rw-r--r--source3/include/nameserv.h1
-rw-r--r--source3/nameannounce.c2
-rw-r--r--source3/namebrowse.c2
-rw-r--r--source3/namedbresp.c4
-rw-r--r--source3/nameelect.c2
-rw-r--r--source3/namepacket.c13
-rw-r--r--source3/nameresp.c10
-rw-r--r--source3/nameserv.c9
-rw-r--r--source3/nameservreply.c8
-rw-r--r--source3/nameservresp.c10
-rw-r--r--source3/namework.c3
11 files changed, 40 insertions, 24 deletions
diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h
index 593c101d92..81487e9ce9 100644
--- a/source3/include/nameserv.h
+++ b/source3/include/nameserv.h
@@ -247,6 +247,7 @@ struct response_record
BOOL recurse;
struct in_addr send_ip;
struct in_addr reply_to_ip;
+ int reply_id;
int num_msgs;
diff --git a/source3/nameannounce.c b/source3/nameannounce.c
index d3344ebd47..d69ee32ddf 100644
--- a/source3/nameannounce.c
+++ b/source3/nameannounce.c
@@ -469,7 +469,7 @@ for workgroup %s\n", name, type, inet_ntoa(nr->ip_flgs[0].ip), work->work_group
NMB_QUERY,NAME_STATUS_DOM_SRV_CHK,
name, type, 0,0,0,
work->work_group,NULL,
- False, False, nr->ip_flgs[0].ip, nr->ip_flgs[0].ip);
+ False, False, nr->ip_flgs[0].ip, nr->ip_flgs[0].ip, 0);
}
}
diff --git a/source3/namebrowse.c b/source3/namebrowse.c
index 1dd293d27b..ae5f00ce10 100644
--- a/source3/namebrowse.c
+++ b/source3/namebrowse.c
@@ -199,7 +199,7 @@ workgroup %s\n",
queue_netbios_packet(d,ClientNMB,NMB_QUERY,
b->local?NAME_QUERY_SYNC_LOCAL:NAME_QUERY_SYNC_REMOTE,
b->name,0x20,0,0,0,NULL,b->group,
- False,False,b->ip,b->ip);
+ False,False,b->ip,b->ip, 0);
b->synced = True;
}
diff --git a/source3/namedbresp.c b/source3/namedbresp.c
index 86d7eddbd4..c8a31a6c79 100644
--- a/source3/namedbresp.c
+++ b/source3/namedbresp.c
@@ -95,7 +95,8 @@ struct response_record *make_response_queue_record(enum state_type state,
int quest_type, char *name,int type, int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse,
- struct in_addr send_ip, struct in_addr reply_to_ip)
+ struct in_addr send_ip, struct in_addr reply_to_ip,
+ int reply_id)
{
struct response_record *n;
@@ -118,6 +119,7 @@ struct response_record *make_response_queue_record(enum state_type state,
n->recurse = recurse;
n->send_ip = send_ip;
n->reply_to_ip = reply_to_ip;
+ n->reply_id = reply_id;
if(my_name)
StrnCpy(n->my_name, my_name, sizeof(n->my_name)-1);
else
diff --git a/source3/nameelect.c b/source3/nameelect.c
index 5fd1a4bdf2..215ee94feb 100644
--- a/source3/nameelect.c
+++ b/source3/nameelect.c
@@ -97,7 +97,7 @@ void check_master_browser(time_t t)
queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_MST_CHK,
work->work_group,0x1d,0,0,0,NULL,NULL,
- True,False,d->bcast_ip,d->bcast_ip);
+ True,False,d->bcast_ip,d->bcast_ip, 0);
}
}
}
diff --git a/source3/namepacket.c b/source3/namepacket.c
index ba2497d7de..4a9f586a76 100644
--- a/source3/namepacket.c
+++ b/source3/namepacket.c
@@ -37,6 +37,7 @@ extern int num_response_packets;
BOOL CanRecurse = True;
extern pstring scope;
extern struct in_addr wins_ip;
+extern struct in_addr loopback_ip;
static uint16 name_trn_id=0;
@@ -228,14 +229,14 @@ void reply_netbios_packet(struct packet_struct *p1,int trn_id,
}
default:
{
- DEBUG(1,("replying netbios packet: %s %s\n",
+ DEBUG(1,("replying netbios packet: %s %s %s\n",
packet_type, namestr(rr_name), inet_ntoa(p.ip)));
return;
}
}
- DEBUG(4,("replying netbios packet: %s %s\n",
+ DEBUG(4,("replying netbios packet: %s %s %s\n",
packet_type, namestr(rr_name), inet_ntoa(p.ip)));
nmb->header.name_trn_id = trn_id;
@@ -534,7 +535,9 @@ void listen_for_packets(BOOL run_election)
struct packet_struct *packet = read_packet(ClientNMB, NMB_PACKET);
if (packet)
{
- if (ismyip(packet->ip) && packet->port == NMB_PORT)
+ if ((ip_equal(loopback_ip, packet->ip) ||
+ ismyip(packet->ip)) &&
+ packet->port == NMB_PORT)
{
DEBUG(7,("discarding own packet from %s:%d\n",
inet_ntoa(packet->ip),packet->port));
@@ -552,7 +555,9 @@ void listen_for_packets(BOOL run_election)
struct packet_struct *packet = read_packet(ClientDGRAM, DGRAM_PACKET);
if (packet)
{
- if (ismyip(packet->ip) && packet->port == DGRAM_PORT)
+ if ((ip_equal(loopback_ip, packet->ip) ||
+ ismyip(packet->ip)) &&
+ packet->port == DGRAM_PORT)
{
DEBUG(7,("discarding own packet from %s:%d\n",
inet_ntoa(packet->ip),packet->port));
diff --git a/source3/nameresp.c b/source3/nameresp.c
index f44171f4b6..c40dd16a88 100644
--- a/source3/nameresp.c
+++ b/source3/nameresp.c
@@ -115,7 +115,7 @@ static void dead_netbios_entry(struct subnet_record *d,
wanted the unique name and tell them that they can have it
*/
- add_name_respond(d,n->fd,d->myip, n->response_id ,&n->name,
+ add_name_respond(d,n->fd,d->myip, n->reply_id ,&n->name,
n->nb_flags, GET_TTL(0),
n->reply_to_ip, True, n->reply_to_ip);
@@ -281,7 +281,7 @@ struct response_record *queue_netbios_pkt_wins(
return queue_netbios_packet(wins_subnet,fd, quest_type, state,
name, name_type, nb_flags, ttl,
server_type,my_name,my_comment,
- False, True, send_ip, reply_to_ip);
+ False, True, send_ip, reply_to_ip, 0);
}
@@ -296,7 +296,8 @@ struct response_record *queue_netbios_packet(struct subnet_record *d,
int name_type,int nb_flags, time_t ttl,
int server_type, char *my_name, char *my_comment,
BOOL bcast,BOOL recurse,
- struct in_addr send_ip, struct in_addr reply_to_ip)
+ struct in_addr send_ip, struct in_addr reply_to_ip,
+ int reply_id)
{
struct response_record *n;
uint16 id = 0xffff;
@@ -315,7 +316,8 @@ struct response_record *queue_netbios_packet(struct subnet_record *d,
if ((n = make_response_queue_record(state,id,fd,
quest_type,name,name_type,nb_flags,ttl,
server_type,my_name, my_comment,
- bcast,recurse,send_ip,reply_to_ip)))
+ bcast,recurse,send_ip,reply_to_ip,
+ reply_id)))
{
add_response_record(d,n);
return n;
diff --git a/source3/nameserv.c b/source3/nameserv.c
index ccd0ef379c..bc37d1c424 100644
--- a/source3/nameserv.c
+++ b/source3/nameserv.c
@@ -111,7 +111,7 @@ void remove_name_entry(struct subnet_record *d, char *name,int type)
/* local interface: release them on the network */
queue_netbios_packet(d,ClientNMB,NMB_REL,NAME_RELEASE,
name, type, 0, 0,0,NULL,NULL,
- True, False, d->bcast_ip, d->bcast_ip);
+ True, False, d->bcast_ip, d->bcast_ip, 0);
}
}
@@ -172,7 +172,7 @@ void add_my_name_entry(struct subnet_record *d,char *name,int type,int nb_flags)
queue_netbios_packet(d,ClientNMB,
re_reg ? NMB_REG_REFRESH : NMB_REG, NAME_REGISTER,
name, type, nb_flags, GET_TTL(0),0,NULL,NULL,
- True, False, d->bcast_ip, ipzero);
+ True, False, d->bcast_ip, ipzero, 0);
}
}
@@ -249,7 +249,7 @@ for domain master on workgroup %s\n",
myworkgroup, 0x1b,
0, 0,0,NULL,NULL,
True, False,
- d->bcast_ip, d->bcast_ip);
+ d->bcast_ip, d->bcast_ip, 0);
}
}
}
@@ -488,7 +488,8 @@ void query_refresh_names(time_t t)
queue_netbios_packet(d,ClientNMB,NMB_QUERY,NAME_QUERY_CONFIRM,
n->name.name, n->name.name_type,
0,0,0,NULL,NULL,
- False,False,n->ip_flgs[0].ip,n->ip_flgs[0].ip);
+ False,False,n->ip_flgs[0].ip,n->ip_flgs[0].ip,
+ 0);
count++;
}
diff --git a/source3/nameservreply.c b/source3/nameservreply.c
index 5b9c476549..98247c7636 100644
--- a/source3/nameservreply.c
+++ b/source3/nameservreply.c
@@ -45,7 +45,7 @@ static void send_name_response(int fd, struct in_addr from_ip,
int name_trn_id, int opcode, BOOL success,
BOOL recursion_available, BOOL recursion_desired,
struct nmb_name *reply_name, int nb_flags, int ttl,
- struct in_addr ip)
+ struct in_addr ip)
{
char rdata[6];
struct packet_struct p;
@@ -96,7 +96,8 @@ void add_name_respond(struct subnet_record *d, int fd, struct in_addr from_ip,
/* reply yes or no to the host that requested the name */
/* see rfc1002.txt - 4.2.10 and 4.2.11 */
- send_name_response(fd,from_ip, response_id, NMB_REG,
+
+ send_name_response(fd, reply_to_ip, response_id, NMB_REG,
new_owner,
True, True,
name, nb_flags, ttl, reply_to_ip);
@@ -317,7 +318,8 @@ void reply_name_reg(struct packet_struct *p)
reply_name->name,reply_name->name_type,
nb_flags,0,0,NULL,NULL,
False, False,
- n->ip_flgs[0].ip, p->ip);
+ n->ip_flgs[0].ip, p->ip,
+ nmb->header.name_trn_id);
}
else
{
diff --git a/source3/nameservresp.c b/source3/nameservresp.c
index a88481d06b..8de90113fb 100644
--- a/source3/nameservresp.c
+++ b/source3/nameservresp.c
@@ -176,7 +176,7 @@ static void response_server_check(struct nmb_name *ans_name,
queue_netbios_packet(d,ClientNMB,NMB_STATUS, cmd,
ans_name->name, ans_name->name_type,
0,0,0,n->my_name,NULL,
- False,False,send_ip,n->reply_to_ip);
+ False,False,send_ip,n->reply_to_ip, 0);
}
@@ -362,9 +362,11 @@ static void response_name_query_register(struct nmb_packet *nmb,
}
/* register the old or the new owners' ip */
- add_name_respond(d, n->fd, d->myip, n->response_id,&n->name,n->nb_flags,
+ add_name_respond(d, n->fd, d->myip, n->reply_id,&n->name,n->nb_flags,
GET_TTL(0), register_ip,
new_owner, n->reply_to_ip);
+
+ remove_response_record(d,n); /* remove the response record */
}
@@ -829,8 +831,8 @@ void response_netbios_packet(struct packet_struct *p)
}
ans_name = &nmb->answers->rr_name;
- DEBUG(3,("response for %s from %s (bcast=%s)\n",
- namestr(ans_name), inet_ntoa(p->ip), BOOLSTR(bcast)));
+ DEBUG(3,("response for %s from %s(%d) (bcast=%s)\n",
+ namestr(ans_name), inet_ntoa(p->ip), p->port, BOOLSTR(bcast)));
debug_rr_type(nmb->answers->rr_type);
diff --git a/source3/namework.c b/source3/namework.c
index 3e1ac22005..2de4a3016f 100644
--- a/source3/namework.c
+++ b/source3/namework.c
@@ -372,7 +372,8 @@ static void process_rcv_backup_list(struct packet_struct *p,char *buf)
queue_netbios_packet(d1,ClientNMB,NMB_QUERY,NAME_QUERY_SRV_CHK,
work->work_group,0x1d,
0,0,0,NULL,NULL,
- False,False,back_ip,back_ip);
+ False,False,back_ip,back_ip,
+ 0);
return;
}
}