]> andersk Git - gssapi-openssh.git/blobdiff - openssh/ssh.c
http://www.psc.edu/networking/projects/hpn-ssh/openssh-4.5p1-hpn12v14.diff.gz
[gssapi-openssh.git] / openssh / ssh.c
index 47297edbb3f021db400199bfcbcba42418009bbe..2099325e36e8c4bc8a002a6d2657c6a25e495489 100644 (file)
@@ -498,9 +498,6 @@ main(int ac, char **av)
                        no_shell_flag = 1;
                        no_tty_flag = 1;
                        break;
-               case 'T':
-                       no_tty_flag = 1;
-                       break;
                case 'o':
                        dummy = 1;
                        line = xstrdup(optarg);
@@ -509,6 +506,13 @@ main(int ac, char **av)
                                exit(255);
                        xfree(line);
                        break;
+               case 'T':
+                       no_tty_flag = 1;
+                       /* ensure that the user doesn't try to backdoor a */
+                       /* null cipher switch on an interactive session */
+                       /* so explicitly disable it no matter what */
+                       options.none_switch=0;
+                       break;
                case 's':
                        subsystem_flag = 1;
                        break;
@@ -825,7 +829,8 @@ ssh_init_forwarding(void)
                    options.local_forwards[i].listen_port,
                    options.local_forwards[i].connect_host,
                    options.local_forwards[i].connect_port,
-                   options.gateway_ports);
+                   options.gateway_ports, options.hpn_disabled,
+                   options.hpn_buffer_size);
        }
        if (i > 0 && success != i && options.exit_on_forward_failure)
                fatal("Could not request local forwarding.");
@@ -1122,9 +1127,14 @@ ssh_session2_setup(int id, void *arg)
                debug("Requesting tun.");
                if ((fd = tun_open(options.tun_local,
                    options.tun_open)) >= 0) {
-                       c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1,
-                           CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
-                           0, "tun", 1);
+                       if(options.hpn_disabled)
+                               c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1,
+                                   CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT,
+                                   0, "tun", 1);
+                       else
+                               c = channel_new("tun", SSH_CHANNEL_OPENING, fd, fd, -1,
+                                   options.hpn_buffer_size, CHAN_TCP_PACKET_DEFAULT,
+                                   0, "tun", 1);
                        c->datagram = 1;
 #if defined(SSH_TUN_FILTER)
                        if (options.tun_open == SSH_TUNMODE_POINTOPOINT)
