[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Thu May 7 16:24:02 UTC 2020


The branch, master has been updated
       via  afd3bd01eb4 docs-xml/smbdotconf: clarify the quoting for advanced "interfaces" options
       via  fe3380d369c interface: clarify the quoting for advanced "interfaces" options
       via  5944ec38cd9 interface: allow overriding speed/cap/if_index for named interfaces
       via  d39636acea4 lib/socket: autodetect RSS using ETHTOOL_GRXRINGS
       via  4ccb5816093 lib/socket: let query_iface_speed_from_name() initialize memory passed to syscalls
      from  c83ce5f4f99 lib:util: Fix smbclient -l basename dir

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit afd3bd01eb463081cb85724260a0840cd98b38c2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 7 12:04:00 2020 +0200

    docs-xml/smbdotconf: clarify the quoting for advanced "interfaces" options
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Thu May  7 16:23:40 UTC 2020 on sn-devel-184

commit fe3380d369c2a528f89da5a047235420cec63b4d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 7 12:04:00 2020 +0200

    interface: clarify the quoting for advanced "interfaces" options
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 5944ec38cd9462643f82bf733a86a8e405bc0594
Author: Steven Noonan <steven at uplinklabs.net>
Date:   Mon Sep 23 22:53:40 2019 -0700

    interface: allow overriding speed/cap/if_index for named interfaces
    
    Signed-off-by: Steven Noonan <steven at uplinklabs.net>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit d39636acea4fda840b23646b021e24559681b0b0
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 7 11:06:03 2020 +0200

    lib/socket: autodetect RSS using ETHTOOL_GRXRINGS
    
    This is also used as part of 'ethtool -n rdma14' and
    'ethtool -x rdma14'.
    
    ;#> ethtool -n rdma14
    8 RX rings available
    rxclass: Cannot get RX class rule count: Operation not supported
    RX classification rule retrieval failed
    
    ;#> ethtool -x rdma14
    RX flow hash indirection table for rdma14 with 8 RX ring(s):
        0:      0     1     2     3     4     5     6     7
        8:      0     1     2     3     4     5     6     7
    RSS hash key:
    Operation not supported
    RSS hash function:
        toeplitz: on
        xor: off
        crc32: off
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 4ccb58160936d13a06c74ed1c28c855564b50f22
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu May 7 11:06:03 2020 +0200

    lib/socket: let query_iface_speed_from_name() initialize memory passed to syscalls
    
    I'm not sure if struct initializers would take care of padding,
    so I use ZERO_STRUCT().
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

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

Summary of changes:
 docs-xml/smbdotconf/base/interfaces.xml | 20 ++++++++++++---
 lib/socket/interfaces.c                 | 43 +++++++++++++++++++++++++++++++++
 source3/lib/interface.c                 | 39 +++++++++++++++++++++---------
 3 files changed, 86 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/base/interfaces.xml b/docs-xml/smbdotconf/base/interfaces.xml
index b804e64be9e..cbc29712385 100644
--- a/docs-xml/smbdotconf/base/interfaces.xml
+++ b/docs-xml/smbdotconf/base/interfaces.xml
@@ -41,12 +41,13 @@
 
 	<para>
 	In order to support SMB3 multi-channel configurations, smbd understands
-	some extra data that can be appended after the actual interface with
-	this extended syntax:
+	some extra parameters which can be appended after the actual interface with
+	this extended syntax (note that the quoting is important in order to handle the ; and ,
+	characters):
 	</para>
 
 	<para>
-	interface[;key1=value1[,key2=value2[...]]]
+	"interface[;key1=value1[,key2=value2[...]]]"
 	</para>
 
 	<para>
@@ -58,18 +59,29 @@
 	development rather than for production use. At least on Linux systems,
 	these values should be auto-detected, but the settings can serve
 	as last a resort when autodetection is not working or is not available.
+	The specified values overwrite the auto-detected values.
 	</para>
 
 	<para>
-	The example below configures three network interfaces corresponding 
+	The first two example below configures three network interfaces corresponding
 	to the eth0 device and IP addresses 192.168.2.10 and 192.168.3.10. 
 	The netmasks of the latter two interfaces would be set to 255.255.255.0.
 	</para>
 
+	<para>
+	The other examples show how per interface extra parameters can be specified.
+	Notice the possible usage of "," and ";", which makes
+	the double quoting necessary.
+	</para>
 </description>
 <related>bind interfaces only</related>
 
 <value type="example">eth0 192.168.2.10/24 192.168.3.10/255.255.255.0</value>
+<value type="example">eth0, 192.168.2.10/24; 192.168.3.10/255.255.255.0</value>
+<value type="example">"eth0;if_index=65,speed=1000000000,capability=RSS"</value>
+<value type="example">"lo;speed=1000000000" "eth0;capability=RSS"</value>
+<value type="example">"lo;speed=1000000000" , "eth0;capability=RSS"</value>
+<value type="example">"eth0;capability=RSS" , "rdma1;capability=RDMA" ; "rdma2;capability=RSS,capability=RDMA"</value>
 
 <value type="default"/>
 </samba:parameter>
diff --git a/lib/socket/interfaces.c b/lib/socket/interfaces.c
index ac26b97c248..3157e0cef12 100644
--- a/lib/socket/interfaces.c
+++ b/lib/socket/interfaces.c
@@ -149,6 +149,7 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed)
 	strlcpy(ifr.ifr_name, name, IF_NAMESIZE);
 
 	ifr.ifr_data = (void *)&edata;
