fixed the freeze on logout bug. The fix has several parts:
authorAndrew Tridgell <tridge@samba.org>
Wed, 15 Oct 1997 09:15:45 +0000 (09:15 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 15 Oct 1997 09:15:45 +0000 (09:15 +0000)
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)

source3/include/nameserv.h
source3/nameannounce.c
source3/namebrowse.c
source3/namedbresp.c
source3/nameelect.c
source3/namepacket.c
source3/nameresp.c
source3/nameserv.c
source3/nameservreply.c
source3/nameservresp.c
source3/namework.c

index 593c101d92f4476b3ae6d6152329ec97149623b7..81487e9ce9ab500093d944fd28328e74cabcb2c7 100644 (file)
@@ -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;
 
index d3344ebd4786a91f512d2f42d96d23c663311843..d69ee32ddf7b6fb01198f47c9f77088ef5af197b 100644 (file)
@@ -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);
          }
 
     }
index 1dd293d27be0ae31fea4e30604bb9d083563059a..ae5f00ce10e2016ce1495837f2594fdfd13f2dd7 100644 (file)
@@ -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;
 }
index 86d7eddbd41cb13c5b930b83eb5ec8841fd92d33..c8a31a6c79be0d810dccd6d5901c109ae67a2caa 100644 (file)
@@ -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
index 5fd1a4bdf2ebc304e21cfa37e6402debac92fc0f..215ee94febb2a536d4f1fb0eeadc455269159e2b 100644 (file)
@@ -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);
         }
       }
     }
index ba2497d7de08c8ddf48714fd80cdf524bb54588c..4a9f586a762d29b5cad0c04da88d10f7f58e54cf 100644 (file)
@@ -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));   
index f44171f4b674b08794d4ba9f3886c01e2bc9c582..c40dd16a8884f93fcb27146e11664007a1fa186a 100644 (file)
@@ -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;
index ccd0ef379cba189b49b809ab658c9a6a16a11343..bc37d1c424eff1da9a3cc7345e3f5bbc8235e93d 100644 (file)
@@ -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++;
                }
 
index 5b9c476549d487be8f16b8e894dfdc43e8139ba2..98247c76366fa98b4b91398c23ad5d43da69c2b3 100644 (file)
@@ -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
   {
index a88481d06b0a61cd601d3d7579393d626721e7f5..8de90113fb6bd0b8c6913ac17fb65344d31e8431 100644 (file)
@@ -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);
   
index 3e1ac220058bd20b3578d745a46fc9fa7b61c99f..2de4a3016f7bc1e4924689b894dcc1fbb32ec2d9 100644 (file)
@@ -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;
                  }
                }