Commit 032c6d21 authored by Matt Caswell's avatar Matt Caswell
Browse files

Add pipeline support to s_server and s_client



Add the options min_send_frag and max_pipelines to s_server and s_client
in order to control pipelining capabilities. This will only have an effect
if a pipeline capable cipher is used (such as the one provided by the
dasync engine).

Reviewed-by: default avatarTim Hudson <tjh@openssl.org>
parent d102d9df
Loading
Loading
Loading
Loading
+33 −1
Original line number Diff line number Diff line
@@ -188,6 +188,8 @@ extern int verify_quiet;

static char *prog;
static int async = 0;
static unsigned int split_send_fragment = 0;
static unsigned int max_pipelines = 0;
static int c_nbio = 0;
static int c_tlsextdebug = 0;
static int c_status_req = 0;
@@ -654,7 +656,7 @@ typedef enum OPTION_choice {
    OPT_CHAINCAFILE, OPT_VERIFYCAFILE, OPT_NEXTPROTONEG, OPT_ALPN,
    OPT_SERVERINFO, OPT_STARTTLS, OPT_SERVERNAME,
    OPT_USE_SRTP, OPT_KEYMATEXPORT, OPT_KEYMATEXPORTLEN, OPT_SMTPHOST,
    OPT_ASYNC,
    OPT_ASYNC, OPT_SPLIT_SEND_FRAG, OPT_MAX_PIPELINES,
    OPT_V_ENUM,
    OPT_X_ENUM,
    OPT_S_ENUM,
@@ -760,6 +762,10 @@ OPTIONS s_client_options[] = {
     "Enable ALPN extension, considering named protocols supported (comma-separated list)"},
    {"async", OPT_ASYNC, '-', "Support asynchronous operation"},
    {"ssl_config", OPT_SSL_CONFIG, 's', "Use specified configuration file"},
    {"split_send_frag", OPT_SPLIT_SEND_FRAG, 'n',
     "Size used to split data for encrypt/decrypt pipelines"},
    {"max_pipelines", OPT_MAX_PIPELINES, 'n',
     "Maximum number of encrypt/decrypt pipelines to be used"},
    OPT_S_OPTIONS,
    OPT_V_OPTIONS,
    OPT_X_OPTIONS,
@@ -1377,6 +1383,16 @@ int s_client_main(int argc, char **argv)
        case OPT_ASYNC:
            async = 1;
            break;
        case OPT_SPLIT_SEND_FRAG:
            split_send_fragment = atoi(opt_arg());
            if (split_send_fragment == 0) {
                /* Not allowed - set to a deliberately bad value */
                split_send_fragment = -1;
            }
            break;
        case OPT_MAX_PIPELINES:
            max_pipelines = atoi(opt_arg());
            break;
        }
    }
    argc = opt_num_rest();
@@ -1424,6 +1440,16 @@ int s_client_main(int argc, char **argv)
        goto end;
    }

    if (split_send_fragment > SSL3_RT_MAX_PLAIN_LENGTH) {
        BIO_printf(bio_err, "Bad split send fragment size\n");
        goto end;
    }

    if (max_pipelines > SSL_MAX_PIPELINES) {
        BIO_printf(bio_err, "Bad max pipelines value\n");
        goto end;
    }

