[SCM] Samba Shared Repository - branch v3-5-stable updated

Karolin Seeger kseeger at samba.org
Mon Feb 15 02:41:14 MST 2010


The branch, v3-5-stable has been updated
       via  76148be... VERSION: We need another release candidate.
       via  edac3a3... WHATSNEW: Update changes since 3.5.0rc2.
       via  e08caca... Fixes issue with preexec scripts creating a share directory, and problems is a smb.conf reload turns wide links back on after a connection is establised.
       via  b8215ae... s3: Fix typo found by jhell <jhell at DataIX.net> (cherry picked from commit 271a4c60dbec0d001dc55df58de8e54274137853) (cherry picked from commit eb390b8f917f52eb28f46f39a19abdc717051f3d)
       via  291738d... s3-spoolss: implement spoolss_EnumJobs level 3.
       via  59e187a... WHATSNEW: Mention new "nmbd bind explicit broadcast" parameter.
       via  85ec12a... More of the fix for bug #7118 - nmbd problems with socket address.
       via  8925ef0... Make "nmbd bind explicit broadcast" on by default.
       via  f87c0e6... s3:docs-xml: document "nmbd bind explicit broadcast"
       via  354e229... s3:nmbd: change "nmbd:bind explicit broadcast" into "nmbd bind explicit broadcast"
       via  88645a6... s3:nmbd: also listen explicit on the subnet broadcast addresses
       via  340f559... s3: change ldap filter to what really was intended (cherry picked from commit 9b75650f1a963e36a6dd697b5ad2725a8c7c9250)
      from  00e133b... WHATSNEW: Update changes since 3.5.0rc2.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-5-stable


- Log -----------------------------------------------------------------
commit 76148be688f7201bdf7a613618e05fcc3415917d
Author: Karolin Seeger <kseeger at samba.org>
Date:   Mon Feb 15 10:22:45 2010 +0100

    VERSION: We need another release candidate.
    
    Karolin
    (cherry picked from commit 70e4d52d290e1851afe9c1f9e4503534713ec8fb)

commit edac3a3036fdf97beeef50fb4d1dac3e1ee5cc4b
Author: Karolin Seeger <kseeger at samba.org>
Date:   Mon Feb 15 10:37:09 2010 +0100

    WHATSNEW: Update changes since 3.5.0rc2.
    
    Karolin
    (cherry picked from commit 4a386fb1850b558cc7355ecd4e0ce0a9849283e0)

commit e08caca47e31a0ca2c19f94b70a01f8402937089
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Feb 11 16:00:51 2010 -0800

    Fixes issue with preexec scripts creating a share directory, and problems is a smb.conf reload turns wide links back on after a connection is establised.
    
    Includes git refs :
    cd18695fc2e4d09ab75e9eab2f0c43dcc15adf0b
    94865e4dbd3d721c9855aada8c55e02be8b3881e
    5d92d969dda450cc3564dd2265d2b042d832c542
    02a5078f1fe6285e4a0b6ad95a3aea1c5bb3e8cf
    a6f402ad87ff0ae14d57d97278d67d0ceaaa1d82
    
    from master.
    
    Jeremy.
    
    Fix bug #7104 ("wide links" and "unix extensions" are incompatible.)
    (cherry picked from commit 09fbad07d7fc6577b5617b1ecc912072ad220463)

commit b8215ae91e2d2baed6e0763022debe0e41d6aded
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Feb 13 16:38:25 2010 +0100

    s3: Fix typo found by jhell <jhell at DataIX.net>
    (cherry picked from commit 271a4c60dbec0d001dc55df58de8e54274137853)
    (cherry picked from commit eb390b8f917f52eb28f46f39a19abdc717051f3d)

commit 291738dd0d7f1b4671f8b496e1b50576ac79a101
Author: Günther Deschner <gd at samba.org>
Date:   Thu Feb 11 00:44:06 2010 +0100

    s3-spoolss: implement spoolss_EnumJobs level 3.
    
    Level 3 has been added with NT 4.0 and Windows 7 (at least 64bit version) makes
    use of it in order to display queued jobs. Windows 7 will *not* fall back to
    level 2 if we just return WERR_UNKNOWN_LEVEL, instead there will be no printjobs
    displayed at all.
    
    Guenther
    (cherry picked from commit 25001bbd1b0b32073073dab7cf5b78a2b902163f)
    
    Fix bug #7130 (enumjobs level 3 is required by win7).
    (cherry picked from commit 223d9163651a3a2c0bb2bd72886f1a119b7f1fed)