@@ -1154,6 +1164,9 @@ ssh_session2_open(void)
 {
        Channel *c;
        int window, packetmax, in, out, err;
+       int sock;
+       int socksize;
+       int socksizelen = sizeof(int);
 
        if (stdin_null_flag) {
                in = open(_PATH_DEVNULL, O_RDONLY);
@@ -1174,9 +1187,70 @@ ssh_session2_open(void)
        if (!isatty(err))
                set_nonblock(err);
 
-       window = CHAN_SES_WINDOW_DEFAULT;
+       /* we need to check to see if what they want to do about buffer */
+       /* sizes here. In a hpn to nonhpn connection we want to limit */
+       /* the window size to something reasonable in case the far side */
+       /* has the large window bug. In hpn to hpn connection we want to */
+       /* use the max window size but allow the user to override it */
+       /* lastly if they disabled hpn then use the ssh std window size */
+
+       /* so why don't we just do a getsockopt() here and set the */
+       /* ssh window to that? In the case of a autotuning receive */
+       /* window the window would get stuck at the initial buffer */
+       /* size generally less than 96k. Therefore we need to set the */
+       /* maximum ssh window size to the maximum hpn buffer size */
+       /* unless the user hasspecifically set the hpnrcvbufpoll */
+       /* to no. In which case we *can* just set the window to the */
+       /* minimum of the hpn buffer size and tcp receive buffer size */
+       
+       if(options.hpn_disabled)
+       {
+               options.hpn_buffer_size = CHAN_SES_WINDOW_DEFAULT;
+       }
+       else if (datafellows & SSH_BUG_LARGEWINDOW) 
+       {
+               debug("HPN to Non-HPN Connection");
+               if (options.hpn_buffer_size < 0)
+                       options.hpn_buffer_size = 2*1024*1024;
+       } 
+       else 
+       {
+               if (options.hpn_buffer_size < 0)
+                       options.hpn_buffer_size = BUFFER_MAX_LEN_HPN;
+
+               /*create a socket but don't connect it */
+               /* we use that the get the rcv socket size */
+               sock = socket(AF_INET, SOCK_STREAM, 0);
+               /* if they are using the tcp_rcv_buf option */
+               /* attempt to set the buffer size to that */
+               if (options.tcp_rcv_buf) 
+                       setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void *)&options.tcp_rcv_buf, 
+                                  sizeof(options.tcp_rcv_buf));
+               getsockopt(sock, SOL_SOCKET, SO_RCVBUF, 
+                          &socksize, &socksizelen);
+               close(sock);
+               debug("socksize %d", socksize);
+               if (options.tcp_rcv_buf_poll <= 0) 
+               {
+                       options.hpn_buffer_size = MIN(socksize,options.hpn_buffer_size);
+                       debug ("MIN of TCP RWIN and HPNBufferSize: %d", options.hpn_buffer_size);
+               } 
+               else
+               {
+                       if (options.tcp_rcv_buf > 0) 
+                               options.hpn_buffer_size = MIN(options.tcp_rcv_buf, options.hpn_buffer_size);
+                               debug ("MIN of TCPRcvBuf and HPNBufferSize: %d", options.hpn_buffer_size);
+               }
+               
+       }
+
+       debug("Final hpn_buffer_size = %d", options.hpn_buffer_size);
+
+       window = options.hpn_buffer_size;
+
        packetmax = CHAN_SES_PACKET_DEFAULT;
        if (tty_flag) {
+               window = 4*CHAN_SES_PACKET_DEFAULT;
                window >>= 1;
                packetmax >>= 1;
        }
@@ -1184,7 +1258,10 @@ ssh_session2_open(void)
            "session", SSH_CHANNEL_OPENING, in, out, err,
            window, packetmax, CHAN_EXTENDED_WRITE,
            "client-session", /*nonblock*/0);
-
+       if ((options.tcp_rcv_buf_poll > 0) && (!options.hpn_disabled)) {
+               c->dynamic_window = 1;
+               debug ("Enabled Dynamic Window Scaling\n");
+       }
        debug3("ssh_session2_open: channel_new: %d", c->self);
 
        channel_send_open(c->self);
@@ -1374,12 +1451,23 @@ control_client(const char *path)
                flags |= SSHMUX_FLAG_X11_FWD;
        if (options.forward_agent)
                flags |= SSHMUX_FLAG_AGENT_FWD;
-
+       if (options.num_local_forwards > 0)
+               flags |= SSHMUX_FLAG_PORTFORWARD;
        buffer_init(&m);
 
        /* Send our command to server */
        buffer_put_int(&m, mux_command);
        buffer_put_int(&m, flags);
+       if (options.num_local_forwards > 0)
+        {
+               if (options.local_forwards[0].listen_host == NULL)
+                       buffer_put_string(&m,"LOCALHOST",11);
+               else
+                       buffer_put_string(&m,options.local_forwards[0].listen_host,512);
+               buffer_put_int(&m,options.local_forwards[0].listen_port);
+               buffer_put_string(&m,options.local_forwards[0].connect_host,512);       
+               buffer_put_int(&m,options.local_forwards[0].connect_port);
+       }
        if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1)
                fatal("%s: msg_send", __func__);
        buffer_clear(&m);
This page took 0.036076 seconds and 4 git commands to generate.