#if !defined(OPENSSL_NO_NEXTPROTONEG)
    next_proto.status = -1;
    if (next_proto_neg_in) {
@@ -1540,6 +1566,12 @@ int s_client_main(int argc, char **argv)
    if (async) {
        SSL_CTX_set_mode(ctx, SSL_MODE_ASYNC);
    }
    if (split_send_fragment > 0) {
        SSL_CTX_set_split_send_fragment(ctx, split_send_fragment);
    }
    if (max_pipelines > 0) {
        SSL_CTX_set_max_pipelines(ctx, max_pipelines);
    }

    if (!config_ctx(cctx, ssl_args, ctx))
        goto end;
+35 −1
Original line number Diff line number Diff line
@@ -244,6 +244,8 @@ static char *keymatexportlabel = NULL;
static int keymatexportlen = 20;

static int async = 0;
static unsigned int split_send_fragment = 0;
static unsigned int max_pipelines = 0;

#ifndef OPENSSL_NO_ENGINE
static char *engine_id = NULL;
@@ -402,6 +404,8 @@ static void s_server_init(void)
    s_quiet = 0;
    s_brief = 0;
    async = 0;
    split_send_fragment = 0;
    max_pipelines = 0;
#ifndef OPENSSL_NO_ENGINE
    engine_id = NULL;
#endif
@@ -805,7 +809,7 @@ typedef enum OPTION_choice {
    OPT_QUIET, OPT_BRIEF, OPT_NO_DHE,
    OPT_NO_RESUME_EPHEMERAL, OPT_PSK_HINT, OPT_PSK, OPT_SRPVFILE,
    OPT_SRPUSERSEED, OPT_REV, OPT_WWW, OPT_UPPER_WWW, OPT_HTTP, OPT_ASYNC,
    OPT_SSL_CONFIG, OPT_SSL3,
    OPT_SSL_CONFIG, OPT_SPLIT_SEND_FRAG, OPT_MAX_PIPELINES, OPT_SSL3,
    OPT_TLS1_2, OPT_TLS1_1, OPT_TLS1, OPT_DTLS, OPT_DTLS1,
    OPT_DTLS1_2, OPT_TIMEOUT, OPT_MTU, OPT_CHAIN, OPT_LISTEN,
    OPT_ID_PREFIX, OPT_RAND, OPT_SERVERNAME, OPT_SERVERNAME_FATAL,
@@ -938,6 +942,10 @@ OPTIONS s_server_options[] = {
    {"async", OPT_ASYNC, '-', "Operate in asynchronous mode"},
    {"ssl_config", OPT_SSL_CONFIG, 's', \
     "Configure SSL_CTX using the configuration 'val'"},
    {"split_send_frag", OPT_SPLIT_SEND_FRAG, 'n',
     "Size used to split data for encrypt/decrypt pipelines"},
    {"max_pipelines", OPT_MAX_PIPELINES, 'n',
     "Maximum number of encrypt/decrypt pipelines to be used"},
    OPT_S_OPTIONS,
    OPT_V_OPTIONS,
    OPT_X_OPTIONS,
@@ -1503,6 +1511,16 @@ int s_server_main(int argc, char *argv[])
        case OPT_ASYNC:
            async = 1;
            break;
        case OPT_SPLIT_SEND_FRAG:
            split_send_fragment = atoi(opt_arg());
            if (split_send_fragment == 0) {
                /* Not allowed - set to a deliberately bad value */
                split_send_fragment = -1;
            }
            break;
        case OPT_MAX_PIPELINES:
            max_pipelines = atoi(opt_arg());
            break;
        }
    }
    argc = opt_num_rest();
@@ -1528,6 +1546,16 @@ int s_server_main(int argc, char *argv[])
    }
#endif

    if (split_send_fragment > SSL3_RT_MAX_PLAIN_LENGTH) {
        BIO_printf(bio_err, "Bad split send fragment size\n");
        goto end;
    }

    if (max_pipelines > SSL_MAX_PIPELINES) {
        BIO_printf(bio_err, "Bad max pipelines value\n");
        goto end;
    }

    if (!app_passwd(passarg, dpassarg, &pass, &dpass)) {
        BIO_printf(bio_err, "Error getting password\n");
        goto end;
@@ -1718,6 +1746,12 @@ int s_server_main(int argc, char *argv[])
    if (async) {
        SSL_CTX_set_mode(ctx, SSL_MODE_ASYNC);
    }
    if (split_send_fragment > 0) {
        SSL_CTX_set_split_send_fragment(ctx, split_send_fragment);
    }
    if (max_pipelines > 0) {
        SSL_CTX_set_max_pipelines(ctx, max_pipelines);
    }

#ifndef OPENSSL_NO_SRTP
    if (srtp_profiles != NULL) {