commit 59e187ab8d68edb50fb44206423bfb2e1ee0849e
Author: Karolin Seeger <kseeger at samba.org>
Date:   Thu Feb 11 13:25:12 2010 +0100

    WHATSNEW: Mention new "nmbd bind explicit broadcast" parameter.
    
    Karolin
    (cherry picked from commit df5db3d3f02d40d08891faa83717d306ebcd1331)

commit 85ec12a06d5834fa7b9b8269bbe47387def9928e
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Feb 10 12:32:05 2010 -0800

    More of the fix for bug #7118 - nmbd problems with socket address.
    
    Add a simple "processed packet queue" cache to stop nmbd responding to
    packets received on the broadcast and non-broadcast socket (which
    it has opened when "nmbd bind explicit broadcast = yes").
    
    This is a very simple packet queue - it only keeps the packets
    processed during a single call to listen_for_packets() (i.e. one
    select call). This means that if the delivery notification for a
    packet received on both broadcast and non-broadcast addresses
    is done in two different select calls, the packet will still be
    processed twice. This is a very rare occurrance and we can just
    live with it when it does as the protocol is stateless. If this
    is ever flagged as a repeatable problem then we can add a longer
    lived cache, using timeout processing to clear etc. etc. But without
    storing all packets processed we can never be *sure* we've eliminated
    the race condition so I'm going to go with this simple solution until
    someone proves a more complex one is needed :-).
    
    Jeremy.
    (cherry picked from commit 6fe7ee1d216fcf722b3efa23fd80782ce0dd0e9f)

commit 8925ef04a1967f96857f5c2445927c7a263b9178
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Feb 8 14:35:02 2010 -0800

    Make "nmbd bind explicit broadcast" on by default.
    
    Fix a comment typo.
    
    Jeremy.
    (cherry picked from commit 05123ef78c903de2a12b95fb30632f03ac919a4d)

commit f87c0e624bec2f60a134fc2ea2f3b8339b18de95
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Feb 8 12:59:13 2010 +0100

    s3:docs-xml: document "nmbd bind explicit broadcast"
    
    metze
    (cherry picked from commit 9887751f6fa6f7e4fd5c79c637e0576405000c01)
    
    The last 3 fixes address bug #7118 (nmbd problems with socket address).
    (cherry picked from commit 5456e5e460041256cfa886eb8bab380c59c25b19)

commit 354e2295e4f502940743c62d0d6ee8f5af88f7a2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Feb 8 12:51:29 2010 +0100

    s3:nmbd: change "nmbd:bind explicit broadcast" into "nmbd bind explicit broadcast"
    
    metze
    (cherry picked from commit 0140bc389d56511c3255720856bdb64803ba8930)
    (cherry picked from commit 431a78a2f823b415d9fb2b207448e33e6ba12138)

commit 88645a6665523b0b26e520141c13820c48ad5aec
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jan 28 11:04:05 2010 +0100

    s3:nmbd: also listen explicit on the subnet broadcast addresses
    
    And send replies always via the unicast address of the subnet.
    
    This behavior is off by default (as before)
    and can be enabled with "nmbd:bind explicit broadcast = yes".
    
    metze
    (cherry picked from commit 30a1bc365071befd07e68e24ca4fa3843159ab13)
    (cherry picked from commit fe629dbf1aab33f6e75c14b916684c9adeca017f)

