Multiple WINS Servers Enhancement

Dave Olker dave_olker at hp.com
Thu Jul 6 19:42:45 GMT 2000


Hello Samba Team,

I decided to take a shot at writing the enhancement request to allow
samba to access more than one WINS servers.  The code base I wrote this
on is 2.0.6.  The enhancement involves changes to 5 files:

source/libsmb/namequery.c
source/nmbd/nmbd_subnetdb.c
source/param/loadparm.c
source/utils/testparm.c
source/include/proto.h

The design goals I tried to adhere to in this enhancement were:

1. Minimal amount of change to code and smb.conf file

     The primary WINS server stuff is exactly as it was.  I didn't 
     rename any of the existing variables, I merely added the ones
     needed for the secondary server.  

2. Only allow a single secondary server, rather than a list

     Microsoft only allows a primary and secondary server to be 
     specified so I used this model

3. The behavior is to query the primary first and only fail over to
   the secondary if the primary does not respond, rather than use a
   round-robin method of load balancing the servers.

     Again, I believe this is how NT works so this is the model I used.


The only change necessary to the smb.conf file to use this new feature
is to add a line in the [global] section called "wins secondary server =
<ip/host>".  The syntax of the field is the same as the "wins server"
field.

I have not modified the documentation files yet because I wanted to
first submit the enhancement and make sure the samba community agreed
with the proposed syntax (i.e. adding an entry to the smb.conf file
called "wins secondary server" rather than modifying the syntax of the
existing "wins server" field to accept a list).  Once the implementation
details are agreed upon we can modify the documentation to match the
implementation.

Here are the proposed changes to the files in unified diff format:

--- CIFS_Source/samba/source/libsmb/namequery.c Fri Nov 12 11:19:43 1999
+++ MultipleWINS/samba/source/libsmb/namequery.c        Fri May 26
11:40:27 2000
@@ -525,6 +525,31 @@

        wins_ip = *interpret_addr2(lp_wins_server());
        wins_ismyip = ismyip(wins_ip);
