SMF and TCP Tuning


I recently tuned a few TCP parameters on a Solaris 10 fileserver of mine and I wanted to persist these changes across reboots.  Well, you’re not really supposed to stick this stuff in /etc/system anymore, and so the alternative is to set it on boot.  This being the age of SMF, I looked for an existing implementation and found this blog post by Hung-Sheng Tsao at Sun.  His version was pretty simple, since it’s just a basic manifest that defines running a script in which the calls to ndd and the parameters are hardcoded.  I thought it’d be nice if you could define your parameters right in SMF (that’s the point, right? ;) so the result is a new SMF method named nddtune.  My version reads the tunables directly from the SMF properties, and also stores the previous values so that disabling the service reverts to the old values.  Here’s how you use it:

  1. Copy the nddtune script to somewhere appropriate for your environment and make sure it is executable.  By default, the SMF config expects to find it in /lib/svc/method.
  2. Copy network-nddtune.xml to /var/svc/manifest/site.  Edit the XML config file if you put nddtune somewhere other than /lib/svc/method.
  3. Import the manifest:
        # svccfg import /var/svc/manifest/site/network-nddtune.xml
  4. Create property groups for the devices you wish to tune.  The property group is translated to the device passed to ndd by prepending a slash and converting underscores to slashes, so in this example dev_tcp will result in ‘ndd -set /dev/tcp …’:
        # svccfg -s nddtune addpg dev_tcp application
  5. Set some parameters:
        # svccfg -s nddtune setprop dev_tcp/tcp_xmit_hiwat = integer: 4000000
        # svccfg -s nddtune setprop dev_tcp/tcp_recv_hiwat = integer: 4000000
        # svccfg -s nddtune setprop dev_tcp/tcp_max_buf = integer: 4000000
        # svccfg -s nddtune setprop dev_tcp/tcp_cwnd_max = integer: 4000000
  6. Create an SMF snapshot that includes your new values:
        # svcadm refresh nddtune
  7. Check your current values before enabling:
        % ndd -get /dev/tcp tcp_xmit_hiwat
        % ndd -get /dev/tcp tcp_recv_hiwat
        % ndd -get /dev/tcp tcp_max_buf
        % ndd -get /dev/tcp tcp_cwnd_max
  8. Enable the service:
        # svcadm enable nddtune
  9. Check the new values to make sure it worked:
        % ndd -get /dev/tcp tcp_xmit_hiwat
        % ndd -get /dev/tcp tcp_recv_hiwat
        % ndd -get /dev/tcp tcp_max_buf
        % ndd -get /dev/tcp tcp_cwnd_max
  10. You can disable the service to reset the tunables to their previous values, since the previous values are stored whenever the service is enabled. These previous values are stored in an SMF property group named like the one(s) you created, but with ‘_defaults’ appended:
        % /usr/bin/svcprop -p dev_tcp_defaults nddtune
        dev_tcp_defaults/tcp_xmit_hiwat integer 49152
        dev_tcp_defaults/tcp_recv_hiwat integer 49152
        dev_tcp_defaults/tcp_max_buf integer 1048576
        dev_tcp_defaults/tcp_cwnd_max integer 1048576

You can get nddtune from its repository on bitbucket.


No Responses Yet to “SMF and TCP Tuning”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: