Guest User

openssh-6.0p1-hpn13v13-ismo.diff

a guest
May 27th, 2014
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 64.07 KB | None | 0 0
  1. diff -NupwB canonical/auth2.c kitchen/auth2.c
  2. --- canonical/auth2.c   2011-12-18 18:52:51.000000000 -0500
  3. +++ kitchen/auth2.c 2012-11-07 15:28:16.000000000 -0500
  4. @@ -49,6 +49,7 @@
  5.  #include "dispatch.h"
  6.  #include "pathnames.h"
  7.  #include "buffer.h"
  8. +#include "canohost.h"
  9.  
  10.  #ifdef GSSAPI
  11.  #include "ssh-gss.h"
  12. @@ -75,6 +76,8 @@ extern Authmethod method_gssapi;
  13.  extern Authmethod method_jpake;
  14.  #endif
  15.  
  16. +static int log_flag = 0;
  17. +
  18.  Authmethod *authmethods[] = {
  19.     &method_none,
  20.     &method_pubkey,
  21. @@ -227,6 +230,12 @@ input_userauth_request(int type, u_int32
  22.     debug("userauth-request for user %s service %s method %s", user, service, method);
  23.     debug("attempt %d failures %d", authctxt->attempt, authctxt->failures);
  24.  
  25. +   if (!log_flag) {
  26. +       logit("SSH: Server;Ltype: Authname;Remote: %s-%d;Name: %s",
  27. +           get_remote_ipaddr(), get_remote_port(), user);
  28. +       log_flag = 1;
  29. +   }
  30. +
  31.     if ((style = strchr(user, ':')) != NULL)
  32.         *style++ = 0;
  33.  
  34. diff -NupwB canonical/buffer.c kitchen/buffer.c
  35. --- canonical/buffer.c  2010-02-11 17:23:40.000000000 -0500
  36. +++ kitchen/buffer.c    2012-11-07 15:28:16.000000000 -0500
  37. @@ -127,7 +127,7 @@ restart:
  38.  
  39.     /* Increase the size of the buffer and retry. */
  40.     newlen = roundup(buffer->alloc + len, BUFFER_ALLOCSZ);
  41. -   if (newlen > BUFFER_MAX_LEN)
  42. +   if (newlen > BUFFER_MAX_LEN_HPN)
  43.         fatal("buffer_append_space: alloc %u not supported",
  44.             newlen);
  45.     buffer->buf = xrealloc(buffer->buf, 1, newlen);
  46. diff -NupwB canonical/buffer.h kitchen/buffer.h
  47. --- canonical/buffer.h  2010-09-09 21:39:27.000000000 -0400
  48. +++ kitchen/buffer.h    2012-11-07 15:28:16.000000000 -0500
  49. @@ -16,6 +16,9 @@
  50.  #ifndef BUFFER_H
  51.  #define BUFFER_H
  52.  
  53. +/* move the following to a more appropriate place and name */
  54. +#define BUFFER_MAX_LEN_HPN          0x4000000  /* 64MB */
  55. +
  56.  typedef struct {
  57.     u_char  *buf;       /* Buffer for data. */
  58.     u_int    alloc;     /* Number of bytes allocated for data. */
  59. diff -NupwB canonical/channels.c kitchen/channels.c
  60. --- canonical/channels.c    2011-10-02 03:59:03.000000000 -0400
  61. +++ kitchen/channels.c  2012-11-07 15:28:16.000000000 -0500
  62. @@ -173,8 +173,10 @@ static void port_open_helper(Channel *c,
  63.  static int connect_next(struct channel_connect *);
  64.  static void channel_connect_ctx_free(struct channel_connect *);
  65.  
  66. -/* -- channel core */
  67. +static int hpn_disabled = 0;
  68. +static int hpn_buffer_size = 2 * 1024 * 1024;
  69.  
  70. +/* -- channel core */
  71.  Channel *
  72.  channel_by_id(int id)
  73.  {
  74. @@ -318,6 +320,7 @@ channel_new(char *ctype, int type, int r
  75.     c->local_window_max = window;
  76.     c->local_consumed = 0;
  77.     c->local_maxpacket = maxpack;
  78. +   c->dynamic_window = 0;
  79.     c->remote_id = -1;
  80.     c->remote_name = xstrdup(remote_name);
  81.     c->remote_window = 0;
  82. @@ -817,11 +820,36 @@ channel_pre_open_13(Channel *c, fd_set *
  83.         FD_SET(c->sock, writeset);
  84.  }
  85.  
  86. +int channel_tcpwinsz () {
  87. +        u_int32_t tcpwinsz = 0;
  88. +        socklen_t optsz = sizeof(tcpwinsz);
  89. +   int ret = -1;
  90. +
  91. +   /* if we aren't on a socket return 128KB*/
  92. +   if(!packet_connection_is_on_socket())
  93. +       return(128*1024);
  94. +   ret = getsockopt(packet_get_connection_in(),
  95. +            SOL_SOCKET, SO_RCVBUF, &tcpwinsz, &optsz);
  96. +   /* return no more than 64MB */
  97. +   if ((ret == 0) && tcpwinsz > BUFFER_MAX_LEN_HPN)
  98. +       tcpwinsz = BUFFER_MAX_LEN_HPN;
  99. +   debug2("tcpwinsz: %d for connection: %d", tcpwinsz,
  100. +          packet_get_connection_in());
  101. +   return(tcpwinsz);
  102. +}
  103. +
  104.  static void
  105.  channel_pre_open(Channel *c, fd_set *readset, fd_set *writeset)
  106.  {
  107.     u_int limit = compat20 ? c->remote_window : packet_get_maxsize();
  108.  
  109. +        /* check buffer limits */
  110. +   if ((!c->tcpwinsz) || (c->dynamic_window > 0))
  111. +           c->tcpwinsz = channel_tcpwinsz();
  112. +  
  113. +   limit = MIN(limit, 2 * c->tcpwinsz);
  114. +
  115. +
  116.     if (c->istate == CHAN_INPUT_OPEN &&
  117.         limit > 0 &&
  118.         buffer_len(&c->input) < limit &&
  119. @@ -1798,6 +1826,17 @@ channel_check_window(Channel *c)
  120.         c->local_maxpacket*3) ||
  121.         c->local_window < c->local_window_max/2) &&
  122.         c->local_consumed > 0) {
  123. +       u_int addition = 0;
  124. +       /* adjust max window size if we are in a dynamic environment */
  125. +       if (c->dynamic_window && (c->tcpwinsz > c->local_window_max)) {
  126. +       /* grow the window somewhat aggressively to maintain pressure */
  127. +           addition = 1.5*(c->tcpwinsz - c->local_window_max);
  128. +           c->local_window_max += addition;
  129. +       }
  130. +       packet_start(SSH2_MSG_CHANNEL_WINDOW_ADJUST);
  131. +       packet_put_int(c->remote_id);
  132. +       packet_put_int(c->local_consumed + addition);
  133. +
  134.         packet_start(SSH2_MSG_CHANNEL_WINDOW_ADJUST);
  135.         packet_put_int(c->remote_id);
  136.         packet_put_int(c->local_consumed);
  137. @@ -1805,7 +1844,7 @@ channel_check_window(Channel *c)
  138.         debug2("channel %d: window %d sent adjust %d",
  139.             c->self, c->local_window,
  140.             c->local_consumed);
  141. -       c->local_window += c->local_consumed;
  142. +       c->local_window += c->local_consumed + addition;
  143.         c->local_consumed = 0;
  144.     }
  145.     return 1;
  146. @@ -2137,11 +2176,12 @@ channel_after_select(fd_set *readset, fd
  147.  
  148.  
  149.  /* If there is data to send to the connection, enqueue some of it now. */
  150. -void
  151. +int
  152.  channel_output_poll(void)
  153.  {
  154.     Channel *c;
  155.     u_int i, len;
  156. +   int packet_length = 0;
  157.  
  158.     for (i = 0; i < channels_alloc; i++) {
  159.         c = channels[i];
  160. @@ -2189,7 +2229,7 @@ channel_output_poll(void)
  161.                     packet_start(SSH2_MSG_CHANNEL_DATA);
  162.                     packet_put_int(c->remote_id);
  163.                     packet_put_string(data, dlen);
  164. -                   packet_send();
  165. +                   packet_length = packet_send();
  166.                     c->remote_window -= dlen + 4;
  167.                     xfree(data);
  168.                 }
  169. @@ -2219,7 +2259,7 @@ channel_output_poll(void)
  170.                     SSH2_MSG_CHANNEL_DATA : SSH_MSG_CHANNEL_DATA);
  171.                 packet_put_int(c->remote_id);
  172.                 packet_put_string(buffer_ptr(&c->input), len);
  173. -               packet_send();
  174. +               packet_length = packet_send();
  175.                 buffer_consume(&c->input, len);
  176.                 c->remote_window -= len;
  177.             }
  178. @@ -2254,12 +2294,13 @@ channel_output_poll(void)
  179.             packet_put_int(c->remote_id);
  180.             packet_put_int(SSH2_EXTENDED_DATA_STDERR);
  181.             packet_put_string(buffer_ptr(&c->extended), len);
  182. -           packet_send();
  183. +           packet_length = packet_send();
  184.             buffer_consume(&c->extended, len);
  185.             c->remote_window -= len;
  186.             debug2("channel %d: sent ext data %d", c->self, len);
  187.         }
  188.     }
  189. +   return (packet_length);
  190.  }
  191.  
  192.  
  193. @@ -2683,6 +2724,14 @@ channel_fwd_bind_addr(const char *listen
  194.     return addr;
  195.  }
  196.  
  197. +void
  198. +channel_set_hpn(int external_hpn_disabled, int external_hpn_buffer_size)
  199. +{
  200. +       hpn_disabled = external_hpn_disabled;
  201. +   hpn_buffer_size = external_hpn_buffer_size;
  202. +   debug("HPN Disabled: %d, HPN Buffer Size: %d", hpn_disabled, hpn_buffer_size);
  203. +}
  204. +
  205.  static int
  206.  channel_setup_fwd_listener(int type, const char *listen_addr,
  207.      u_short listen_port, int *allocated_listen_port,
  208. @@ -2809,9 +2858,15 @@ channel_setup_fwd_listener(int type, con
  209.         }
  210.  
  211.         /* Allocate a channel number for the socket. */
  212. +       /* explicitly test for hpn disabled option. if true use smaller window size */
  213. +       if (hpn_disabled)
  214.         c = channel_new("port listener", type, sock, sock, -1,
  215.             CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
  216.             0, "port listener", 1);
  217. +       else
  218. +           c = channel_new("port listener", type, sock, sock, -1,
  219. +                 hpn_buffer_size, CHAN_TCP_PACKET_DEFAULT,
  220. +                 0, "port listener", 1);
  221.         c->path = xstrdup(host);
  222.         c->host_port = port_to_connect;
  223.         c->listening_addr = addr == NULL ? NULL : xstrdup(addr);
  224. @@ -3456,10 +3511,17 @@ x11_create_display_inet(int x11_display_
  225.     *chanids = xcalloc(num_socks + 1, sizeof(**chanids));
  226.     for (n = 0; n < num_socks; n++) {
  227.         sock = socks[n];
  228. +       /* Is this really necassary? */
  229. +       if (hpn_disabled)
  230.         nc = channel_new("x11 listener",
  231.             SSH_CHANNEL_X11_LISTENER, sock, sock, -1,
  232.             CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT,
  233.             0, "X11 inet listener", 1);
  234. +       else
  235. +           nc = channel_new("x11 listener",
  236. +               SSH_CHANNEL_X11_LISTENER, sock, sock, -1,
  237. +               hpn_buffer_size, CHAN_X11_PACKET_DEFAULT,
  238. +               0, "X11 inet listener", 1);
  239.         nc->single_connection = single_connection;
  240.         (*chanids)[n] = nc->self;
  241.     }
  242. diff -NupwB canonical/channels.h kitchen/channels.h
  243. --- canonical/channels.h    2011-10-02 03:59:03.000000000 -0400
  244. +++ kitchen/channels.h  2012-11-07 15:28:16.000000000 -0500
  245. @@ -126,10 +126,12 @@ struct Channel {
  246.     u_int   remote_maxpacket;
  247.     u_int   local_window;
  248.     u_int   local_window_max;
  249. +   int dynamic_window;
  250.     u_int   local_consumed;
  251.     u_int   local_maxpacket;
  252.     int     extended_usage;
  253.     int single_connection;
  254. +   u_int   tcpwinsz;
  255.  
  256.     char   *ctype;      /* type */
  257.  
  258. @@ -164,9 +166,11 @@ struct Channel {
  259.  
  260.  /* default window/packet sizes for tcp/x11-fwd-channel */
  261.  #define CHAN_SES_PACKET_DEFAULT    (32*1024)
  262. -#define CHAN_SES_WINDOW_DEFAULT    (64*CHAN_SES_PACKET_DEFAULT)
  263. +#define CHAN_SES_WINDOW_DEFAULT    (4*CHAN_SES_PACKET_DEFAULT)
  264. +
  265.  #define CHAN_TCP_PACKET_DEFAULT    (32*1024)
  266. -#define CHAN_TCP_WINDOW_DEFAULT    (64*CHAN_TCP_PACKET_DEFAULT)
  267. +#define CHAN_TCP_WINDOW_DEFAULT    (4*CHAN_TCP_PACKET_DEFAULT)
  268. +
  269.  #define CHAN_X11_PACKET_DEFAULT    (16*1024)
  270.  #define CHAN_X11_WINDOW_DEFAULT    (4*CHAN_X11_PACKET_DEFAULT)
  271.  
  272. @@ -240,7 +244,7 @@ void     channel_input_status_confirm(int,
  273.  
  274.  void    channel_prepare_select(fd_set **, fd_set **, int *, u_int*, int);
  275.  void     channel_after_select(fd_set *, fd_set *);
  276. -void     channel_output_poll(void);
  277. +int      channel_output_poll(void);
  278.  
  279.  int      channel_not_very_much_buffered_data(void);
  280.  void     channel_close_all(void);
  281. @@ -300,4 +304,8 @@ void     chan_rcvd_ieof(Channel *);
  282.  void    chan_write_failed(Channel *);
  283.  void    chan_obuf_empty(Channel *);
  284.  
  285. +/* hpn handler */
  286. +void     channel_set_hpn(int, int);
  287. +
  288. +
  289.  #endif
  290. diff -NupwB canonical/cipher.c kitchen/cipher.c
  291. --- canonical/cipher.c  2009-01-28 00:38:41.000000000 -0500
  292. +++ kitchen/cipher.c    2012-11-07 15:28:16.000000000 -0500
  293. @@ -55,6 +55,7 @@ extern const EVP_CIPHER *evp_ssh1_bf(voi
  294.  extern const EVP_CIPHER *evp_ssh1_3des(void);
  295.  extern void ssh1_3des_iv(EVP_CIPHER_CTX *, int, u_char *, int);
  296.  extern const EVP_CIPHER *evp_aes_128_ctr(void);
  297. +extern const EVP_CIPHER *evp_aes_ctr_mt(void);
  298.  extern void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
  299.  
  300.  struct Cipher {
  301. @@ -82,9 +83,9 @@ struct Cipher {
  302.     { "aes256-cbc",     SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc },
  303.                 SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc },
  304. -   { "aes128-ctr",     SSH_CIPHER_SSH2, 16, 16, 0, 0, evp_aes_128_ctr },
  305. -   { "aes192-ctr",     SSH_CIPHER_SSH2, 16, 24, 0, 0, evp_aes_128_ctr },
  306. -   { "aes256-ctr",     SSH_CIPHER_SSH2, 16, 32, 0, 0, evp_aes_128_ctr },
  307. +   { "aes128-ctr",     SSH_CIPHER_SSH2, 16, 16, 0, 0, evp_aes_ctr_mt },
  308. +   { "aes192-ctr",     SSH_CIPHER_SSH2, 16, 24, 0, 0, evp_aes_ctr_mt },
  309. +   { "aes256-ctr",     SSH_CIPHER_SSH2, 16, 32, 0, 0, evp_aes_ctr_mt },
  310.  #ifdef USE_CIPHER_ACSS
  311.     { "[email protected]",   SSH_CIPHER_SSH2, 16, 5, 0, 0, EVP_acss },
  312.  #endif
  313. @@ -163,7 +164,7 @@ ciphers_valid(const char *names)
  314.     for ((p = strsep(&cp, CIPHER_SEP)); p && *p != '\0';
  315.         (p = strsep(&cp, CIPHER_SEP))) {
  316.         c = cipher_by_name(p);
  317. -       if (c == NULL || c->number != SSH_CIPHER_SSH2) {
  318. +       if (c == NULL || (c->number != SSH_CIPHER_SSH2 && c->number != SSH_CIPHER_NONE)) {
  319.             debug("bad cipher %s [%s]", p, names);
  320.             xfree(cipher_list);
  321.             return 0;
  322. @@ -337,6 +338,7 @@ cipher_get_keyiv(CipherContext *cc, u_ch
  323.     int evplen;
  324.  
  325.     switch (c->number) {
  326. +   case SSH_CIPHER_NONE:
  327.     case SSH_CIPHER_SSH2:
  328.     case SSH_CIPHER_DES:
  329.     case SSH_CIPHER_BLOWFISH:
  330. @@ -371,6 +373,7 @@ cipher_set_keyiv(CipherContext *cc, u_ch
  331.     int evplen = 0;
  332.  
  333.     switch (c->number) {
  334. +   case SSH_CIPHER_NONE:
  335.     case SSH_CIPHER_SSH2:
  336.     case SSH_CIPHER_DES:
  337.     case SSH_CIPHER_BLOWFISH:
  338. diff -NupwB canonical/cipher-ctr-mt.c kitchen/cipher-ctr-mt.c
  339. --- canonical/cipher-ctr-mt.c   1969-12-31 19:00:00.000000000 -0500
  340. +++ kitchen/cipher-ctr-mt.c 2012-11-07 15:28:16.000000000 -0500
  341. @@ -0,0 +1,473 @@
  342. +/*
  343. + * OpenSSH Multi-threaded AES-CTR Cipher
  344. + *
  345. + * Author: Benjamin Bennett <[email protected]>
  346. + * Copyright (c) 2008 Pittsburgh Supercomputing Center. All rights reserved.
  347. + *
  348. + * Based on original OpenSSH AES-CTR cipher. Small portions remain unchanged,
  349. + * Copyright (c) 2003 Markus Friedl <[email protected]>
  350. + *
  351. + * Permission to use, copy, modify, and distribute this software for any
  352. + * purpose with or without fee is hereby granted, provided that the above
  353. + * copyright notice and this permission notice appear in all copies.
  354. + *
  355. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  356. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  357. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  358. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  359. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  360. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  361. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  362. + */
  363. +#include "includes.h"
  364. +
  365. +#include <sys/types.h>
  366. +
  367. +#include <stdarg.h>
  368. +#include <string.h>
  369. +
  370. +#include <openssl/evp.h>
  371. +
  372. +#include "xmalloc.h"
  373. +#include "log.h"
  374. +
  375. +/* compatibility with old or broken OpenSSL versions */
  376. +#include "openbsd-compat/openssl-compat.h"
  377. +
  378. +#ifndef USE_BUILTIN_RIJNDAEL
  379. +#include <openssl/aes.h>
  380. +#endif
  381. +
  382. +#include <pthread.h>
  383. +
  384. +/*-------------------- TUNABLES --------------------*/
  385. +/* Number of pregen threads to use */
  386. +#define CIPHER_THREADS 2
  387. +
  388. +/* Number of keystream queues */
  389. +#define NUMKQ      (CIPHER_THREADS + 2)
  390. +
  391. +/* Length of a keystream queue */
  392. +#define KQLEN      4096
  393. +
  394. +/* Processor cacheline length */
  395. +#define CACHELINE_LEN  64
  396. +
  397. +/* Collect thread stats and print at cancellation when in debug mode */
  398. +/* #define CIPHER_THREAD_STATS */
  399. +
  400. +/* Use single-byte XOR instead of 8-byte XOR */
  401. +/* #define CIPHER_BYTE_XOR */
  402. +/*-------------------- END TUNABLES --------------------*/
  403. +
  404. +
  405. +const EVP_CIPHER *evp_aes_ctr_mt(void);
  406. +
  407. +#ifdef CIPHER_THREAD_STATS
  408. +/*
  409. + * Struct to collect thread stats
  410. + */
  411. +struct thread_stats {
  412. +   u_int   fills;
  413. +   u_int   skips;
  414. +   u_int   waits;
  415. +   u_int   drains;
  416. +};
  417. +
  418. +/*
  419. + * Debug print the thread stats
  420. + * Use with pthread_cleanup_push for displaying at thread cancellation
  421. + */
  422. +static void
  423. +thread_loop_stats(void *x)
  424. +{
  425. +   struct thread_stats *s = x;
  426. +
  427. +   debug("tid %lu - %u fills, %u skips, %u waits", pthread_self(),
  428. +           s->fills, s->skips, s->waits);
  429. +}
  430. +
  431. + #define STATS_STRUCT(s)   struct thread_stats s
  432. + #define STATS_INIT(s)     { memset(&s, 0, sizeof(s)); }
  433. + #define STATS_FILL(s)     { s.fills++; }
  434. + #define STATS_SKIP(s)     { s.skips++; }
  435. + #define STATS_WAIT(s)     { s.waits++; }
  436. + #define STATS_DRAIN(s)        { s.drains++; }
  437. +#else
  438. + #define STATS_STRUCT(s)
  439. + #define STATS_INIT(s)
  440. + #define STATS_FILL(s)
  441. + #define STATS_SKIP(s)
  442. + #define STATS_WAIT(s)
  443. + #define STATS_DRAIN(s)
  444. +#endif
  445. +
  446. +/* Keystream Queue state */
  447. +enum {
  448. +   KQINIT,
  449. +   KQEMPTY,
  450. +   KQFILLING,
  451. +   KQFULL,
  452. +   KQDRAINING
  453. +};
  454. +
  455. +/* Keystream Queue struct */
  456. +struct kq {
  457. +   u_char      keys[KQLEN][AES_BLOCK_SIZE];
  458. +   u_char      ctr[AES_BLOCK_SIZE];
  459. +   u_char      pad0[CACHELINE_LEN];
  460. +   volatile int    qstate;
  461. +   pthread_mutex_t lock;
  462. +   pthread_cond_t  cond;
  463. +   u_char      pad1[CACHELINE_LEN];
  464. +};
  465. +
  466. +/* Context struct */
  467. +struct ssh_aes_ctr_ctx
  468. +{
  469. +   struct kq   q[NUMKQ];
  470. +   AES_KEY     aes_ctx;
  471. +   STATS_STRUCT(stats);
  472. +   u_char      aes_counter[AES_BLOCK_SIZE];
  473. +   pthread_t   tid[CIPHER_THREADS];
  474. +   int     state;
  475. +   int     qidx;
  476. +   int     ridx;
  477. +};
  478. +
  479. +/* <friedl>
  480. + * increment counter 'ctr',
  481. + * the counter is of size 'len' bytes and stored in network-byte-order.
  482. + * (LSB at ctr[len-1], MSB at ctr[0])
  483. + */
  484. +static void
  485. +ssh_ctr_inc(u_char *ctr, u_int len)
  486. +{
  487. +   int i;
  488. +
  489. +   for (i = len - 1; i >= 0; i--)
  490. +       if (++ctr[i])   /* continue on overflow */
  491. +           return;
  492. +}
  493. +
  494. +/*
  495. + * Add num to counter 'ctr'
  496. + */
  497. +static void
  498. +ssh_ctr_add(u_char *ctr, uint32_t num, u_int len)
  499. +{
  500. +   int i;
  501. +   uint16_t n;
  502. +
  503. +   for (n = 0, i = len - 1; i >= 0 && (num || n); i--) {
  504. +       n = ctr[i] + (num & 0xff) + n;
  505. +       num >>= 8;
  506. +       ctr[i] = n & 0xff;
  507. +       n >>= 8;
  508. +   }
  509. +}
  510. +
  511. +/*
  512. + * Threads may be cancelled in a pthread_cond_wait, we must free the mutex
  513. + */
  514. +static void
  515. +thread_loop_cleanup(void *x)
  516. +{
  517. +   pthread_mutex_unlock((pthread_mutex_t *)x);
  518. +}
  519. +
  520. +/*
  521. + * The life of a pregen thread:
  522. + *    Find empty keystream queues and fill them using their counter.
  523. + *    When done, update counter for the next fill.
  524. + */
  525. +static void *
  526. +thread_loop(void *x)
  527. +{
  528. +   AES_KEY key;
  529. +   STATS_STRUCT(stats);
  530. +   struct ssh_aes_ctr_ctx *c = x;
  531. +   struct kq *q;
  532. +   int i;
  533. +   int qidx;
  534. +
  535. +   /* Threads stats on cancellation */
  536. +   STATS_INIT(stats);
  537. +#ifdef CIPHER_THREAD_STATS
  538. +   pthread_cleanup_push(thread_loop_stats, &stats);
  539. +#endif
  540. +
  541. +   /* Thread local copy of AES key */
  542. +   memcpy(&key, &c->aes_ctx, sizeof(key));
  543. +
  544. +   /*
  545. +    * Handle the special case of startup, one thread must fill
  546. +    * the first KQ then mark it as draining. Lock held throughout.
  547. +    */
  548. +   if (pthread_equal(pthread_self(), c->tid[0])) {
  549. +       q = &c->q[0];
  550. +       pthread_mutex_lock(&q->lock);
  551. +       if (q->qstate == KQINIT) {
  552. +           for (i = 0; i < KQLEN; i++) {
  553. +               AES_encrypt(q->ctr, q->keys[i], &key);
  554. +               ssh_ctr_inc(q->ctr, AES_BLOCK_SIZE);
  555. +           }
  556. +           ssh_ctr_add(q->ctr, KQLEN * (NUMKQ - 1), AES_BLOCK_SIZE);
  557. +           q->qstate = KQDRAINING;
  558. +           STATS_FILL(stats);
  559. +           pthread_cond_broadcast(&q->cond);
  560. +       }
  561. +       pthread_mutex_unlock(&q->lock);
  562. +   }
  563. +   else
  564. +       STATS_SKIP(stats);
  565. +
  566. +   /*
  567. +    * Normal case is to find empty queues and fill them, skipping over
  568. +    * queues already filled by other threads and stopping to wait for
  569. +    * a draining queue to become empty.
  570. +    *
  571. +    * Multiple threads may be waiting on a draining queue and awoken
  572. +    * when empty.  The first thread to wake will mark it as filling,
  573. +    * others will move on to fill, skip, or wait on the next queue.
  574. +    */
  575. +   for (qidx = 1;; qidx = (qidx + 1) % NUMKQ) {
  576. +       /* Check if I was cancelled, also checked in cond_wait */
  577. +       pthread_testcancel();
  578. +
  579. +       /* Lock queue and block if its draining */
  580. +       q = &c->q[qidx];
  581. +       pthread_mutex_lock(&q->lock);
  582. +       pthread_cleanup_push(thread_loop_cleanup, &q->lock);
  583. +       while (q->qstate == KQDRAINING || q->qstate == KQINIT) {
  584. +           STATS_WAIT(stats);
  585. +           pthread_cond_wait(&q->cond, &q->lock);
  586. +       }
  587. +       pthread_cleanup_pop(0);
  588. +
  589. +       /* If filling or full, somebody else got it, skip */
  590. +       if (q->qstate != KQEMPTY) {
  591. +           pthread_mutex_unlock(&q->lock);
  592. +           STATS_SKIP(stats);
  593. +           continue;
  594. +       }
  595. +
  596. +       /*
  597. +        * Empty, let's fill it.
  598. +        * Queue lock is relinquished while we do this so others
  599. +        * can see that it's being filled.
  600. +        */
  601. +       q->qstate = KQFILLING;
  602. +       pthread_mutex_unlock(&q->lock);
  603. +       for (i = 0; i < KQLEN; i++) {
  604. +           AES_encrypt(q->ctr, q->keys[i], &key);
  605. +           ssh_ctr_inc(q->ctr, AES_BLOCK_SIZE);
  606. +       }
  607. +
  608. +       /* Re-lock, mark full and signal consumer */
  609. +       pthread_mutex_lock(&q->lock);
  610. +       ssh_ctr_add(q->ctr, KQLEN * (NUMKQ - 1), AES_BLOCK_SIZE);
  611. +       q->qstate = KQFULL;
  612. +       STATS_FILL(stats);
  613. +       pthread_cond_signal(&q->cond);
  614. +       pthread_mutex_unlock(&q->lock);
  615. +   }
  616. +
  617. +#ifdef CIPHER_THREAD_STATS
  618. +   /* Stats */
  619. +   pthread_cleanup_pop(1);
  620. +#endif
  621. +
  622. +   return NULL;
  623. +}
  624. +
  625. +static int
  626. +ssh_aes_ctr(EVP_CIPHER_CTX *ctx, u_char *dest, const u_char *src,
  627. +    u_int len)
  628. +{
  629. +   struct ssh_aes_ctr_ctx *c;
  630. +   struct kq *q, *oldq;
  631. +   int ridx;
  632. +   u_char *buf;
  633. +
  634. +   if (len == 0)
  635. +       return (1);
  636. +   if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) == NULL)
  637. +       return (0);
  638. +
  639. +   q = &c->q[c->qidx];
  640. +   ridx = c->ridx;
  641. +
  642. +   /* src already padded to block multiple */
  643. +   while (len > 0) {
  644. +       buf = q->keys[ridx];
  645. +
  646. +#ifdef CIPHER_BYTE_XOR
  647. +       dest[0] = src[0] ^ buf[0];
  648. +       dest[1] = src[1] ^ buf[1];
  649. +       dest[2] = src[2] ^ buf[2];
  650. +       dest[3] = src[3] ^ buf[3];
  651. +       dest[4] = src[4] ^ buf[4];
  652. +       dest[5] = src[5] ^ buf[5];
  653. +       dest[6] = src[6] ^ buf[6];
  654. +       dest[7] = src[7] ^ buf[7];
  655. +       dest[8] = src[8] ^ buf[8];
  656. +       dest[9] = src[9] ^ buf[9];
  657. +       dest[10] = src[10] ^ buf[10];
  658. +       dest[11] = src[11] ^ buf[11];
  659. +       dest[12] = src[12] ^ buf[12];
  660. +       dest[13] = src[13] ^ buf[13];
  661. +       dest[14] = src[14] ^ buf[14];
  662. +       dest[15] = src[15] ^ buf[15];
  663. +#else
  664. +       *(uint64_t *)dest = *(uint64_t *)src ^ *(uint64_t *)buf;
  665. +       *(uint64_t *)(dest + 8) = *(uint64_t *)(src + 8) ^
  666. +                       *(uint64_t *)(buf + 8);
  667. +#endif
  668. +
  669. +       dest += 16;
  670. +       src += 16;
  671. +       len -= 16;
  672. +       ssh_ctr_inc(ctx->iv, AES_BLOCK_SIZE);
  673. +
  674. +       /* Increment read index, switch queues on rollover */
  675. +       if ((ridx = (ridx + 1) % KQLEN) == 0) {
  676. +           oldq = q;
  677. +
  678. +           /* Mark next queue draining, may need to wait */
  679. +           c->qidx = (c->qidx + 1) % NUMKQ;
  680. +           q = &c->q[c->qidx];
  681. +           pthread_mutex_lock(&q->lock);
  682. +           while (q->qstate != KQFULL) {
  683. +               STATS_WAIT(c->stats);
  684. +               pthread_cond_wait(&q->cond, &q->lock);
  685. +           }
  686. +           q->qstate = KQDRAINING;
  687. +           pthread_mutex_unlock(&q->lock);
  688. +
  689. +           /* Mark consumed queue empty and signal producers */
  690. +           pthread_mutex_lock(&oldq->lock);
  691. +           oldq->qstate = KQEMPTY;
  692. +           STATS_DRAIN(c->stats);
  693. +           pthread_cond_broadcast(&oldq->cond);
  694. +           pthread_mutex_unlock(&oldq->lock);
  695. +       }
  696. +   }
  697. +   c->ridx = ridx;
  698. +   return (1);
  699. +}
  700. +
  701. +#define HAVE_NONE       0
  702. +#define HAVE_KEY        1
  703. +#define HAVE_IV         2
  704. +static int
  705. +ssh_aes_ctr_init(EVP_CIPHER_CTX *ctx, const u_char *key, const u_char *iv,
  706. +    int enc)
  707. +{
  708. +   struct ssh_aes_ctr_ctx *c;
  709. +   int i;
  710. +
  711. +   if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) == NULL) {
  712. +       c = xmalloc(sizeof(*c));
  713. +
  714. +       c->state = HAVE_NONE;
  715. +       for (i = 0; i < NUMKQ; i++) {
  716. +           pthread_mutex_init(&c->q[i].lock, NULL);
  717. +           pthread_cond_init(&c->q[i].cond, NULL);
  718. +       }
  719. +
  720. +       STATS_INIT(c->stats);
  721. +      
  722. +       EVP_CIPHER_CTX_set_app_data(ctx, c);
  723. +   }
  724. +
  725. +   if (c->state == (HAVE_KEY | HAVE_IV)) {
  726. +       /* Cancel pregen threads */
  727. +       for (i = 0; i < CIPHER_THREADS; i++)
  728. +           pthread_cancel(c->tid[i]);
  729. +       for (i = 0; i < CIPHER_THREADS; i++)
  730. +           pthread_join(c->tid[i], NULL);
  731. +       /* Start over getting key & iv */
  732. +       c->state = HAVE_NONE;
  733. +   }
  734. +
  735. +   if (key != NULL) {
  736. +       AES_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 8,
  737. +           &c->aes_ctx);
  738. +       c->state |= HAVE_KEY;
  739. +   }
  740. +
  741. +   if (iv != NULL) {
  742. +       memcpy(ctx->iv, iv, AES_BLOCK_SIZE);
  743. +       c->state |= HAVE_IV;
  744. +   }
  745. +
  746. +   if (c->state == (HAVE_KEY | HAVE_IV)) {
  747. +       /* Clear queues */
  748. +       memcpy(c->q[0].ctr, ctx->iv, AES_BLOCK_SIZE);
  749. +       c->q[0].qstate = KQINIT;
  750. +       for (i = 1; i < NUMKQ; i++) {
  751. +           memcpy(c->q[i].ctr, ctx->iv, AES_BLOCK_SIZE);
  752. +           ssh_ctr_add(c->q[i].ctr, i * KQLEN, AES_BLOCK_SIZE);
  753. +           c->q[i].qstate = KQEMPTY;
  754. +       }
  755. +       c->qidx = 0;
  756. +       c->ridx = 0;
  757. +
  758. +       /* Start threads */
  759. +       for (i = 0; i < CIPHER_THREADS; i++) {
  760. +           pthread_create(&c->tid[i], NULL, thread_loop, c);
  761. +       }
  762. +       pthread_mutex_lock(&c->q[0].lock);
  763. +       while (c->q[0].qstate != KQDRAINING)
  764. +           pthread_cond_wait(&c->q[0].cond, &c->q[0].lock);
  765. +       pthread_mutex_unlock(&c->q[0].lock);
  766. +      
  767. +   }
  768. +   return (1);
  769. +}
  770. +
  771. +static int
  772. +ssh_aes_ctr_cleanup(EVP_CIPHER_CTX *ctx)
  773. +{
  774. +   struct ssh_aes_ctr_ctx *c;
  775. +   int i;
  776. +
  777. +   if ((c = EVP_CIPHER_CTX_get_app_data(ctx)) != NULL) {
  778. +#ifdef CIPHER_THREAD_STATS
  779. +       debug("main thread: %u drains, %u waits", c->stats.drains,
  780. +               c->stats.waits);
  781. +#endif
  782. +       /* Cancel pregen threads */
  783. +       for (i = 0; i < CIPHER_THREADS; i++)
  784. +           pthread_cancel(c->tid[i]);
  785. +       for (i = 0; i < CIPHER_THREADS; i++)
  786. +           pthread_join(c->tid[i], NULL);
  787. +
  788. +       memset(c, 0, sizeof(*c));
  789. +       xfree(c);
  790. +       EVP_CIPHER_CTX_set_app_data(ctx, NULL);
  791. +   }
  792. +   return (1);
  793. +}
  794. +
  795. +/* <friedl> */
  796. +const EVP_CIPHER *
  797. +evp_aes_ctr_mt(void)
  798. +{
  799. +   static EVP_CIPHER aes_ctr;
  800. +
  801. +   memset(&aes_ctr, 0, sizeof(EVP_CIPHER));
  802. +   aes_ctr.nid = NID_undef;
  803. +   aes_ctr.block_size = AES_BLOCK_SIZE;
  804. +   aes_ctr.iv_len = AES_BLOCK_SIZE;
  805. +   aes_ctr.key_len = 16;
  806. +   aes_ctr.init = ssh_aes_ctr_init;
  807. +   aes_ctr.cleanup = ssh_aes_ctr_cleanup;
  808. +   aes_ctr.do_cipher = ssh_aes_ctr;
  809. +#ifndef SSH_OLD_EVP
  810. +   aes_ctr.flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH |
  811. +       EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CUSTOM_IV;
  812. +#endif
  813. +   return (&aes_ctr);
  814. +}
  815. diff -NupwB canonical/clientloop.c kitchen/clientloop.c
  816. --- canonical/clientloop.c  2012-02-10 16:18:17.000000000 -0500
  817. +++ kitchen/clientloop.c    2012-11-07 15:28:16.000000000 -0500
  818. @@ -1825,9 +1825,15 @@ client_request_x11(const char *request_t
  819.     sock = x11_connect_display();
  820.     if (sock < 0)
  821.         return NULL;
  822. +   /* again is this really necessary for X11? */
  823. +   if (options.hpn_disabled)
  824.     c = channel_new("x11",
  825.         SSH_CHANNEL_X11_OPEN, sock, sock, -1,
  826.         CHAN_TCP_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0, "x11", 1);
  827. +   else
  828. +       c = channel_new("x11",
  829. +           SSH_CHANNEL_X11_OPEN, sock, sock, -1,
  830. +           options.hpn_buffer_size, CHAN_X11_PACKET_DEFAULT, 0, "x11", 1);
  831.     c->force_drain = 1;
  832.     return c;
  833.  }
  834. @@ -1879,6 +1885,14 @@ client_request_tun_fwd(int tun_mode, int
  835.  
  836.     c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1,
  837.         CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1);
  838. +   if(options.hpn_disabled)
  839. +   c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1,
  840. +               CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
  841. +               0, "tun", 1);
  842. +   else
  843. +   c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1,
  844. +               options.hpn_buffer_size, CHAN_TCP_PACKET_DEFAULT,
  845. +               0, "tun", 1);
  846.     c->datagram = 1;
  847.  
  848.  #if defined(SSH_TUN_FILTER)
  849. diff -NupwB canonical/compat.c kitchen/compat.c
  850. --- canonical/compat.c  2011-10-02 03:59:03.000000000 -0400
  851. +++ kitchen/compat.c    2012-11-07 15:28:16.000000000 -0500
  852. @@ -171,6 +171,15 @@ compat_datafellows(const char *version)
  853.             strlen(check[i].pat), 0) == 1) {
  854.             debug("match: %s pat %s", version, check[i].pat);
  855.             datafellows = check[i].bugs;
  856. +           /* Check to see if the remote side is OpenSSH and not HPN */
  857. +           if(strstr(version,"OpenSSH") != NULL)
  858. +           {
  859. +               if (strstr(version,"hpn") == NULL)
  860. +               {
  861. +                   datafellows |= SSH_BUG_LARGEWINDOW;
  862. +                   debug("Remote is NON-HPN aware");
  863. +               }
  864. +           }
  865.             return;
  866.         }
  867.     }
  868. diff -NupwB canonical/compat.h kitchen/compat.h
  869. --- canonical/compat.h  2011-10-02 03:59:03.000000000 -0400
  870. +++ kitchen/compat.h    2012-11-07 15:29:51.000000000 -0500
  871. @@ -59,6 +59,7 @@
  872.  #define SSH_BUG_RFWD_ADDR  0x02000000
  873.  #define SSH_NEW_OPENSSH        0x04000000
  874.  #define SSH_BUG_DYNAMIC_RPORT  0x08000000
  875. +#define SSH_BUG_LARGEWINDOW     0x10000000
  876.  
  877.  void     enable_compat13(void);
  878.  void     enable_compat20(void);
  879. Common subdirectories: canonical/contrib and kitchen/contrib
  880. diff -NupwB canonical/kex.c kitchen/kex.c
  881. --- canonical/kex.c 2010-09-24 08:11:14.000000000 -0400
  882. +++ kitchen/kex.c   2012-11-07 15:28:16.000000000 -0500
  883. @@ -49,6 +49,7 @@
  884.  #include "dispatch.h"
  885.  #include "monitor.h"
  886.  #include "roaming.h"
  887. +#include "canohost.h"
  888.  
  889.  #if OPENSSL_VERSION_NUMBER >= 0x00907000L
  890.  # if defined(HAVE_EVP_SHA256)
  891. @@ -91,7 +92,8 @@ kex_names_valid(const char *names)
  892.  }
  893.  
  894.  /* put algorithm proposal into buffer */
  895. -static void
  896. +/* used in sshconnect.c as well as kex.c */
  897. +void
  898.  kex_prop2buf(Buffer *b, char *proposal[PROPOSAL_MAX])
  899.  {
  900.     u_int i;
  901. @@ -408,6 +410,14 @@ kex_choose_conf(Kex *kex)
  902.     u_int mode, ctos, need;
  903.     int first_kex_follows, type;
  904.  
  905. +   int log_flag = 0;
  906. +
  907. +   int auth_flag;
  908. +
  909. +   auth_flag = packet_authentication_state();
  910. +
  911. +   debug ("AUTH STATE IS %d", auth_flag);
  912. +
  913.     my   = kex_buf2prop(&kex->my, NULL);
  914.     peer = kex_buf2prop(&kex->peer, &first_kex_follows);
  915.  
  916. @@ -441,11 +451,34 @@ kex_choose_conf(Kex *kex)
  917.         choose_enc (&newkeys->enc,  cprop[nenc],  sprop[nenc]);
  918.         choose_mac (&newkeys->mac,  cprop[nmac],  sprop[nmac]);
  919.         choose_comp(&newkeys->comp, cprop[ncomp], sprop[ncomp]);
  920. +       debug("REQUESTED ENC.NAME is '%s'", newkeys->enc.name);
  921. +       if (strcmp(newkeys->enc.name, "none") == 0) {
  922. +               debug("Requesting NONE. Authflag is %d", auth_flag);           
  923. +           if (auth_flag == 1) {
  924. +               debug("None requested post authentication.");
  925. +           } else {
  926. +               fatal("Pre-authentication none cipher requests are not allowed.");
  927. +           }
  928. +       }
  929.         debug("kex: %s %s %s %s",
  930.             ctos ? "client->server" : "server->client",
  931.             newkeys->enc.name,
  932.             newkeys->mac.name,
  933.             newkeys->comp.name);
  934. +       /* client starts withctos = 0 && log flag = 0 and no log*/
  935. +       /* 2nd client pass ctos=1 and flag = 1 so no log*/
  936. +       /* server starts with ctos =1 && log_flag = 0 so log */
  937. +       /* 2nd sever pass ctos = 1 && log flag = 1 so no log*/
  938. +       /* -cjr*/
  939. +       if (ctos && !log_flag) {
  940. +           logit("SSH: Server;Ltype: Kex;Remote: %s-%d;Enc: %s;MAC: %s;Comp: %s",
  941. +                 get_remote_ipaddr(),
  942. +                 get_remote_port(),
  943. +                 newkeys->enc.name,
  944. +                 newkeys->mac.name,
  945. +                 newkeys->comp.name);
  946. +       }
  947. +       log_flag = 1;
  948.     }
  949.     choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]);
  950.     choose_hostkeyalg(kex, cprop[PROPOSAL_SERVER_HOST_KEY_ALGS],
  951. diff -NupwB canonical/kex.h kitchen/kex.h
  952. --- canonical/kex.h 2010-09-24 08:11:14.000000000 -0400
  953. +++ kitchen/kex.h   2012-11-07 15:28:16.000000000 -0500
  954. @@ -138,6 +138,8 @@ struct Kex {
  955.     void    (*kex[KEX_MAX])(Kex *);
  956.  };
  957.  
  958. +void kex_prop2buf(Buffer *, char *proposal[PROPOSAL_MAX]);
  959. +
  960.  int     kex_names_valid(const char *);
  961.  
  962.  Kex    *kex_setup(char *[PROPOSAL_MAX]);
  963. diff -NupwB canonical/Makefile.in kitchen/Makefile.in
  964. --- canonical/Makefile.in   2012-04-03 21:27:57.000000000 -0400
  965. +++ kitchen/Makefile.in 2012-11-07 15:28:16.000000000 -0500
  966. @@ -43,7 +43,7 @@ CC=@CC@
  967.  LD=@LD@
  968.  CFLAGS=@CFLAGS@
  969.  CPPFLAGS=-I. -I$(srcdir) @CPPFLAGS@ $(PATHS) @DEFS@
  970. -LIBS=@LIBS@
  971. +LIBS=@LIBS@ -lpthread
  972.  SSHLIBS=@SSHLIBS@
  973.  SSHDLIBS=@SSHDLIBS@
  974.  LIBEDIT=@LIBEDIT@
  975. @@ -63,7 +63,7 @@ TARGETS=ssh$(EXEEXT) sshd$(EXEEXT) ssh-a
  976.  
  977.  LIBSSH_OBJS=acss.o authfd.o authfile.o bufaux.o bufbn.o buffer.o \
  978.     canohost.o channels.o cipher.o cipher-acss.o cipher-aes.o \
  979. -   cipher-bf1.o cipher-ctr.o cipher-3des1.o cleanup.o \
  980. +   cipher-bf1.o cipher-ctr.o cipher-ctr-mt.o cipher-3des1.o cleanup.o \
  981.     compat.o compress.o crc32.o deattack.o fatal.o hostfile.o \
  982.     log.o match.o md-sha256.o moduli.o nchan.o packet.o \
  983.     readpass.o rsa.o ttymodes.o xmalloc.o addrmatch.o \
  984. diff -NupwB canonical/myproposal.h kitchen/myproposal.h
  985. --- canonical/myproposal.h  2011-08-16 20:29:03.000000000 -0400
  986. +++ kitchen/myproposal.h    2012-11-07 15:28:16.000000000 -0500
  987. @@ -75,6 +75,8 @@
  988.     "arcfour256,arcfour128," \
  989.     "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc," \
  990.     "aes192-cbc,aes256-cbc,arcfour,[email protected]"
  991. +#define KEX_ENCRYPT_INCLUDE_NONE KEX_DEFAULT_ENCRYPT \
  992. +   ",none"
  993.  #ifdef HAVE_EVP_SHA256
  994.  #define    SHA2_HMAC_MODES \
  995.     "hmac-sha2-256," \
  996. Common subdirectories: canonical/openbsd-compat and kitchen/openbsd-compat
  997. diff -NupwB canonical/packet.c kitchen/packet.c
  998. --- canonical/packet.c  2012-03-08 18:28:07.000000000 -0500
  999. +++ kitchen/packet.c    2012-11-07 15:28:16.000000000 -0500
  1000. @@ -838,7 +838,7 @@ packet_enable_delayed_compress(void)
  1001.  /*
  1002.   * Finalize packet in SSH2 format (compress, mac, encrypt, enqueue)
  1003.   */
  1004. -static void
  1005. +static int
  1006.  packet_send2_wrapped(void)
  1007.  {
  1008.     u_char type, *cp, *macbuf = NULL;
  1009. @@ -957,11 +957,13 @@ packet_send2_wrapped(void)
  1010.         set_newkeys(MODE_OUT);
  1011.     else if (type == SSH2_MSG_USERAUTH_SUCCESS && active_state->server_side)
  1012.         packet_enable_delayed_compress();
  1013. +   return(packet_length);
  1014.  }
  1015.  
  1016. -static void
  1017. +static int
  1018.  packet_send2(void)
  1019.  {
  1020. +   static int packet_length = 0;
  1021.     struct packet *p;
  1022.     u_char type, *cp;
  1023.  
  1024. @@ -981,7 +983,7 @@ packet_send2(void)
  1025.                 sizeof(Buffer));
  1026.             buffer_init(&active_state->outgoing_packet);
  1027.             TAILQ_INSERT_TAIL(&active_state->outgoing, p, next);
  1028. -           return;
  1029. +           return(sizeof(Buffer));
  1030.         }
  1031.     }
  1032.  
  1033. @@ -1002,19 +1004,22 @@ packet_send2(void)
  1034.                 sizeof(Buffer));
  1035.             TAILQ_REMOVE(&active_state->outgoing, p, next);
  1036.             xfree(p);
  1037. -           packet_send2_wrapped();
  1038. +           packet_length += packet_send2_wrapped();
  1039.         }
  1040.     }
  1041. +   return(packet_length);
  1042.  }
  1043.  
  1044. -void
  1045. +int
  1046.  packet_send(void)
  1047.  {
  1048. + int packet_len = 0;
  1049.     if (compat20)
  1050. -       packet_send2();
  1051. +       packet_len = packet_send2();
  1052.     else
  1053.         packet_send1();
  1054.     DBG(debug("packet_send done"));
  1055. +   return(packet_len);
  1056.  }
  1057.  
  1058.  /*
  1059. @@ -1647,12 +1652,14 @@ packet_disconnect(const char *fmt,...)
  1060.  
  1061.  /* Checks if there is any buffered output, and tries to write some of the output. */
  1062.  
  1063. -void
  1064. +int
  1065.  packet_write_poll(void)
  1066.  {
  1067. -   int len = buffer_len(&active_state->output);
  1068. +   int len = 0;
  1069.     int cont;
  1070.  
  1071. +   len = buffer_len(&active_state->output);
  1072. +
  1073.     if (len > 0) {
  1074.         cont = 0;
  1075.         len = roaming_write(active_state->connection_out,
  1076. @@ -1660,13 +1667,14 @@ packet_write_poll(void)
  1077.         if (len == -1) {
  1078.             if (errno == EINTR || errno == EAGAIN ||
  1079.                 errno == EWOULDBLOCK)
  1080. -               return;
  1081. +               return (0);
  1082.             fatal("Write failed: %.100s", strerror(errno));
  1083.         }
  1084.         if (len == 0 && !cont)
  1085.             fatal("Write connection closed");
  1086.         buffer_consume(&active_state->output, len);
  1087.     }
  1088. +   return(len);
  1089.  }
  1090.  
  1091.  /*
  1092. @@ -1867,12 +1875,24 @@ packet_send_ignore(int nbytes)
  1093.     }
  1094.  }
  1095.  
  1096. +int rekey_requested = 0;
  1097. +void
  1098. +packet_request_rekeying(void)
  1099. +{
  1100. +   rekey_requested = 1;
  1101. +}
  1102. +
  1103.  #define MAX_PACKETS    (1U<<31)
  1104.  int
  1105.  packet_need_rekeying(void)
  1106.  {
  1107.     if (datafellows & SSH_BUG_NOREKEY)
  1108.         return 0;
  1109. +   if (rekey_requested == 1)
  1110. +   {
  1111. +       rekey_requested = 0;
  1112. +       return 1;
  1113. +   }
  1114.     return
  1115.         (active_state->p_send.packets > MAX_PACKETS) ||
  1116.         (active_state->p_read.packets > MAX_PACKETS) ||
  1117. @@ -1964,3 +1984,8 @@ packet_restore_state(void)
  1118.         add_recv_bytes(len);
  1119.     }
  1120.  }
  1121. +int
  1122. +packet_authentication_state(void)
  1123. +{
  1124. +   return(active_state->after_authentication);
  1125. +}
  1126. diff -NupwB canonical/packet.h kitchen/packet.h
  1127. --- canonical/packet.h  2012-02-10 16:19:21.000000000 -0500
  1128. +++ kitchen/packet.h    2012-11-07 15:28:16.000000000 -0500
  1129. @@ -19,6 +19,8 @@
  1130.  #include <termios.h>
  1131.  
  1132.  #include <openssl/bn.h>
  1133. +void
  1134. +packet_request_rekeying(void);
  1135.  #ifdef OPENSSL_HAS_ECC
  1136.  #include <openssl/ec.h>
  1137.  #endif
  1138. @@ -38,6 +40,7 @@ void     packet_set_interactive(int, int
  1139.  int      packet_is_interactive(void);
  1140.  void     packet_set_server(void);
  1141.  void     packet_set_authenticated(void);
  1142. +int     packet_authentication_state(void);
  1143.  
  1144.  void     packet_start(u_char);
  1145.  void     packet_put_char(int ch);
  1146. @@ -51,7 +54,7 @@ void     packet_put_ecpoint(const EC_GRO
  1147.  void     packet_put_string(const void *buf, u_int len);
  1148.  void     packet_put_cstring(const char *str);
  1149.  void     packet_put_raw(const void *buf, u_int len);
  1150. -void     packet_send(void);
  1151. +int     packet_send(void);
  1152.  
  1153.  int      packet_read(void);
  1154.  void     packet_read_expect(int type);
  1155. @@ -85,7 +88,7 @@ int    packet_get_ssh1_cipher(void);
  1156.  void    packet_set_iv(int, u_char *);
  1157.  void   *packet_get_newkeys(int);
  1158.  
  1159. -void     packet_write_poll(void);
  1160. +int     packet_write_poll(void);
  1161.  void     packet_write_wait(void);
  1162.  int      packet_have_data_to_write(void);
  1163.  int      packet_not_very_much_data_to_write(void);
  1164. diff -NupwB canonical/progressmeter.c kitchen/progressmeter.c
  1165. --- canonical/progressmeter.c   2006-08-04 22:39:40.000000000 -0400
  1166. +++ kitchen/progressmeter.c 2012-11-07 15:28:16.000000000 -0500
  1167. @@ -68,6 +68,8 @@ static time_t last_update;    /* last progr
  1168.  static char *file;     /* name of the file being transferred */
  1169.  static off_t end_pos;      /* ending position of transfer */
  1170.  static off_t cur_pos;      /* transfer position as of last refresh */
  1171. +static off_t last_pos;
  1172. +static off_t max_delta_pos = 0;
  1173.  static volatile off_t *counter;    /* progress counter */
  1174.  static long stalled;       /* how long we have been stalled */
  1175.  static int bytes_per_second;   /* current speed in bytes per second */
  1176. @@ -128,12 +130,17 @@ refresh_progress_meter(void)
  1177.     int hours, minutes, seconds;
  1178.     int i, len;
  1179.     int file_len;
  1180. +   off_t delta_pos;
  1181.  
  1182.     transferred = *counter - cur_pos;
  1183.     cur_pos = *counter;
  1184.     now = time(NULL);
  1185.     bytes_left = end_pos - cur_pos;
  1186.  
  1187. +   delta_pos = cur_pos - last_pos;
  1188. +   if (delta_pos > max_delta_pos)
  1189. +       max_delta_pos = delta_pos;
  1190. +
  1191.     if (bytes_left > 0)
  1192.         elapsed = now - last_update;
  1193.     else {
  1194. @@ -158,7 +165,7 @@ refresh_progress_meter(void)
  1195.  
  1196.     /* filename */
  1197.     buf[0] = '\0';
  1198. -   file_len = win_size - 35;
  1199. +   file_len = win_size - 45;
  1200.     if (file_len > 0) {
  1201.         len = snprintf(buf, file_len + 1, "\r%s", file);
  1202.         if (len < 0)
  1203. @@ -175,7 +182,7 @@ refresh_progress_meter(void)
  1204.         percent = ((float)cur_pos / end_pos) * 100;
  1205.     else
  1206.         percent = 100;
  1207. -   snprintf(buf + strlen(buf), win_size - strlen(buf),
  1208. +   snprintf(buf + strlen(buf), win_size - strlen(buf-8),
  1209.         " %3d%% ", percent);
  1210.  
  1211.     /* amount transferred */
  1212. @@ -183,6 +190,15 @@ refresh_progress_meter(void)
  1213.         cur_pos);
  1214.     strlcat(buf, " ", win_size);
  1215.  
  1216. +   /* instantaneous rate */
  1217. +   if (bytes_left > 0)
  1218. +       format_rate(buf + strlen(buf), win_size - strlen(buf),
  1219. +               delta_pos);
  1220. +   else
  1221. +       format_rate(buf + strlen(buf), win_size - strlen(buf),
  1222. +               max_delta_pos);
  1223. +   strlcat(buf, "/s ", win_size);
  1224. +
  1225.     /* bandwidth usage */
  1226.     format_rate(buf + strlen(buf), win_size - strlen(buf),
  1227.         (off_t)bytes_per_second);
  1228. @@ -224,6 +240,7 @@ refresh_progress_meter(void)
  1229.  
  1230.     atomicio(vwrite, STDOUT_FILENO, buf, win_size - 1);
  1231.     last_update = now;
  1232. +   last_pos = cur_pos;
  1233.  }
  1234.  
  1235.  /*ARGSUSED*/
  1236. diff -NupwB canonical/readconf.c kitchen/readconf.c
  1237. --- canonical/readconf.c    2011-10-02 03:59:03.000000000 -0400
  1238. +++ kitchen/readconf.c  2012-11-07 15:28:16.000000000 -0500
  1239. @@ -140,6 +140,8 @@ typedef enum {
  1240.     oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
  1241.     oVisualHostKey, oUseRoaming, oZeroKnowledgePasswordAuthentication,
  1242.     oKexAlgorithms, oIPQoS, oRequestTTY,
  1243. +   oNoneEnabled, oTcpRcvBufPoll, oTcpRcvBuf, oNoneSwitch, oHPNDisabled,
  1244. +   oHPNBufferSize,
  1245.     oProtocolKeepAlives, oSetupTimeOut,
  1246.     oDeprecated, oUnsupported
  1247.  } OpCodes;
  1248. @@ -247,6 +249,13 @@ static struct {
  1249.     { "ipqos", oIPQoS },
  1250.     { "requesttty", oRequestTTY },
  1251.  
  1252. +   { "noneenabled", oNoneEnabled },
  1253. +   { "tcprcvbufpoll", oTcpRcvBufPoll },
  1254. +   { "tcprcvbuf", oTcpRcvBuf },
  1255. +   { "noneswitch", oNoneSwitch },
  1256. +   { "hpndisabled", oHPNDisabled },
  1257. +   { "hpnbuffersize", oHPNBufferSize },
  1258. +
  1259.     { NULL, oBadOption }
  1260.  };
  1261.  
  1262. @@ -495,6 +504,36 @@ parse_flag:
  1263.         intptr = &options->check_host_ip;
  1264.         goto parse_flag;
  1265.  
  1266. +   case oNoneEnabled:
  1267. +       intptr = &options->none_enabled;
  1268. +       goto parse_flag;
  1269. +
  1270. +   /* we check to see if the command comes from the */
  1271. +   /* command line or not. If it does then enable it */
  1272. +   /* otherwise fail. NONE should never be a default configuration */
  1273. +   case oNoneSwitch:
  1274. +       if(strcmp(filename,"command-line") == 0) {
  1275. +           intptr = &options->none_switch;
  1276. +           goto parse_flag;
  1277. +       } else {
  1278. +           error("NoneSwitch is found in %.200s.\nYou may only use this configuration option from the command line", filename);
  1279. +           error("Continuing...");
  1280. +           debug("NoneSwitch directive found in %.200s.", filename);
  1281. +           return 0;
  1282. +       }
  1283. +
  1284. +   case oHPNDisabled:
  1285. +       intptr = &options->hpn_disabled;
  1286. +       goto parse_flag;
  1287. +
  1288. +   case oHPNBufferSize:
  1289. +       intptr = &options->hpn_buffer_size;
  1290. +       goto parse_int;
  1291. +
  1292. +   case oTcpRcvBufPoll:
  1293. +       intptr = &options->tcp_rcv_buf_poll;
  1294. +       goto parse_flag;
  1295. +
  1296.     case oVerifyHostKeyDNS:
  1297.         intptr = &options->verify_host_key_dns;
  1298.         goto parse_yesnoask;
  1299. @@ -680,6 +719,10 @@ parse_int:
  1300.         intptr = &options->connection_attempts;
  1301.         goto parse_int;
  1302.  
  1303. +   case oTcpRcvBuf:
  1304. +       intptr = &options->tcp_rcv_buf;
  1305. +       goto parse_int;
  1306. +
  1307.     case oCipher:
  1308.         intptr = &options->cipher;
  1309.         arg = strdelim(&s);
  1310. @@ -1203,6 +1246,13 @@ initialize_options(Options * options)
  1311.     options->ip_qos_interactive = -1;
  1312.     options->ip_qos_bulk = -1;
  1313.     options->request_tty = -1;
  1314. +
  1315. +   options->none_switch = -1;
  1316. +   options->none_enabled = -1;
  1317. +   options->hpn_disabled = -1;
  1318. +   options->hpn_buffer_size = -1;
  1319. +   options->tcp_rcv_buf_poll = -1;
  1320. +   options->tcp_rcv_buf = -1;
  1321.  }
  1322.  
  1323.  /*
  1324. @@ -1339,6 +1389,30 @@ fill_default_options(Options * options)
  1325.         options->server_alive_interval = 0;
  1326.     if (options->server_alive_count_max == -1)
  1327.         options->server_alive_count_max = 3;
  1328. +   if (options->none_switch == -1)
  1329. +           options->none_switch = 0;
  1330. +   if (options->hpn_disabled == -1)
  1331. +           options->hpn_disabled = 0;
  1332. +   if (options->hpn_buffer_size > -1)
  1333. +   {
  1334. +     /* if a user tries to set the size to 0 set it to 1KB */
  1335. +       if (options->hpn_buffer_size == 0)
  1336. +       options->hpn_buffer_size = 1;
  1337. +       /*limit the buffer to 64MB*/
  1338. +       if (options->hpn_buffer_size > 64*1024)
  1339. +       {
  1340. +           options->hpn_buffer_size = 64*1024*1024;
  1341. +           debug("User requested buffer larger than 64MB. Request reverted to 64MB");
  1342. +       }
  1343. +       else options->hpn_buffer_size *= 1024;
  1344. +       debug("hpn_buffer_size set to %d", options->hpn_buffer_size);
  1345. +   }
  1346. +   if (options->tcp_rcv_buf == 0)
  1347. +       options->tcp_rcv_buf = 1;
  1348. +   if (options->tcp_rcv_buf > -1)
  1349. +       options->tcp_rcv_buf *=1024;
  1350. +   if (options->tcp_rcv_buf_poll == -1)
  1351. +       options->tcp_rcv_buf_poll = 1;
  1352.     if (options->control_master == -1)
  1353.         options->control_master = 0;
  1354.     if (options->control_persist == -1) {
  1355. diff -NupwB canonical/readconf.h kitchen/readconf.h
  1356. --- canonical/readconf.h    2011-10-02 03:59:03.000000000 -0400
  1357. +++ kitchen/readconf.h  2012-11-07 15:28:16.000000000 -0500
  1358. @@ -61,6 +61,11 @@ typedef struct {
  1359.     int     compression_level;  /* Compression level 1 (fast) to 9
  1360.                      * (best). */
  1361.     int     tcp_keep_alive; /* Set SO_KEEPALIVE. */
  1362. +        int     tcp_rcv_buf; /* user switch to set tcp recv buffer */
  1363. +   int tcp_rcv_buf_poll; /* Option to poll recv buf every window transfer */
  1364. +   int     hpn_disabled;    /* Switch to disable HPN buffer management */
  1365. +   int hpn_buffer_size; /* User definable size for HPN buffer window */
  1366. +
  1367.     int ip_qos_interactive; /* IP ToS/DSCP/class for interactive */
  1368.     int ip_qos_bulk;        /* IP ToS/DSCP/class for bulk traffic */
  1369.     LogLevel log_level; /* Level for logging. */
  1370. @@ -109,6 +114,8 @@ typedef struct {
  1371.  
  1372.     int enable_ssh_keysign;
  1373.     int64_t rekey_limit;
  1374. +   int     none_switch;    /* Use none cipher */
  1375. +   int     none_enabled;   /* Allow none to be used */
  1376.     int no_host_authentication_for_localhost;
  1377.     int identities_only;
  1378.     int server_alive_interval;
  1379. Common subdirectories: canonical/regress and kitchen/regress
  1380. Common subdirectories: canonical/scard and kitchen/scard
  1381. diff -NupwB canonical/scp.c kitchen/scp.c
  1382. --- canonical/scp.c 2011-09-22 07:38:01.000000000 -0400
  1383. +++ kitchen/scp.c   2012-11-07 15:28:16.000000000 -0500
  1384. @@ -731,7 +731,7 @@ source(int argc, char **argv)
  1385.     off_t i, statbytes;
  1386.     size_t amt;
  1387.     int fd = -1, haderr, indx;
  1388. -   char *last, *name, buf[2048], encname[MAXPATHLEN];
  1389. +   char *last, *name, buf[16384], encname[MAXPATHLEN];
  1390.     int len;
  1391.  
  1392.     for (indx = 0; indx < argc; ++indx) {
  1393. @@ -913,7 +913,7 @@ sink(int argc, char **argv)
  1394.     mode_t mode, omode, mask;
  1395.     off_t size, statbytes;
  1396.     int setimes, targisdir, wrerrno = 0;
  1397. -   char ch, *cp, *np, *targ, *why, *vect[1], buf[2048];
  1398. +   char ch, *cp, *np, *targ, *why, *vect[1], buf[16384];
  1399.     struct timeval tv[2];
  1400.  
  1401.  #define    atime   tv[0]
  1402. diff -NupwB canonical/servconf.c kitchen/servconf.c
  1403. --- canonical/servconf.c    2011-10-02 03:57:38.000000000 -0400
  1404. +++ kitchen/servconf.c  2012-11-07 15:28:16.000000000 -0500
  1405. @@ -136,6 +136,10 @@ initialize_server_options(ServerOptions
  1406.     options->revoked_keys_file = NULL;
  1407.     options->trusted_user_ca_keys = NULL;
  1408.     options->authorized_principals_file = NULL;
  1409. +   options->none_enabled = -1;
  1410. +   options->tcp_rcv_buf_poll = -1;
  1411. +   options->hpn_disabled = -1;
  1412. +   options->hpn_buffer_size = -1;
  1413.     options->ip_qos_interactive = -1;
  1414.     options->ip_qos_bulk = -1;
  1415.  }
  1416. @@ -143,6 +147,11 @@ initialize_server_options(ServerOptions
  1417.  void
  1418.  fill_default_server_options(ServerOptions *options)
  1419.  {
  1420. +   /* needed for hpn socket tests */
  1421. +   int sock;
  1422. +   int socksize;
  1423. +   int socksizelen = sizeof(int);
  1424. +
  1425.     /* Portable-specific options */
  1426.     if (options->use_pam == -1)
  1427.         options->use_pam = 0;
  1428. @@ -273,6 +282,43 @@ fill_default_server_options(ServerOption
  1429.         options->permit_tun = SSH_TUNMODE_NO;
  1430.     if (options->zero_knowledge_password_authentication == -1)
  1431.         options->zero_knowledge_password_authentication = 0;
  1432. +   if (options->hpn_disabled == -1)
  1433. +       options->hpn_disabled = 0;
  1434. +
  1435. +   if (options->hpn_buffer_size == -1) {
  1436. +       /* option not explicitly set. Now we have to figure out */
  1437. +       /* what value to use */
  1438. +       if (options->hpn_disabled == 1) {
  1439. +           options->hpn_buffer_size = CHAN_SES_WINDOW_DEFAULT;
  1440. +       } else {
  1441. +           /* get the current RCV size and set it to that */
  1442. +           /*create a socket but don't connect it */
  1443. +           /* we use that the get the rcv socket size */
  1444. +           sock = socket(AF_INET, SOCK_STREAM, 0);
  1445. +           getsockopt(sock, SOL_SOCKET, SO_RCVBUF,
  1446. +                  &socksize, &socksizelen);
  1447. +           close(sock);
  1448. +           options->hpn_buffer_size = socksize;
  1449. +           debug ("HPN Buffer Size: %d", options->hpn_buffer_size);
  1450. +          
  1451. +       }
  1452. +   } else {
  1453. +       /* we have to do this incase the user sets both values in a contradictory */
  1454. +       /* manner. hpn_disabled overrrides hpn_buffer_size*/
  1455. +       if (options->hpn_disabled <= 0) {
  1456. +           if (options->hpn_buffer_size == 0)
  1457. +               options->hpn_buffer_size = 1;
  1458. +           /* limit the maximum buffer to 64MB */
  1459. +           if (options->hpn_buffer_size > 64*1024) {
  1460. +               options->hpn_buffer_size = 64*1024*1024;
  1461. +           } else {
  1462. +               options->hpn_buffer_size *= 1024;
  1463. +           }
  1464. +       } else
  1465. +           options->hpn_buffer_size = CHAN_TCP_WINDOW_DEFAULT;
  1466. +   }
  1467. +
  1468. +
  1469.     if (options->ip_qos_interactive == -1)
  1470.         options->ip_qos_interactive = IPTOS_LOWDELAY;
  1471.     if (options->ip_qos_bulk == -1)
  1472. @@ -323,6 +369,7 @@ typedef enum {
  1473.     sUsePrivilegeSeparation, sAllowAgentForwarding,
  1474.     sZeroKnowledgePasswordAuthentication, sHostCertificate,
  1475.     sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile,
  1476. +   sNoneEnabled, sTcpRcvBufPoll, sHPNDisabled, sHPNBufferSize,
  1477.     sKexAlgorithms, sIPQoS,
  1478.     sDeprecated, sUnsupported
  1479.  } ServerOpCodes;
  1480. @@ -446,6 +493,10 @@ static struct {
  1481.     { "revokedkeys", sRevokedKeys, SSHCFG_ALL },
  1482.     { "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL },
  1483.     { "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL },
  1484. +   { "noneenabled", sNoneEnabled, SSHCFG_ALL },
  1485. +   { "hpndisabled", sHPNDisabled, SSHCFG_ALL },
  1486. +   { "hpnbuffersize", sHPNBufferSize, SSHCFG_ALL },
  1487. +   { "tcprcvbufpoll", sTcpRcvBufPoll, SSHCFG_ALL },
  1488.     { "kexalgorithms", sKexAlgorithms, SSHCFG_GLOBAL },
  1489.     { "ipqos", sIPQoS, SSHCFG_ALL },
  1490.     { NULL, sBadOption, 0 }
  1491. @@ -474,6 +525,7 @@ parse_token(const char *cp, const char *
  1492.  
  1493.     for (i = 0; keywords[i].name; i++)
  1494.         if (strcasecmp(cp, keywords[i].name) == 0) {
  1495. +           debug ("Config token is %s", keywords[i].name);
  1496.             *flags = keywords[i].flags;
  1497.             return keywords[i].opcode;
  1498.         }
  1499. @@ -918,6 +970,23 @@ process_server_config_line(ServerOptions
  1500.             *intptr = value;
  1501.         break;
  1502.  
  1503. +
  1504. +   case sNoneEnabled:
  1505. +       intptr = &options->none_enabled;
  1506. +       goto parse_flag;
  1507. +
  1508. +   case sTcpRcvBufPoll:
  1509. +       intptr = &options->tcp_rcv_buf_poll;
  1510. +       goto parse_flag;
  1511. +
  1512. +   case sHPNDisabled:
  1513. +       intptr = &options->hpn_disabled;
  1514. +       goto parse_flag;
  1515. +
  1516. +   case sHPNBufferSize:
  1517. +       intptr = &options->hpn_buffer_size;
  1518. +       goto parse_int;
  1519. +
  1520.     case sIgnoreUserKnownHosts:
  1521.         intptr = &options->ignore_user_known_hosts;
  1522.         goto parse_flag;
  1523. diff -NupwB canonical/servconf.h kitchen/servconf.h
  1524. --- canonical/servconf.h    2011-06-22 18:30:03.000000000 -0400
  1525. +++ kitchen/servconf.h  2012-11-07 15:28:16.000000000 -0500
  1526. @@ -158,6 +158,11 @@ typedef struct {
  1527.  
  1528.     int use_pam;        /* Enable auth via PAM */
  1529.  
  1530. +        int     none_enabled;           /* enable NONE cipher switch */
  1531. +        int     tcp_rcv_buf_poll;       /* poll tcp rcv window in autotuning kernels*/
  1532. +   int hpn_disabled;       /* disable hpn functionality. false by default */
  1533. +   int hpn_buffer_size;    /* set the hpn buffer size - default 3MB */
  1534. +
  1535.     int permit_tun;
  1536.  
  1537.     int num_permitted_opens;
  1538. diff -NupwB canonical/serverloop.c kitchen/serverloop.c
  1539. --- canonical/serverloop.c  2011-05-20 05:02:50.000000000 -0400
  1540. +++ kitchen/serverloop.c    2012-11-07 15:28:16.000000000 -0500
  1541. @@ -94,10 +94,10 @@ static int fdin;        /* Descriptor for stdi
  1542.  static int fdout;      /* Descriptor for stdout (for reading);
  1543.                    May be same number as fdin. */
  1544.  static int fderr;      /* Descriptor for stderr.  May be -1. */
  1545. -static long stdin_bytes = 0;   /* Number of bytes written to stdin. */
  1546. -static long stdout_bytes = 0;  /* Number of stdout bytes sent to client. */
  1547. -static long stderr_bytes = 0;  /* Number of stderr bytes sent to client. */
  1548. -static long fdout_bytes = 0;   /* Number of stdout bytes read from program. */
  1549. +static u_long stdin_bytes = 0; /* Number of bytes written to stdin. */
  1550. +static u_long stdout_bytes = 0;    /* Number of stdout bytes sent to client. */
  1551. +static u_long stderr_bytes = 0;    /* Number of stderr bytes sent to client. */
  1552. +static u_long fdout_bytes = 0; /* Number of stdout bytes read from program. */
  1553.  static int stdin_eof = 0;  /* EOF message received from client. */
  1554.  static int fdout_eof = 0;  /* EOF encountered reading from fdout. */
  1555.  static int fderr_eof = 0;  /* EOF encountered readung from fderr. */
  1556. @@ -122,6 +122,20 @@ static volatile sig_atomic_t received_si
  1557.  static void server_init_dispatch(void);
  1558.  
  1559.  /*
  1560. + * Returns current time in seconds from Jan 1, 1970 with the maximum
  1561. + * available resolution.
  1562. + */
  1563. +
  1564. +static double
  1565. +get_current_time(void)
  1566. +{
  1567. +   struct timeval tv;
  1568. +   gettimeofday(&tv, NULL);
  1569. +   return (double) tv.tv_sec + (double) tv.tv_usec / 1000000.0;
  1570. +}
  1571. +
  1572. +
  1573. +/*
  1574.   * we write to this pipe if a SIGCHLD is caught in order to avoid
  1575.   * the race between select() and child_terminated
  1576.   */
  1577. @@ -436,6 +450,7 @@ process_input(fd_set *readset)
  1578.         } else {
  1579.             buffer_append(&stdout_buffer, buf, len);
  1580.             fdout_bytes += len;
  1581. +           debug ("FD out now: %ld", fdout_bytes);
  1582.         }
  1583.     }
  1584.     /* Read and buffer any available stderr data from the program. */
  1585. @@ -503,7 +518,7 @@ process_output(fd_set *writeset)
  1586.     }
  1587.     /* Send any buffered packet data to the client. */
  1588.     if (FD_ISSET(connection_out, writeset))
  1589. -       packet_write_poll();
  1590. +       stdin_bytes += packet_write_poll();
  1591.  }
  1592.  
  1593.  /*
  1594. @@ -820,8 +835,10 @@ server_loop2(Authctxt *authctxt)
  1595.  {
  1596.     fd_set *readset = NULL, *writeset = NULL;
  1597.     int rekeying = 0, max_fd, nalloc = 0;
  1598. +   double start_time, total_time;
  1599.  
  1600.     debug("Entering interactive session for SSH2.");
  1601. +   start_time = get_current_time();
  1602.  
  1603.     mysignal(SIGCHLD, sigchld_handler);
  1604.     child_terminated = 0;
  1605. @@ -883,6 +900,11 @@ server_loop2(Authctxt *authctxt)
  1606.  
  1607.     /* free remaining sessions, e.g. remove wtmp entries */
  1608.     session_destroy_all(NULL);
  1609. +   total_time = get_current_time() - start_time;
  1610. +   logit("SSH: Server;LType: Throughput;Remote: %s-%d;IN: %lu;OUT: %lu;Duration: %.1f;tPut_in: %.1f;tPut_out: %.1f",
  1611. +         get_remote_ipaddr(), get_remote_port(),
  1612. +         stdin_bytes, fdout_bytes, total_time, stdin_bytes / total_time,
  1613. +         fdout_bytes / total_time);
  1614.  }
  1615.  
  1616.  static void
  1617. @@ -998,8 +1020,12 @@ server_request_tun(void)
  1618.     sock = tun_open(tun, mode);
  1619.     if (sock < 0)
  1620.         goto done;
  1621. +   if (options.hpn_disabled)
  1622.     c = channel_new("tun", SSH_CHANNEL_OPEN, sock, sock, -1,
  1623.         CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1);
  1624. +   else
  1625. +       c = channel_new("tun", SSH_CHANNEL_OPEN, sock, sock, -1,
  1626. +           options.hpn_buffer_size, CHAN_TCP_PACKET_DEFAULT, 0, "tun", 1);
  1627.     c->datagram = 1;
  1628.  #if defined(SSH_TUN_FILTER)
  1629.     if (mode == SSH_TUNMODE_POINTOPOINT)
  1630. @@ -1035,6 +1061,8 @@ server_request_session(void)
  1631.     c = channel_new("session", SSH_CHANNEL_LARVAL,
  1632.         -1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT,
  1633.         0, "server-session", 1);
  1634. +   if ((options.tcp_rcv_buf_poll) && (!options.hpn_disabled))
  1635. +       c->dynamic_window = 1;
  1636.     if (session_open(the_authctxt, c->self) != 1) {
  1637.         debug("session open failed, free channel %d", c->self);
  1638.         channel_free(c);
  1639. diff -NupwB canonical/session.c kitchen/session.c
  1640. --- canonical/session.c 2011-11-03 19:55:24.000000000 -0400
  1641. +++ kitchen/session.c   2012-11-07 15:28:16.000000000 -0500
  1642. @@ -236,6 +236,7 @@ auth_input_request_forwarding(struct pas
  1643.     }
  1644.  
  1645.     /* Allocate a channel for the authentication agent socket. */
  1646. +   /* this shouldn't matter if its hpn or not - cjr */
  1647.     nc = channel_new("auth socket",
  1648.         SSH_CHANNEL_AUTH_SOCKET, sock, sock, -1,
  1649.         CHAN_X11_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT,
  1650. @@ -2278,10 +2279,16 @@ session_set_fds(Session *s, int fdin, in
  1651.      */
  1652.     if (s->chanid == -1)
  1653.         fatal("no channel for session %d", s->self);
  1654. +   if (options.hpn_disabled)
  1655.     channel_set_fds(s->chanid,
  1656.         fdout, fdin, fderr,
  1657.         ignore_fderr ? CHAN_EXTENDED_IGNORE : CHAN_EXTENDED_READ,
  1658.         1, is_tty, CHAN_SES_WINDOW_DEFAULT);
  1659. +   else
  1660. +       channel_set_fds(s->chanid,
  1661. +           fdout, fdin, fderr,
  1662. +           ignore_fderr ? CHAN_EXTENDED_IGNORE : CHAN_EXTENDED_READ,
  1663. +           1, is_tty, options.hpn_buffer_size);
  1664.  }
  1665.  
  1666.  /*
  1667. diff -NupwB canonical/sftp.1 kitchen/sftp.1
  1668. --- canonical/sftp.1    2011-09-22 07:34:15.000000000 -0400
  1669. +++ kitchen/sftp.1  2012-11-07 15:28:16.000000000 -0500
  1670. @@ -247,7 +247,8 @@ diagnostic messages from
  1671.  Specify how many requests may be outstanding at any one time.
  1672.  Increasing this may slightly improve file transfer speed
  1673.  but will increase memory usage.
  1674. -The default is 64 outstanding requests.
  1675. +The default is 256 outstanding requests providing for 8MB
  1676. +of outstanding data with a 32KB buffer.
  1677.  .It Fl r
  1678.  Recursively copy entire directories when uploading and downloading.
  1679.  Note that
  1680. diff -NupwB canonical/sftp.c kitchen/sftp.c
  1681. --- canonical/sftp.c    2011-11-24 21:53:50.000000000 -0500
  1682. +++ kitchen/sftp.c  2012-11-07 15:28:16.000000000 -0500
  1683. @@ -69,7 +69,7 @@ typedef void EditLine;
  1684.  #include "sftp-client.h"
  1685.  
  1686.  #define DEFAULT_COPY_BUFLEN    32768   /* Size of buffer for up/download */
  1687. -#define DEFAULT_NUM_REQUESTS   64  /* # concurrent outstanding requests */
  1688. +#define DEFAULT_NUM_REQUESTS   256 /* # concurrent outstanding requests */
  1689.  
  1690.  /* File to read commands from */
  1691.  FILE* infile;
  1692. diff -NupwB canonical/ssh.c kitchen/ssh.c
  1693. --- canonical/ssh.c 2011-11-03 19:54:22.000000000 -0400
  1694. +++ kitchen/ssh.c   2012-11-07 15:28:16.000000000 -0500
  1695. @@ -577,9 +577,6 @@ main(int ac, char **av)
  1696.             no_shell_flag = 1;
  1697.             options.request_tty = REQUEST_TTY_NO;
  1698.             break;
  1699. -       case 'T':
  1700. -           options.request_tty = REQUEST_TTY_NO;
  1701. -           break;
  1702.         case 'o':
  1703.             dummy = 1;
  1704.             line = xstrdup(optarg);
  1705. @@ -588,6 +585,13 @@ main(int ac, char **av)
  1706.                 exit(255);
  1707.             xfree(line);
  1708.             break;
  1709. +       case 'T':
  1710. +           no_shell_flag = 1;
  1711. +           /* ensure that the user doesn't try to backdoor a */
  1712. +           /* null cipher switch on an interactive session */
  1713. +           /* so explicitly disable it no matter what */
  1714. +           options.none_switch=0;
  1715. +           break;
  1716.         case 's':
  1717.             subsystem_flag = 1;
  1718.             break;
  1719. @@ -1369,6 +1373,9 @@ ssh_session2_open(void)
  1720.  {
  1721.     Channel *c;
  1722.     int window, packetmax, in, out, err;
  1723. +   int sock;
  1724. +   int socksize;
  1725. +   int socksizelen = sizeof(int);
  1726.  
  1727.     if (stdin_null_flag) {
  1728.         in = open(_PATH_DEVNULL, O_RDONLY);
  1729. @@ -1389,9 +1396,71 @@ ssh_session2_open(void)
  1730.     if (!isatty(err))
  1731.         set_nonblock(err);
  1732.  
  1733. -   window = CHAN_SES_WINDOW_DEFAULT;
  1734. +   /* we need to check to see if what they want to do about buffer */
  1735. +   /* sizes here. In a hpn to nonhpn connection we want to limit */
  1736. +   /* the window size to something reasonable in case the far side */
  1737. +   /* has the large window bug. In hpn to hpn connection we want to */
  1738. +   /* use the max window size but allow the user to override it */
  1739. +   /* lastly if they disabled hpn then use the ssh std window size */
  1740. +
  1741. +   /* so why don't we just do a getsockopt() here and set the */
  1742. +   /* ssh window to that? In the case of a autotuning receive */
  1743. +   /* window the window would get stuck at the initial buffer */
  1744. +   /* size generally less than 96k. Therefore we need to set the */
  1745. +   /* maximum ssh window size to the maximum hpn buffer size */
  1746. +   /* unless the user has specifically set the tcprcvbufpoll */
  1747. +   /* to no. In which case we *can* just set the window to the */
  1748. +   /* minimum of the hpn buffer size and tcp receive buffer size */
  1749. +  
  1750. +   if (tty_flag)
  1751. +       options.hpn_buffer_size = CHAN_SES_WINDOW_DEFAULT;
  1752. +   else
  1753. +       options.hpn_buffer_size = 2*1024*1024;
  1754. +
  1755. +   if (datafellows & SSH_BUG_LARGEWINDOW)
  1756. +   {
  1757. +       debug("HPN to Non-HPN Connection");
  1758. +   }
  1759. +   else
  1760. +   {
  1761. +       if (options.tcp_rcv_buf_poll <= 0)
  1762. +       {
  1763. +           sock = socket(AF_INET, SOCK_STREAM, 0);
  1764. +           getsockopt(sock, SOL_SOCKET, SO_RCVBUF,
  1765. +                  &socksize, &socksizelen);
  1766. +           close(sock);
  1767. +           debug("socksize %d", socksize);
  1768. +           options.hpn_buffer_size = socksize;
  1769. +           debug ("HPNBufferSize set to TCP RWIN: %d", options.hpn_buffer_size);
  1770. +       }
  1771. +       else
  1772. +       {
  1773. +           if (options.tcp_rcv_buf > 0)
  1774. +           {
  1775. +               /*create a socket but don't connect it */
  1776. +               /* we use that the get the rcv socket size */
  1777. +               sock = socket(AF_INET, SOCK_STREAM, 0);
  1778. +               /* if they are using the tcp_rcv_buf option */
  1779. +               /* attempt to set the buffer size to that */
  1780. +               if (options.tcp_rcv_buf)
  1781. +                   setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void *)&options.tcp_rcv_buf,
  1782. +                          sizeof(options.tcp_rcv_buf));
  1783. +               getsockopt(sock, SOL_SOCKET, SO_RCVBUF,
  1784. +                      &socksize, &socksizelen);
  1785. +               close(sock);
  1786. +               debug("socksize %d", socksize);
  1787. +               options.hpn_buffer_size = socksize;
  1788. +               debug ("HPNBufferSize set to user TCPRcvBuf: %d", options.hpn_buffer_size);
  1789. +           }
  1790. +       }
  1791. +
  1792. +   }
  1793. +   debug("Final hpn_buffer_size = %d", options.hpn_buffer_size);
  1794. +   window = options.hpn_buffer_size;
  1795. +   channel_set_hpn(options.hpn_disabled, options.hpn_buffer_size);
  1796.     packetmax = CHAN_SES_PACKET_DEFAULT;
  1797.     if (tty_flag) {
  1798. +       window = 4*CHAN_SES_PACKET_DEFAULT;
  1799.         window >>= 1;
  1800.         packetmax >>= 1;
  1801.     }
  1802. @@ -1400,6 +1469,11 @@ ssh_session2_open(void)
  1803.         window, packetmax, CHAN_EXTENDED_WRITE,
  1804.         "client-session", /*nonblock*/0);
  1805.  
  1806. +   if ((options.tcp_rcv_buf_poll > 0) && (!options.hpn_disabled)) {
  1807. +       c->dynamic_window = 1;
  1808. +       debug ("Enabled Dynamic Window Scaling\n");
  1809. +   }
  1810. +
  1811.     debug3("ssh_session2_open: channel_new: %d", c->self);
  1812.  
  1813.     channel_send_open(c->self);
  1814. diff -NupwB canonical/sshconnect2.c kitchen/sshconnect2.c
  1815. --- canonical/sshconnect2.c 2011-05-29 07:42:34.000000000 -0400
  1816. +++ kitchen/sshconnect2.c   2012-11-07 15:28:16.000000000 -0500
  1817. @@ -81,6 +81,11 @@
  1818.  extern char *client_version_string;
  1819.  extern char *server_version_string;
  1820.  extern Options options;
  1821. +extern Kex *xxx_kex;
  1822. +
  1823. +/* tty_flag is set in ssh.c. use this in ssh_userauth2 */
  1824. +/* if it is set then prevent the switch to the null cipher */
  1825. +extern int tty_flag;
  1826.  
  1827.  /*
  1828.   * SSH2 key exchange
  1829. @@ -420,6 +425,29 @@ ssh_userauth2(const char *local_user, co
  1830.     pubkey_cleanup(&authctxt);
  1831.     dispatch_range(SSH2_MSG_USERAUTH_MIN, SSH2_MSG_USERAUTH_MAX, NULL);
  1832.  
  1833. +   /* if the user wants to use the none cipher do it */
  1834. +   /* post authentication and only if the right conditions are met */
  1835. +   /* both of the NONE commands must be true and there must be no */
  1836. +   /* tty allocated */
  1837. +   if ((options.none_switch == 1) && (options.none_enabled == 1))
  1838. +   {
  1839. +       if (!tty_flag) /* no null on tty sessions */
  1840. +       {
  1841. +           debug("Requesting none rekeying...");
  1842. +           myproposal[PROPOSAL_ENC_ALGS_STOC] = "none";
  1843. +           myproposal[PROPOSAL_ENC_ALGS_CTOS] = "none";
  1844. +           kex_prop2buf(&xxx_kex->my,myproposal);
  1845. +           packet_request_rekeying();
  1846. +           fprintf(stderr, "WARNING: ENABLED NONE CIPHER\n");
  1847. +       }
  1848. +       else
  1849. +       {
  1850. +           /* requested NONE cipher when in a tty */
  1851. +           debug("Cannot switch to NONE cipher with tty allocated");
  1852. +           fprintf(stderr, "NONE cipher switch disabled when a TTY is allocated\n");
  1853. +       }
  1854. +   }
  1855. +
  1856.     debug("Authentication succeeded (%s).", authctxt.method->name);
  1857.  }
  1858.  
  1859. diff -NupwB canonical/sshconnect.c kitchen/sshconnect.c
  1860. --- canonical/sshconnect.c  2011-05-29 07:42:34.000000000 -0400
  1861. +++ kitchen/sshconnect.c    2012-11-07 15:28:16.000000000 -0500
  1862. @@ -182,6 +182,33 @@ ssh_kill_proxy_command(void)
  1863.  }
  1864.  
  1865.  /*
  1866. +
  1867. + /*
  1868. + * Set TCP receive buffer if requested.
  1869. + * Note: tuning needs to happen after the socket is
  1870. + * created but before the connection happens
  1871. + * so winscale is negotiated properly -cjr
  1872. + */
  1873. +static void
  1874. +ssh_set_socket_recvbuf(int sock)
  1875. +{
  1876. +   void *buf = (void *)&options.tcp_rcv_buf;
  1877. +   int sz = sizeof(options.tcp_rcv_buf);
  1878. +   int socksize;
  1879. +   int socksizelen = sizeof(int);
  1880. +
  1881. +   debug("setsockopt Attempting to set SO_RCVBUF to %d", options.tcp_rcv_buf);
  1882. +   if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, buf, sz) >= 0) {
  1883. +     getsockopt(sock, SOL_SOCKET, SO_RCVBUF, &socksize, &socksizelen);
  1884. +     debug("setsockopt SO_RCVBUF: %.100s %d", strerror(errno), socksize);
  1885. +   }
  1886. +   else
  1887. +       error("Couldn't set socket receive buffer to %d: %.100s",
  1888. +           options.tcp_rcv_buf, strerror(errno));
  1889. +}
  1890. +
  1891. +
  1892. +/*
  1893.   * Creates a (possibly privileged) socket for use as the ssh connection.
  1894.   */
  1895.  static int
  1896. @@ -204,6 +231,8 @@ ssh_create_socket(int privileged, struct
  1897.                 strerror(errno));
  1898.         else
  1899.             debug("Allocated local port %d.", p);
  1900. +       if (options.tcp_rcv_buf > 0)
  1901. +           ssh_set_socket_recvbuf(sock);
  1902.         return sock;
  1903.     }
  1904.     sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
  1905. @@ -213,6 +242,10 @@ ssh_create_socket(int privileged, struct
  1906.     }
  1907.     fcntl(sock, F_SETFD, FD_CLOEXEC);
  1908.  
  1909. +   if (options.tcp_rcv_buf > 0)
  1910. +       ssh_set_socket_recvbuf(sock);
  1911. +
  1912. +
  1913.     /* Bind the socket to an alternative local IP address */
  1914.     if (options.bind_address == NULL)
  1915.         return sock;
  1916. diff -NupwB canonical/sshd.c kitchen/sshd.c
  1917. --- canonical/sshd.c    2012-02-14 13:03:31.000000000 -0500
  1918. +++ kitchen/sshd.c  2012-11-07 15:28:16.000000000 -0500
  1919. @@ -138,6 +138,8 @@ int deny_severity;
  1920.  #define REEXEC_CONFIG_PASS_FD      (STDERR_FILENO + 3)
  1921.  #define REEXEC_MIN_FREE_FD     (STDERR_FILENO + 4)
  1922.  
  1923. +int myflag = 0;
  1924. +
  1925.  extern char *__progname;
  1926.  
  1927.  /* Server configuration options. */
  1928. @@ -472,6 +474,10 @@ sshd_exchange_identification(int sock_in
  1929.     debug("Client protocol version %d.%d; client software version %.100s",
  1930.         remote_major, remote_minor, remote_version);
  1931.  
  1932. +   logit("SSH: Server;Ltype: Version;Remote: %s-%d;Protocol: %d.%d;Client: %.100s",
  1933. +         get_remote_ipaddr(), get_remote_port(),
  1934. +       remote_major, remote_minor, remote_version);
  1935. +
  1936.     compat_datafellows(remote_version);
  1937.  
  1938.     if (datafellows & SSH_BUG_PROBE) {
  1939. @@ -1028,6 +1034,9 @@ server_listen(void)
  1940.     struct addrinfo *ai;
  1941.     char ntop[NI_MAXHOST], strport[NI_MAXSERV];
  1942.  
  1943. +   int socksize;
  1944. +   int socksizelen = sizeof(int);
  1945. +
  1946.     for (ai = options.listen_addrs; ai; ai = ai->ai_next) {
  1947.         if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
  1948.             continue;
  1949. @@ -1067,6 +1076,12 @@ server_listen(void)
  1950.  
  1951.         debug("Bind to port %s on %s.", strport, ntop);
  1952.  
  1953. +       getsockopt(listen_sock, SOL_SOCKET, SO_RCVBUF,
  1954. +                  &socksize, &socksizelen);
  1955. +       debug("Server TCP RWIN socket size: %d", socksize);
  1956. +       debug("HPN Buffer Size: %d", options.hpn_buffer_size);
  1957. +
  1958. +
  1959.         /* Bind the socket to the desired port. */
  1960.         if (bind(listen_sock, ai->ai_addr, ai->ai_addrlen) < 0) {
  1961.             error("Bind to port %s on %s failed: %.200s.",
  1962. @@ -1948,6 +1963,9 @@ main(int ac, char **av)
  1963.     /* Log the connection. */
  1964.     verbose("Connection from %.500s port %d", remote_ip, remote_port);
  1965.  
  1966. +   /* set the HPN options for the child */
  1967. +   channel_set_hpn(options.hpn_disabled, options.hpn_buffer_size);
  1968. +
  1969.     /*
  1970.      * We don't want to listen forever unless the other side
  1971.      * successfully authenticates itself.  So we set up an alarm which is
  1972. @@ -2304,9 +2322,16 @@ do_ssh2_kex(void)
  1973.  {
  1974.     Kex *kex;
  1975.  
  1976. +   myflag++;
  1977. +   debug ("MYFLAG IS %d", myflag);
  1978. +
  1979.     if (options.ciphers != NULL) {
  1980.         myproposal[PROPOSAL_ENC_ALGS_CTOS] =
  1981.         myproposal[PROPOSAL_ENC_ALGS_STOC] = options.ciphers;
  1982. +   } else if (options.none_enabled == 1) {
  1983. +       debug ("WARNING: None cipher enabled");
  1984. +       myproposal[PROPOSAL_ENC_ALGS_CTOS] =
  1985. +       myproposal[PROPOSAL_ENC_ALGS_STOC] = KEX_ENCRYPT_INCLUDE_NONE;
  1986.     }
  1987.     myproposal[PROPOSAL_ENC_ALGS_CTOS] =
  1988.         compat_cipher_proposal(myproposal[PROPOSAL_ENC_ALGS_CTOS]);
  1989. diff -NupwB canonical/sshd_config kitchen/sshd_config
  1990. --- canonical/sshd_config   2011-05-29 07:39:39.000000000 -0400
  1991. +++ kitchen/sshd_config 2012-11-07 15:28:16.000000000 -0500
  1992. @@ -114,6 +114,19 @@ AuthorizedKeysFile .ssh/authorized_keys
  1993.  # override default of no subsystems
  1994.  Subsystem  sftp    /usr/libexec/sftp-server
  1995.  
  1996. +# the following are HPN related configuration options
  1997. +# tcp receive buffer polling. disable in non autotuning kernels
  1998. +#TcpRcvBufPoll yes
  1999. +
  2000. +# allow the use of the none cipher
  2001. +#NoneEnabled no
  2002. +
  2003. +# disable hpn performance boosts.
  2004. +#HPNDisabled no
  2005. +
  2006. +# buffer size for hpn to non-hpn connections
  2007. +#HPNBufferSize 2048
  2008. +
  2009.  # Example of overriding settings on a per-user basis
  2010.  #Match User anoncvs
  2011.  #  X11Forwarding no
  2012. diff -NupwB canonical/version.h kitchen/version.h
  2013. --- canonical/version.h 2012-02-10 16:19:44.000000000 -0500
  2014. +++ kitchen/version.h   2012-11-07 16:04:59.000000000 -0500
  2015. @@ -3,7 +3,8 @@
  2016.  #define SSH_VERSION    "OpenSSH_6.0"
  2017.  
  2018.  #define SSH_PORTABLE   "p1"
  2019. -#define SSH_RELEASE_MINIMUM    SSH_VERSION SSH_PORTABLE
  2020. +#define SSH_HPN        "-hpn13v13"
  2021. +#define SSH_RELEASE_MINIMUM    SSH_VERSION SSH_PORTABLE SSH_HPN
  2022.  #ifdef SSH_EXTRAVERSION
  2023.  #define SSH_RELEASE    SSH_RELEASE_MINIMUM " " SSH_EXTRAVERSION
  2024.  #else
Advertisement
Add Comment
Please, Sign In to add comment