+       DEBUG(3,("resolve_wins: wins_ip is currently set to <%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 );
+
+               if (sock != -1) {
+                       *return_iplist = name_query(sock, name,
name_type, False,
+                                                               True,
wins_ip, return_count, NULL);
+                       if(*return_iplist != NULL) {
+                               close(sock);
+                               return True;
+                       }
+                       close(sock);
+               }
+       }
+
+       if(!*lp_wins_secondary_server()) {
+               DEBUG(3,("resolve_wins: Primary WINS server failed and
no Secondary WINS server present.\n"));
+               return False;
+       }
+
+       wins_ip = *interpret_addr2(lp_wins_secondary_server());
+       wins_ismyip = ismyip(wins_ip);
+       DEBUG(3,("resolve_wins: wins_ip is currently set to <%s>\n",
inet_ntoa(wins_ip)));

        if((wins_ismyip && !global_in_nmbd) || !wins_ismyip) {
                sock = open_socket_in( SOCK_DGRAM, 0, 3,


--- CIFS_Source/samba/source/nmbd/nmbd_subnetdb.c       Fri Nov 12
11:19:07 1999
+++ MultipleWINS/samba/source/nmbd/nmbd_subnetdb.c      Thu Jul  6
12:17:36 2000
@@ -275,7 +275,23 @@
       /* The smb.conf's wins server parameter MUST be a host_name
          or an ip_address. */
       DEBUG(0,("invalid smb.conf parameter 'wins server'\n"));
-      return False;
+      if(*lp_wins_secondary_server())
+      {
+        struct in_addr real_wins_ip;
+        real_wins_ip = *interpret_addr2(lp_wins_secondary_server());
+
+        if (!zero_ip(real_wins_ip))
+        {
+          unicast_ip = real_wins_ip;
+        }
+        else
+        {
+          /* The smb.conf's wins secondary server parameter MUST be a
host_name
+             or an ip_address. */
+          DEBUG(0,("invalid smb.conf parameter 'wins secondary
server'\n"));
+          return False;
+        }
+      }
     }
   }
   else if(lp_we_are_a_wins_server())


--- CIFS_Source/samba/source/param/loadparm.c   Thu Jan  6 18:47:02 2000
+++ MultipleWINS/samba/source/param/loadparm.c  Fri May 26 09:54:52 2000
@@ -143,6 +143,7 @@
   char *szLogonHome;
   char *szSmbrun;
   char *szWINSserver;
+  char *szWINSSecondaryserver;
   char *szCodingSystem;
   char *szInterfaces;
   char *szRemoteAnnounce;
@@ -775,6 +776,7 @@
   {"dns proxy",        P_BOOL,    P_GLOBAL, &Globals.bDNSproxy,        
NULL,   NULL,  0},
   {"wins proxy",       P_BOOL,    P_GLOBAL, &Globals.bWINSproxy,       
NULL,   NULL,  0},
   {"wins server",      P_STRING,  P_GLOBAL, &Globals.szWINSserver,     
NULL,   NULL,  FLAG_BASIC},
+  {"wins secondary server",       P_STRING, P_GLOBAL,
&Globals.szWINSSecondaryserver,  NULL,   NULL,  FLAG_BASIC},
   {"wins support",     P_BOOL,    P_GLOBAL, &Globals.bWINSsupport,     
NULL,   NULL,  FLAG_BASIC},
   {"wins hook",        P_STRING,  P_GLOBAL, &Globals.szWINSHook,
NULL,   NULL,  0},

@@ -1214,6 +1216,7 @@
 FN_GLOBAL_STRING(lp_remote_announce,&Globals.szRemoteAnnounce)
 FN_GLOBAL_STRING(lp_remote_browse_sync,&Globals.szRemoteBrowseSync)
 FN_GLOBAL_STRING(lp_wins_server,&Globals.szWINSserver)
+FN_GLOBAL_STRING(lp_wins_secondary_server,&Globals.szWINSSecondaryserver)
 FN_GLOBAL_STRING(lp_interfaces,&Globals.szInterfaces)
 FN_GLOBAL_STRING(lp_socket_address,&Globals.szSocketAddress)
 FN_GLOBAL_STRING(lp_nis_home_map_name,&Globals.szNISHomeMapName)


--- CIFS_Source/samba/source/utils/testparm.c   Fri Nov 12 11:19:37 1999
+++ MultipleWINS/samba/source/utils/testparm.c  Fri May 26 09:55:06 2000
@@ -159,6 +159,23 @@
                }
        }

+       /*
+        * WINS Secondary server line sanity checks.
+        */
+
+       if(*lp_wins_secondary_server()) {
+               fstring server;
+               int count = 0;
+               char *p = lp_wins_secondary_server();
+
+               while(next_token(&p,server,LIST_SEP,sizeof(server)))
+                       count++;
+               if(count > 1) {
+                       printf("ERROR: the 'wins secondary server'
parameter must only contain one WINS server.\n");
+                       ret = -1;
+               }
+       }
+
        return ret;
 }



--- CIFS_Source/samba/source/include/proto.h    Fri Nov 12 16:02:37 1999
+++ MultipleWINS/samba/source/include/proto.h   Fri May 26 09:30:44 2000
@@ -1015,6 +1015,7 @@
 char *lp_remote_announce(void);
 char *lp_remote_browse_sync(void);
 char *lp_wins_server(void);
+char *lp_wins_secondary_server(void);
 char *lp_interfaces(void);
 char *lp_socket_address(void);
 char *lp_nis_home_map_name(void);


Let me know what you think.

Regards,

Dave
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dave_olker.vcf
Type: text/x-vcard
Size: 376 bytes
Desc: Card for Dave Olker
Url : http://lists.samba.org/archive/samba-technical/attachments/20000706/0b8243fc/dave_olker.vcf


More information about the samba-technical mailing list