ctdb-scripts: Add options to generate smb.conf interfaces include file
authorVinit Agnihotri <vagnihotri@ddn.com>
Tue, 30 Jan 2024 09:50:20 +0000 (01:50 -0800)
committerMartin Schwenke <martins@samba.org>
Tue, 16 Apr 2024 23:51:45 +0000 (23:51 +0000)
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
ctdb/config/events/legacy/50.samba.script
ctdb/doc/ctdb-script.options.5.xml

index 84600e25024ae7b19c3b502619d95094c7981c23..90de6a3f31b17850116e85d568ee4c4710fd1b00 100755 (executable)
@@ -27,6 +27,27 @@ load_script_options
 
 ctdb_setup_state_dir "service" "$service_name"
 
+generate_smb_interfaces_config()
+{
+       get_public_ifaces
+       pub_iface_list=$public_ifaces
+       public_ifaces=""
+       for iface in $pub_iface_list;
+       do
+               public_ifaces="$public_ifaces \"$iface;options=dynamic\""
+       done
+
+       if [ -n "$CTDB_SAMBA_INTERFACES_EXTRA" ]; then
+               public_ifaces="$public_ifaces $CTDB_SAMBA_INTERFACES_EXTRA"
+       fi
+       public_ifaces=$(echo "$public_ifaces" | xargs -n 1 | sort -u)
+
+cat <<EOT > "$CTDB_SAMBA_INTERFACES_FILE"
+    bind interfaces only = yes
+    interfaces = lo $public_ifaces
+EOT
+}
+
 service_start()
 {
        # make sure samba is not already started
@@ -36,6 +57,9 @@ service_start()
                # make absolutely sure samba is dead
                killall -q -9 smbd
        }
+       if [ -n "$CTDB_SAMBA_INTERFACES_FILE" ]; then
+               generate_smb_interfaces_config
+       fi
        # start Samba service. Start it reniced, as under very heavy load
        # the number of smbd processes will mean that it leaves few cycles
        # for anything else
index ef3ad416d0d3b826b90f770922ed8037fa7396bc..ffe4c3abd62ed92aca94cecdbd516206e14e24f2 100644 (file)
@@ -691,6 +691,51 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
          </listitem>
        </varlistentry>
 
+       <varlistentry>
+         <term>
+           CTDB_SAMBA_INTERFACES_FILE=<parameter>FILENAME</parameter>
+         </term>
+         <listitem>
+           <para>
+             Generates FILENAME, containing an smb.conf snippet with
+             an interfaces setting that includes interfaces for
+             configured CTDB public IP addresses.  This file then
+             needs to be explicitly included in smb.conf.
+           </para>
+           <para>
+             For example, if public IP addresses are defined on
+             interfaces eth0 and eth1, and this is set to
+             <filename>/etc/samba/interfaces.conf</filename>, then
+             that file will contain the following before smbd is
+             started:
+           </para>
+           <screen>
+     bind interfaces only = yes
+     interfaces = lo eth0 eth1
+           </screen>
+           <para>
+             This can be useful for limiting the interfaces used by
+             SMB multichannel.
+           </para>
+           <para>
+             Default is to not generate a file.
+           </para>
+         </listitem>
+       </varlistentry>
+
+       <varlistentry>
+         <term>
+           CTDB_SAMBA_INTERFACES_EXTRA=<parameter>INTERFACE-LIST</parameter>
+         </term>
+         <listitem>
+           <para>
+             A space separated list to provide additional interfaces to bind.
+           </para>
+           <para>
+             Default is empty - no extra interfaces are added.
+           </para>
+         </listitem>
+       </varlistentry>
       </variablelist>
 
     </refsect2>