+	ZERO_STRUCT(edata);
 	edata.cmd = ETHTOOL_GLINK;
 	ret = ioctl(fd, SIOCETHTOOL, &ifr);
 	if (ret == -1) {
@@ -161,6 +162,7 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed)
 	}
 
 	ifr.ifr_data = (void *)&ecmd;
+	ZERO_STRUCT(ecmd);
 	ecmd.cmd = ETHTOOL_GSET;
 	ret = ioctl(fd, SIOCETHTOOL, &ifr);
 	if (ret == -1) {
@@ -168,6 +170,42 @@ static void query_iface_speed_from_name(const char *name, uint64_t *speed)
 	}
 	*speed = ((uint64_t)ethtool_cmd_speed(&ecmd)) * 1000 * 1000;
 
+done:
+	(void)close(fd);
+}
+
+static void query_iface_rx_queues_from_name(const char *name,
+					    uint64_t *rx_queues)
+{
+	int ret = 0;
+	struct ethtool_rxnfc rxcmd;
+	struct ifreq ifr;
+	int fd;
+
+	fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
+	if (fd == -1) {
+		DBG_ERR("Failed to open socket.");
+		return;
+	}
+
+	if (strlen(name) >= IF_NAMESIZE) {
+		DBG_ERR("Interface name too long.");
+		goto done;
+	}
+
+	ZERO_STRUCT(ifr);
+	strlcpy(ifr.ifr_name, name, IF_NAMESIZE);
+
+	ifr.ifr_data = (void *)&rxcmd;
+	ZERO_STRUCT(rxcmd);
+	rxcmd.cmd = ETHTOOL_GRXRINGS;
+	ret = ioctl(fd, SIOCETHTOOL, &ifr);
+	if (ret == -1) {
+		goto done;
+	}
+
+	*rx_queues = rxcmd.data;
+
 done:
 	(void)close(fd);
 }
@@ -215,6 +253,7 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
 	/* Loop through interfaces, looking for given IP address */
 	for (ifptr = iflist; ifptr != NULL; ifptr = ifptr->ifa_next) {
 		uint64_t if_speed = 1000 * 1000 * 1000; /* 1Gbps */
+		uint64_t rx_queues = 1;
 
 		if (!ifptr->ifa_addr || !ifptr->ifa_netmask) {
 			continue;
@@ -276,9 +315,13 @@ static int _get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
 
 #ifdef HAVE_ETHTOOL
 		query_iface_speed_from_name(ifptr->ifa_name, &if_speed);
+		query_iface_rx_queues_from_name(ifptr->ifa_name, &rx_queues);
 #endif
 		ifaces[total].linkspeed = if_speed;
 		ifaces[total].capability = FSCTL_NET_IFACE_NONE_CAPABLE;
+		if (rx_queues > 1) {
+			ifaces[total].capability |= FSCTL_NET_IFACE_RSS_CAPABLE;
+		}
 
 		if (strlcpy(ifaces[total].name, ifptr->ifa_name,
 			sizeof(ifaces[total].name)) >=
diff --git a/source3/lib/interface.c b/source3/lib/interface.c
index af81695abab..35cfc5eee62 100644
--- a/source3/lib/interface.c
+++ b/source3/lib/interface.c
@@ -419,7 +419,11 @@ static void parse_extra_info(char *key, uint64_t *speed, uint32_t *cap,
  Additional information for an interface can be specified with
  this extended syntax:
 
-    interface[;key1=value1[,key2=value2[...]]]
+    "interface[;key1=value1[,key2=value2[...]]]"
+
+ Note: The double quoting is important for the
+       smb.conf parser! Otherwise the ';' and ',' separates
+       two interfaces.
 
  where
  - keys known: 'speed', 'capability', 'if_index'
@@ -429,6 +433,8 @@ static void parse_extra_info(char *key, uint64_t *speed, uint32_t *cap,
    these indexes should not conicide with indexes
    the kernel sets...
 
+ Note: The specified values overwrite the autodetected values!
+
 ****************************************************************************/
 
 static void interpret_interface(char *token)
@@ -449,17 +455,6 @@ static void interpret_interface(char *token)
 	bool cap_set = false;
 	bool if_index_set = false;
 
-	/* first check if it is an interface name */
-	for (i=0;i<total_probed;i++) {
-		if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
-			add_interface(&probed_ifaces[i]);
-			added = true;
-		}
-	}
-	if (added) {
-		return;
-	}
-
 	/*
 	 * extract speed / capability information if present
 	 */
@@ -478,6 +473,26 @@ static void interpret_interface(char *token)
 		}
 	}
 
+	/* first check if it is an interface name */
+	for (i=0;i<total_probed;i++) {
+		if (gen_fnmatch(token, probed_ifaces[i].name) == 0) {
+			if (speed_set) {
+				probed_ifaces[i].linkspeed = speed;
+			}
+			if (cap_set) {
+				probed_ifaces[i].capability = cap;
+			}
+			if (if_index_set) {
+				probed_ifaces[i].if_index = if_index;
+			}
+			add_interface(&probed_ifaces[i]);
+			added = true;
+		}
+	}
+	if (added) {
+		return;
+	}
+
 	p = strchr_m(token,'/');
 	if (p == NULL) {
 		if (!interpret_string_addr(&ss, token, 0)) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list