diff options
author | Andrew Tridgell <tridge@samba.org> | 1997-10-15 09:15:45 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 1997-10-15 09:15:45 +0000 |
commit | e1e86c1a160c8302004ea58e4f0f5874dd179dae (patch) | |
tree | b9a4a216f64d928e4589a55471beca4e621937c5 | |
parent | 708edc348f0fb81d9c918e4bf857f339a13a3781 (diff) | |
download | samba-e1e86c1a160c8302004ea58e4f0f5874dd179dae.tar.gz samba-e1e86c1a160c8302004ea58e4f0f5874dd179dae.tar.xz samba-e1e86c1a160c8302004ea58e4f0f5874dd179dae.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
-rw-r--r-- | source/include/nameserv.h | 1 | ||||
-rw-r--r-- | source/nameannounce.c | 2 | ||||
-rw-r--r-- | source/namebrowse.c | 2 | ||||
-rw-r--r-- | source/namedbresp.c | 4 | ||||
-rw-r--r-- | source/nameelect.c | 2 | ||||
-rw-r--r-- | source/namepacket.c | 13 | ||||
-rw-r--r-- | source/nameresp.c | 10 | ||||
-rw-r--r-- | source/nameserv.c | 9 | ||||
-rw-r--r-- | source/nameservreply.c | 8 | ||||
-rw-r--r-- | source/nameservresp.c | 10 | ||||
-rw-r--r-- | source/namework.c | 3 |
11 files changed, 40 insertions, 24 deletions
diff --git a/source/include/nameserv.h b/source/include/nameserv.h index 593c101d92f..81487e9ce9a 100644 --- a/source/include/nameserv.h +++ b/source/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/source/nameannounce.c b/source/nameannounce.c index d3344ebd478..d69ee32ddf7 100644 --- a/source/nameannounce.c +++ b/source/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/source/namebrowse.c b/source/namebrowse.c index 1dd293d27be..ae5f00ce10e 100644 --- a/source/namebrowse.c +++ b/source/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/source/namedbresp.c b/source/namedbresp.c index 86d7eddbd41..c8a31a6c79b 100644 --- a/source/namedbresp.c +++ b/source/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/source/nameelect.c b/source/nameelect.c index 5fd1a4bdf2e..215ee94febb 100644 --- a/source/nameelect.c +++ b/source/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/source/namepacket.c b/source/namepacket.c index ba2497d7de0..4a9f586a762 100644 --- a/source/namepacket.c +++ b/source/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/source/nameresp.c b/source/nameresp.c index f44171f4b67..c40dd16a888 100644 --- a/source/nameresp.c +++ b/source/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/source/nameserv.c b/source/nameserv.c index ccd0ef379cb..bc37d1c424e 100644 --- a/source/nameserv.c +++ b/source/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/source/nameservreply.c b/source/nameservreply.c index 5b9c476549d..98247c76366 100644 --- a/source/nameservreply.c +++ b/source/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/source/nameservresp.c b/source/nameservresp.c index a88481d06b0..8de90113fb6 100644 --- a/source/nameservresp.c +++ b/source/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/source/namework.c b/source/namework.c index 3e1ac220058..2de4a3016f7 100644 --- a/source/namework.c +++ b/source/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; } } |