commit 340f559f3bddf2482fafbb24a5205fdb919d23e5
Author: Björn Jacke <bj at sernet.de>
Date:   Wed Feb 10 13:48:11 2010 +0100

    s3: change ldap filter to what really was intended (cherry picked from commit 9b75650f1a963e36a6dd697b5ad2725a8c7c9250)
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    
    Part of a fix for bug #7116.
    (cherry picked from commit 23116018779938f931394a022893f2a46654a697)

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                                       |   14 +-
 .../smbdotconf/misc/nmbdbindexplicitbroadcast.xml  |   17 ++
 source3/VERSION                                    |    2 +-
 source3/include/nameserv.h                         |    5 +-
 source3/include/proto.h                            |    2 +
 source3/libsmb/namequery.c                         |    6 +-
 source3/libsmb/nmblib.c                            |    9 +-
 source3/m4/check_path.m4                           |    4 +-
 source3/nmbd/nmbd.c                                |    5 +-
 source3/nmbd/nmbd_packets.c                        |  278 +++++++++++++++-----
 source3/nmbd/nmbd_subnetdb.c                       |  123 ++++++---
 source3/param/loadparm.c                           |   49 ++++-
 source3/passdb/pdb_ldap.c                          |    2 +-
 source3/rpc_server/srv_spoolss_nt.c                |   76 ++++++
 source3/smbd/service.c                             |   63 +++--
 15 files changed, 505 insertions(+), 150 deletions(-)
 create mode 100644 docs-xml/smbdotconf/misc/nmbdbindexplicitbroadcast.xml


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 7560bc5..4c14ea2 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -4,8 +4,10 @@
                    =============================
 
 
-This is the first stable release of Samba 3.5.
-
+This is the third release candidate of Samba 3.5.  This is *not*
+intended for production environments and is designed for testing
+purposes only.  Please report any defects via the Samba bug reporting
+system at https://bugzilla.samba.org/.
 
 Major enhancements in Samba 3.5.0 include:
 
@@ -94,6 +96,7 @@ smb.conf changes
    debug hires timestamp	       Changed Default yes
    ldap deref			       New	       auto
    ldap follow referral		       New	       auto
+   nmbd bind explicit broadcast	       New	       no
    wide links			       Changed Default no
 
 
@@ -142,6 +145,7 @@ o   Jeremy Allison <jra at samba.org>
     * BUG 7084: Fix storing of create time on directories in an EA in new
       create time code.
     * BUG 7104: "wide links" and "unix extensions" are incompatible.
+    * BUG 7118: Fix nmbd problems with socket address.
     * BUG 7122: Fix reading of large browselist.
 
 
@@ -149,8 +153,13 @@ o   Steven Danneman <steven.danneman at isilon.com>
     * BUG 7096: Fix string buffer overflow causing heap corruption in smbd.
 
 
+o   Günther Deschner <gd at samba.org>
+    * BUG 7130: Fix listing of printjobs in  Windows 7.
+
+
 o   Björn Jacke <bj at sernet.de>
     * BUG 7103: Fix build issue on Tru64.
+    * BUG 7116: Change ldap filter to what really was intended.
     * Fix some wrong newlines in de translation strings.
 
 
@@ -162,6 +171,7 @@ o   Volker Lendecke <vl at samba.org>
 o   Stefan Metzmacher <metze at samba.org>
     * BUG 7098: Fix results of 'smbclient -L' with a large browse list.
     * BUG 7116: Add pdb_ldap performance fixes.
+    * BUG 7118: Add new "nmbd bind explicit broadcast" parameter.
     * BUG 7119: Support large browselist.
 
 
diff --git a/docs-xml/smbdotconf/misc/nmbdbindexplicitbroadcast.xml b/docs-xml/smbdotconf/misc/nmbdbindexplicitbroadcast.xml
new file mode 100644
index 0000000..3a44a69
--- /dev/null
+++ b/docs-xml/smbdotconf/misc/nmbdbindexplicitbroadcast.xml
@@ -0,0 +1,17 @@
+<samba:parameter name="nmbd bind explicit broadcast"
+	         context="G"
+		 advanced="1" developer="1"
+		 type="boolean"
+		 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+	<para>
+	This option causes <citerefentry><refentrytitle>nmbd</refentrytitle>
+	<manvolnum>8</manvolnum></citerefentry> to explicitly bind to the
+	broadcast address of the local subnets. This is needed to make nmbd
+	work correctly in combination with the <smbconfoption name="socket address"/> option.
+	You should not need to unset this option.
+	</para>
+</description>
+
+<value type="default">yes</value>
+</samba:parameter>
diff --git a/source3/VERSION b/source3/VERSION
index 13358fe..c8c88b4 100644
--- a/source3/VERSION
+++ b/source3/VERSION
@@ -56,7 +56,7 @@ SAMBA_VERSION_PRE_RELEASE=
 # e.g. SAMBA_VERSION_RC_RELEASE=1                      #
 #  ->  "3.0.0rc1"                                      #
 ########################################################
