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: Tim Hudson <tjh@openssl.org>
This commit is contained in:
		@@ -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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user