In Chapter 9, Troubleshooting Techniques, we saw how to change different network tuning parameters for different operating systems. This appendix details what is necessary to persist these changes on Solaris 10 and above.
The following script is what is actually run by the Service Management Framework (SMF) to set the network parameters with ndd
. Save it as /lib/svc/method/network-tuning.sh
and make it executable so that it can be run at any time on the command line to test:
# vi /lib/svc/method/network-tuning.sh
The following snippet is the content of the /lib/svc/method/network-tuning.sh
file:
#!/sbin/sh # Set the following values as desired ndd -set /dev/tcp tcp_max_buf 16777216 ndd -set /dev/tcp tcp_smallest_anon_port 1024 ndd -set /dev/tcp tcp_largest_anon_port 65535 ndd -set /dev/tcp tcp_conn_req_max_q 1024 ndd -set /dev/tcp tcp_conn_req_max_q0 4096 ndd -set /dev/tcp tcp_xmit_hiwat 1048576 ndd -set /dev/tcp tcp_recv_hiwat 1048576 # chmod 755 /lib/svc /method/network-tuning.sh
The following manifest serves to define the network tuning service and will run the script at boot time. Note that we specify the duration of transient
to let SMF know that this is a run-once script and not a persistent daemon.
Place it in /var/svc/manifest/site/network-tuning.xml
and import with the following command:
# svccfg import /var/svc/manifest/site/network-tuning.xml
You will see the following output:
<?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> <service_bundle type='manifest' name='SUNW:network_tuning'> <service name='site/network_tuning' type='service' version='1'> <create_default_instance enabled='true' /> <single_instance /> <dependency name='usr' type='service' grouping='require_all' restart_on='none'> <service_fmri value='svc:/system/filesystem/minimal' /> </dependency> <!-- Run ndd commands after network/physical is plumbed. --> <dependency name='network-physical' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/network/physical' /> </dependency> <!-- but run the commands before network/initial --> <dependent name='ndd_network-initial' grouping='optional_all' restart_on='none'> <service_fmri value='svc:/network/initial' /> </dependent> <exec_method type='method' name='start' exec='/lib/svc/method/network-tuning.sh' timeout_seconds='60' /> <exec_method type='method' name='stop' exec=':true' timeout_seconds='60' /> <property_group name='startd' type='framework'> <propval name='duration' type='astring' value='transient' /> </property_group> <stability value='Unstable' /> <template> <common_name> <loctext xml:lang='C'> Network Tunings </loctext> </common_name> </template> </service> </service_bundle>
This service is intentionally kept simple for demonstration purposes.
Note
The interested reader can explore SMF in the Solaris man pages (https://docs.oracle.com/cd/E26502_01/html/E29043/smf-5.html) and online resources (https://github.com/natefoo/smf-nettune/blob/master/README.md).