-SAMBA_VERSION_RC_RELEASE=
+SAMBA_VERSION_RC_RELEASE=3
 
 ########################################################
 # To mark SVN snapshots this should be set to 'yes'    #
diff --git a/source3/include/nameserv.h b/source3/include/nameserv.h
index 496d87e..53ffd6f 100644
--- a/source3/include/nameserv.h
+++ b/source3/include/nameserv.h
@@ -434,7 +434,9 @@ struct subnet_record {
 	struct in_addr mask_ip;
 	struct in_addr myip;
 	int nmb_sock;               /* socket to listen for unicast 137. */
+	int nmb_bcast;              /* socket to listen for broadcast 137. */
 	int dgram_sock;             /* socket to listen for unicast 138. */
+	int dgram_bcast;            /* socket to listen for broadcast 138. */
 };
 
 /* A resource record. */
@@ -530,7 +532,8 @@ struct packet_struct
 	bool locked;
 	struct in_addr ip;
 	int port;
-	int fd;
+	int recv_fd;
+	int send_fd;
 	time_t timestamp;
 	enum packet_type packet_type;
 	union {
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 37e6eb9..26fbb44 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3947,6 +3947,7 @@ const char *lp_logon_drive(void);
 const char *lp_logon_home(void);
 char *lp_remote_announce(void);
 char *lp_remote_browse_sync(void);
+bool lp_nmbd_bind_explicit_broadcast(void);
 const char **lp_wins_server_list(void);
 const char **lp_interfaces(void);
 const char *lp_socket_address(void);
@@ -4376,6 +4377,7 @@ void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val);
 int lp_min_receive_file_size(void);
 char* lp_perfcount_module(void);
 void lp_set_passdb_backend(const char *backend);
+void widelinks_warning(int snum);
 
 /* The following definitions come from param/util.c  */
 
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 930f0a5..858330d 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -289,7 +289,8 @@ NODE_STATUS_STRUCT *node_status_query(int fd,
 
 	p.ip = ((const struct sockaddr_in *)to_ss)->sin_addr;
 	p.port = NMB_PORT;
-	p.fd = fd;
+	p.recv_fd = -1;
+	p.send_fd = fd;
 	p.timestamp = time(NULL);
 	p.packet_type = NMB_PACKET;
 
@@ -698,7 +699,8 @@ struct sockaddr_storage *name_query(int fd,
 
 	p.ip = ((struct sockaddr_in *)to_ss)->sin_addr;
 	p.port = NMB_PORT;
-	p.fd = fd;
+	p.recv_fd = -1;
+	p.send_fd = fd;
 	p.timestamp = time(NULL);
 	p.packet_type = NMB_PACKET;
 
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index 5f3eda4..1a21066 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -601,6 +601,8 @@ static struct packet_struct *copy_nmb_packet(struct packet_struct *packet)
 
 	/* Ensure this copy is not locked. */
 	pkt_copy->locked = False;
+	pkt_copy->recv_fd = -1;
+	pkt_copy->send_fd = -1;
 
 	/* Ensure this copy has no resource records. */
 	nmb = &packet->packet.nmb;
@@ -666,6 +668,8 @@ static struct packet_struct *copy_dgram_packet(struct packet_struct *packet)
 
 	/* Ensure this copy is not locked. */
 	pkt_copy->locked = False;
+	pkt_copy->recv_fd = -1;
+	pkt_copy->send_fd = -1;
 
 	/* There are no additional pointers in a dgram packet,
 		we are finished. */
@@ -791,7 +795,8 @@ struct packet_struct *read_packet(int fd,enum packet_type packet_type)
 	if (!packet)
 		return NULL;
 
-	packet->fd = fd;
+	packet->recv_fd = fd;
+	packet->send_fd = -1;
 
 	DEBUG(5,("Received a packet of len %d from (%s) port %d\n",
 		 length, inet_ntoa(packet->ip), packet->port ) );
@@ -1075,7 +1080,7 @@ bool send_packet(struct packet_struct *p)
 	if (!len)
 		return(False);
 
-	return(send_udp(p->fd,buf,len,p->ip,p->port));
+	return(send_udp(p->send_fd,buf,len,p->ip,p->port));
 }
 
 /****************************************************************************
diff --git a/source3/m4/check_path.m4 b/source3/m4/check_path.m4
index b2cc53a..3683802 100644
--- a/source3/m4/check_path.m4
+++ b/source3/m4/check_path.m4
@@ -151,8 +151,8 @@ AC_ARG_WITH(piddir,
 
 #################################################
 # set ncalrpc directory location
-AC_ARG_WITH(ncalprcdir,
-[AS_HELP_STRING([--with-ncalprcdir=DIR], [Where to put ncalrpc sockets ($ac_default_prefix/var/ncalrpc)])],
+AC_ARG_WITH(ncalrpcdir,
+[AS_HELP_STRING([--with-ncalrpcdir=DIR], [Where to put ncalrpc sockets ($ac_default_prefix/var/ncalrpc)])],
 [ case "$withval" in
   yes|no)
   #
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 961e930..3b51a78 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -443,13 +443,14 @@ static void msg_nmbd_send_packet(struct messaging_context *msg,
 	local_ip = &((const struct sockaddr_in *)pss)->sin_addr;
 	subrec = FIRST_SUBNET;
 
-	p->fd = (p->packet_type == NMB_PACKET) ?
+	p->recv_fd = -1;
+	p->send_fd = (p->packet_type == NMB_PACKET) ?
 		subrec->nmb_sock : subrec->dgram_sock;
 
 	for (subrec = FIRST_SUBNET; subrec != NULL;
 	     subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
 		if (ip_equal_v4(*local_ip, subrec->myip)) {
-			p->fd = (p->packet_type == NMB_PACKET) ?
+			p->send_fd = (p->packet_type == NMB_PACKET) ?
 				subrec->nmb_sock : subrec->dgram_sock;
 			break;
 		}
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index 6136c6d..a753b28 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -207,7 +207,8 @@ static struct packet_struct *create_and_init_netbios_packet(struct nmb_name *nmb
 
 	packet->ip = to_ip;
 	packet->port = NMB_PORT;
-	packet->fd = ClientNMB;
+	packet->recv_fd = -1;
+	packet->send_fd = ClientNMB;
 	packet->timestamp = time(NULL);
 	packet->packet_type = NMB_PACKET;
 	packet->locked = False;
@@ -258,7 +259,8 @@ static bool create_and_init_additional_record(struct packet_struct *packet,
 	   our standard refresh cycle for that name which copes nicely
 	   with disconnected networks.
 	*/
-	packet->fd = find_subnet_fd_for_address(*register_ip);
+	packet->recv_fd = -1;
+	packet->send_fd = find_subnet_fd_for_address(*register_ip);
 
 	return True;
 }
@@ -743,7 +745,7 @@ struct response_record *queue_query_name( struct subnet_record *subrec,
 			}
 
 			DEBUG(10,("queue_query_name: using source IP %s\n",inet_ntoa(*ifip)));
-				p->fd = find_subnet_fd_for_address( *ifip );
+				p->send_fd = find_subnet_fd_for_address( *ifip );
 				break;
 		}
 	}
@@ -979,9 +981,14 @@ for id %hu\n", packet_type, nmb_namestr(&orig_nmb->question.question_name),
 	}
 
 	packet.packet_type = NMB_PACKET;
+	packet.recv_fd = -1;
 	/* Ensure we send out on the same fd that the original
 		packet came in on to give the correct source IP address. */
-	packet.fd = orig_packet->fd;
+	if (orig_packet->send_fd != -1) {
+		packet.send_fd = orig_packet->send_fd;
+	} else {
+		packet.send_fd = orig_packet->recv_fd;
+	}
 	packet.timestamp = time(NULL);
 
 	debug_nmb_packet(&packet);
