From: Jens Axboe Date: Thu, 9 Oct 2014 18:05:44 +0000 (-0600) Subject: engines/net: add TCP_MAXSEG setting (mss) X-Git-Tag: fio-2.1.14~79 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=e5f34d95af9163b42945e1737f628a9526a6f83c engines/net: add TCP_MAXSEG setting (mss) Signed-off-by: Jens Axboe --- diff --git a/HOWTO b/HOWTO index f78e47c1..d2ce4d8e 100644 --- a/HOWTO +++ b/HOWTO @@ -1687,6 +1687,8 @@ that defines them is selected. [net] window_size Set the desired socket buffer size for the connection. +[net] mss Set the TCP maximum segment size (TCP_MAXSEG). + [e4defrag] donorname=str File will be used as a block donor(swap extents between files) [e4defrag] inplace=int diff --git a/configure b/configure index 3e3c9785..81b16a35 100755 --- a/configure +++ b/configure @@ -1093,6 +1093,26 @@ if compile_prog "" "" "SO_SNDBUF"; then fi echo "Net engine window_size $window_size" +########################################## +# Check whether we have TCP_MAXSEG +mss="no" +cat > $TMPC << EOF +#include +#include +#include +#include +#include +#include +int main(int argc, char **argv) +{ + return setsockopt(0, IPPROTO_TCP, TCP_MAXSEG, NULL, 0); +} +EOF +if compile_prog "" "" "TCP_MAXSEG"; then + mss="yes" +fi +echo "TCP_MAXSEG $mss" + ########################################## # Check whether we have RLIMIT_MEMLOCK rlimit_memlock="no" @@ -1451,6 +1471,9 @@ fi if test "$window_size" = "yes" ; then output_sym "CONFIG_NET_WINDOWSIZE" fi +if test "$mss" = "yes" ; then + output_sym "CONFIG_NET_MSS" +fi if test "$rlimit_memlock" = "yes" ; then output_sym "CONFIG_RLIMIT_MEMLOCK" fi diff --git a/engines/net.c b/engines/net.c index ac5a93c8..9a327da8 100644 --- a/engines/net.c +++ b/engines/net.c @@ -40,6 +40,7 @@ struct netio_options { unsigned int nodelay; unsigned int ttl; unsigned int window_size; + unsigned int mss; char *intfc; }; @@ -177,6 +178,18 @@ static struct fio_option options[] = { .category = FIO_OPT_C_ENGINE, .group = FIO_OPT_G_NETIO, }, +#endif +#ifdef CONFIG_NET_MSS + { + .name = "mss", + .lname = "Maximum segment size", + .type = FIO_OPT_INT, + .off1 = offsetof(struct netio_options, mss), + .minval = 0, + .help = "Set TCP maximum segment size", + .category = FIO_OPT_C_ENGINE, + .group = FIO_OPT_G_NETIO, + }, #endif { .name = NULL, @@ -233,6 +246,30 @@ static int set_window_size(struct thread_data *td, int fd) #endif } +static int set_mss(struct thread_data *td, int fd) +{ +#ifdef CONFIG_NET_MSS + struct netio_options *o = td->eo; + unsigned int mss; + int ret; + + if (!o->mss || !is_tcp(o)) + return 0; + + mss = o->mss; + ret = setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, (void *) &mss, + sizeof(mss)); + if (ret < 0) + td_verror(td, errno, "setsockopt TCP_MAXSEG"); + + return ret; +#else + td_verror(td, -EINVAL, "setsockopt TCP_MAXSEG"); + return -1; +#endif +} + + /* * Return -1 for error and 'nr events' for a positive number * of events @@ -655,6 +692,10 @@ static int fio_netio_connect(struct thread_data *td, struct fio_file *f) close(f->fd); return 1; } + if (set_mss(td, f->fd)) { + close(f->fd); + return 1; + } if (is_udp(o)) { if (!fio_netio_is_multicast(td->o.filename)) @@ -1101,6 +1142,10 @@ static int fio_netio_setup_listen_inet(struct thread_data *td, short port) close(fd); return 1; } + if (set_mss(td, fd)) { + close(fd); + return 1; + } if (td->o.filename) { if (!is_udp(o) || !fio_netio_is_multicast(td->o.filename)) { diff --git a/fio.1 b/fio.1 index dc727d36..9ddf101a 100644 --- a/fio.1 +++ b/fio.1 @@ -1528,6 +1528,9 @@ reader when multiple readers are listening to the same address. .BI (net, window_size) \fR=\fPint Set the desired socket buffer size for the connection. .TP +.BI (net, mss) \fR=\fPint +Set the TCP maximum segment size (TCP_MAXSEG). +.TP .BI (e4defrag,donorname) \fR=\fPstr File will be used as a block donor (swap extents between files) .TP