@@ -1679,50 +1686,74 @@ static bool create_listen_fdset(fd_set **ppset, int **psock_array, int *listen_n
 		return True;
 	}
 
+	/* The Client* sockets */
+	count++;
+
 	/* Check that we can add all the fd's we need. */
 	for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec))
 		count++;
 
-	if((count*2) + 2 > FD_SETSIZE) {
+	/* each interface gets 4 sockets */
+	count *= 4;
+
+	if(count > FD_SETSIZE) {
 		DEBUG(0,("create_listen_fdset: Too many file descriptors needed (%d). We can \
-only use %d.\n", (count*2) + 2, FD_SETSIZE));
+only use %d.\n", count, FD_SETSIZE));
 		SAFE_FREE(pset);
 		return True;
 	}
 
-	if((sock_array = SMB_MALLOC_ARRAY(int, (count*2) + 2)) == NULL) {
-		DEBUG(0,("create_listen_fdset: malloc fail for socket array.\n"));
+	if((sock_array = SMB_MALLOC_ARRAY(int, count)) == NULL) {
+		DEBUG(0,("create_listen_fdset: malloc fail for socket array. size %d\n", count));
 		SAFE_FREE(pset);
 		return True;
 	}
 
 	FD_ZERO(pset);
 
-	/* Add in the broadcast socket on 137. */
+	/* Add in the lp_socket_address() interface on 137. */
 	FD_SET(ClientNMB,pset);
 	sock_array[num++] = ClientNMB;
 	*maxfd = MAX( *maxfd, ClientNMB);
 
+	/* the lp_socket_address() interface has only one socket */
+	sock_array[num++] = -1;
+
 	/* Add in the 137 sockets on all the interfaces. */
 	for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
 		FD_SET(subrec->nmb_sock,pset);
 		sock_array[num++] = subrec->nmb_sock;
 		*maxfd = MAX( *maxfd, subrec->nmb_sock);
+
+		sock_array[num++] = subrec->nmb_bcast;
+		if (subrec->nmb_bcast != -1) {
+			FD_SET(subrec->nmb_bcast,pset);
+			*maxfd = MAX( *maxfd, subrec->nmb_bcast);
+		}
 	}
 
-	/* Add in the broadcast socket on 138. */
+	/* Add in the lp_socket_address() interface on 138. */
 	FD_SET(ClientDGRAM,pset);
 	sock_array[num++] = ClientDGRAM;
 	*maxfd = MAX( *maxfd, ClientDGRAM);
 
+	/* the lp_socket_address() interface has only one socket */
+	sock_array[num++] = -1;
+
 	/* Add in the 138 sockets on all the interfaces. */
 	for (subrec = FIRST_SUBNET; subrec; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
 		FD_SET(subrec->dgram_sock,pset);
 		sock_array[num++] = subrec->dgram_sock;
 		*maxfd = MAX( *maxfd, subrec->dgram_sock);
+
+		sock_array[num++] = subrec->dgram_bcast;
+		if (subrec->dgram_bcast != -1) {
+			FD_SET(subrec->dgram_bcast,pset);
+			*maxfd = MAX( *maxfd, subrec->dgram_bcast);
+		}
 	}
 
-	*listen_number = (count*2) + 2;
+	*listen_number = count;
 
 	SAFE_FREE(*ppset);
 	SAFE_FREE(*psock_array);
@@ -1734,6 +1765,83 @@ only use %d.\n", (count*2) + 2, FD_SETSIZE));
 }
 
 /****************************************************************************
+ List of packets we're processing this select.
+***************************************************************************/
+
+struct processed_packet {
+	struct processed_packet *next;
+	struct processed_packet *prev;
+	enum packet_type packet_type;
+	struct in_addr ip;
+	int packet_id;
+};
+
+/****************************************************************************
+ Have we seen this before ?
+***************************************************************************/
+
+static bool is_processed_packet(struct processed_packet *processed_packet_list,
+				struct packet_struct *packet)
+{
+	struct processed_packet *p = NULL;
+
+	for (p = processed_packet_list; p; p = p->next) {
+		if (ip_equal_v4(p->ip, packet->ip) && p->packet_type == packet->packet_type) {
+			if ((p->packet_type == NMB_PACKET) &&
+				(p->packet_id ==
+					packet->packet.nmb.header.name_trn_id)) {
+				return true;
+			} else if ((p->packet_type == DGRAM_PACKET) &&
+				(p->packet_id ==
+					packet->packet.dgram.header.dgm_id)) {
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+/****************************************************************************
+ Keep a list of what we've seen before.
+***************************************************************************/
+
+static bool store_processed_packet(struct processed_packet **pp_processed_packet_list,
+				struct packet_struct *packet)
+{
+	struct processed_packet *p = SMB_MALLOC_P(struct processed_packet);
+	if (!p) {
+		return false;
+	}
+	p->packet_type = packet->packet_type;
+	p->ip = packet->ip;
+	if (packet->packet_type == NMB_PACKET) {
+		p->packet_id = packet->packet.nmb.header.name_trn_id;
+	} else if (packet->packet_type == DGRAM_PACKET) {
+		p->packet_id = packet->packet.dgram.header.dgm_id;
+	} else {
+		return false;
+	}
+
+	DLIST_ADD(*pp_processed_packet_list, p);
+	return true;
+}
+
+/****************************************************************************
+ Throw away what we've seen before.
+***************************************************************************/
+
+static void free_processed_packet_list(struct processed_packet **pp_processed_packet_list)
+{
+	struct processed_packet *p = NULL, *next = NULL;
+
+	for (p = *pp_processed_packet_list; p; p = next) {
+		next = p->next;
+		DLIST_REMOVE(*pp_processed_packet_list, p);
+		SAFE_FREE(p);
+	}
+}
+
+/****************************************************************************
   Listens for NMB or DGRAM packets, and queues them.
   return True if the socket is dead
 ***************************************************************************/
@@ -1753,6 +1861,7 @@ bool listen_for_packets(bool run_election)
 #ifndef SYNC_DNS
 	int dns_fd;
 #endif
+	struct processed_packet *processed_packet_list = NULL;
 
 	if(listen_set == NULL || rescan_listen_set) {
 		if(create_listen_fdset(&listen_set, &sock_array, &listen_number, &maxfd)) {
@@ -1811,61 +1920,101 @@ bool listen_for_packets(bool run_election)
 #endif
 
 	for(i = 0; i < listen_number; i++) {
+		enum packet_type packet_type;
+		struct packet_struct *packet;
+		const char *packet_name;
+		int client_fd;
+		int client_port;
+
+		if (sock_array[i] == -1) {
+			continue;
+		}
+
+		if (!FD_ISSET(sock_array[i],&r_fds)) {
+			continue;
+		}
+
 		if (i < (listen_number/2)) {
-			/* Processing a 137 socket. */
-			if (FD_ISSET(sock_array[i],&r_fds)) {
-				struct packet_struct *packet = read_packet(sock_array[i], NMB_PACKET);
-				if (packet) {
-					/*
-					 * If we got a packet on the broadcast socket and interfaces
-					 * only is set then check it came from one of our local nets. 
-					 */
-					if(lp_bind_interfaces_only() && (sock_array[i] == ClientNMB) && 
-								(!is_local_net_v4(packet->ip))) {
-						DEBUG(7,("discarding nmb packet sent to broadcast socket from %s:%d\n",
-							inet_ntoa(packet->ip),packet->port));	  
-						free_packet(packet);
-					} else if ((is_loopback_ip_v4(packet->ip) || 
-								ismyip_v4(packet->ip)) && packet->port == global_nmb_port &&
-								packet->packet.nmb.header.nm_flags.bcast) {
-						DEBUG(7,("discarding own bcast packet from %s:%d\n",
-							inet_ntoa(packet->ip),packet->port));	  
-						free_packet(packet);
-					} else {
-						/* Save the file descriptor this packet came in on. */
-						packet->fd = sock_array[i];


-- 
Samba Shared Repository


More information about the samba-cvs mailing list