Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/rlogin PR/47584: Steffen Daoden: Add option to turn ...



details:   https://anonhg.NetBSD.org/src/rev/0a2f0966ab18
branches:  trunk
changeset: 785188:0a2f0966ab18
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Mar 02 16:35:17 2013 +0000

description:
PR/47584: Steffen Daoden: Add option to turn off Nagle to rlogin

diffstat:

 usr.bin/rlogin/rlogin.1 |  28 +++++++++++++--------
 usr.bin/rlogin/rlogin.c |  63 ++++++++++++++++++++++++------------------------
 2 files changed, 49 insertions(+), 42 deletions(-)

diffs (256 lines):

diff -r 074e6d11fa8b -r 0a2f0966ab18 usr.bin/rlogin/rlogin.1
--- a/usr.bin/rlogin/rlogin.1   Sat Mar 02 08:51:42 2013 +0000
+++ b/usr.bin/rlogin/rlogin.1   Sat Mar 02 16:35:17 2013 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: rlogin.1,v 1.25 2005/07/16 12:35:59 rpaulo Exp $
+.\"    $NetBSD: rlogin.1,v 1.26 2013/03/02 16:35:17 christos Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    @(#)rlogin.1    8.2 (Berkeley) 4/29/95
 .\"
-.Dd July 16, 2005
+.Dd March 2, 2013
 .Dt RLOGIN 1
 .Os
 .Sh NAME
@@ -37,20 +37,20 @@
 .Nd remote login
 .Sh SYNOPSIS
 .Nm
-.Op Fl 468Ed
+.Op Fl 468dEn
 .Op Fl e Ar char
 .Op Fl l Ar username
 .Op Fl p Ar port
 .Ar host
 .Nm
-.Op Fl 468Ed
+.Op Fl 468dEn
 .Op Fl e Ar char
 .Op Fl p Ar port
 .Ar username@host
 .Sh DESCRIPTION
 .Nm
 starts a terminal session on a remote host
-.Ar host  .
+.Ar host .
 .Pp
 .Nm
 first attempts to use the standard Berkeley
@@ -69,6 +69,12 @@
 parity bits are stripped except when the remote side's stop and start
 characters are other than
 .Sq \&^S/^Q .
+.It Fl d
+The
+.Fl d
+option turns on socket debugging (see
+.Xr setsockopt 2 )
+on the TCP sockets used for communication with the remote host.
 .It Fl E
 The
 .Fl E
@@ -76,12 +82,6 @@
 When used with the
 .Fl 8
 option, this provides a completely transparent connection.
-.It Fl d
-The
-.Fl d
-option turns on socket debugging (see
-.Xr setsockopt 2 )
-on the TCP sockets used for communication with the remote host.
 .It Fl e Ar char
 The
 .Fl e
@@ -97,6 +97,12 @@
 .Ar username
 for the remote login.
 If this option is not specified, your local username will be used.
+.It Fl n
+Set the
+.Dv TCP_NODELAY
+socket option,
+which can improve interactive responsiveness at the possible downside of
+increased network load.
 .It Fl p Ar port
 Uses the given
 .Ar port
diff -r 074e6d11fa8b -r 0a2f0966ab18 usr.bin/rlogin/rlogin.c
--- a/usr.bin/rlogin/rlogin.c   Sat Mar 02 08:51:42 2013 +0000
+++ b/usr.bin/rlogin/rlogin.c   Sat Mar 02 16:35:17 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rlogin.c,v 1.41 2011/09/06 18:28:35 joerg Exp $        */
+/*     $NetBSD: rlogin.c,v 1.42 2013/03/02 16:35:18 christos Exp $     */
 
 /*
  * Copyright (c) 1983, 1990, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)rlogin.c   8.4 (Berkeley) 4/29/95";
 #else
-__RCSID("$NetBSD: rlogin.c,v 1.41 2011/09/06 18:28:35 joerg Exp $");
+__RCSID("$NetBSD: rlogin.c,v 1.42 2013/03/02 16:35:18 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -56,6 +56,7 @@
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
+#include <netinet/tcp.h>
 
 #include <err.h>
 #include <errno.h>
@@ -73,7 +74,6 @@
 
 #include "getport.h"
 
-
 #ifndef TIOCPKT_WINDOW
 #define        TIOCPKT_WINDOW  0x80
 #endif
@@ -134,7 +134,7 @@
        struct termios tty;
        sigset_t smask;
        uid_t uid;
-       int argoff, ch, dflag, one;
+       int argoff, ch, dflag, nflag, one;
        int i, len, len2;
        int family = AF_UNSPEC;
        char *host, *p, *user, *name, term[1024] = "network";
@@ -143,7 +143,7 @@
        char *service = NULL;
        struct rlimit rlim;
 
-       argoff = dflag = 0;
+       argoff = dflag = nflag = 0;
        one = 1;
        host = user = NULL;
        sp = NULL;
@@ -160,7 +160,7 @@
                argoff = 1;
        }
 
-#define        OPTIONS "468dEe:l:p:"
+#define        OPTIONS "468dEe:l:np:"
        while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1)
                switch(ch) {
                case '4':
@@ -185,6 +185,9 @@
                case 'l':
                        user = optarg;
                        break;
+               case 'n':
+                       nflag = 1;
+                       break;
                case 'p':
                        sp = getport(service = optarg, "tcp");
                        break;
@@ -258,34 +261,34 @@
        (void)sigaction(SIGURG, &sa, (struct sigaction *) 0);
        sa.sa_handler = writeroob;
        (void)sigaction(SIGUSR1, &sa, (struct sigaction *) 0);
-       
+
        /* don't dump core */
        rlim.rlim_cur = rlim.rlim_max = 0;
        if (setrlimit(RLIMIT_CORE, &rlim) < 0)
                warn("setrlimit");
 
        rem = rcmd_af(&host, sp->s_port, name, user, term, 0, family);
-
-
        if (rem < 0)
                exit(1);
 
        if (dflag &&
            setsockopt(rem, SOL_SOCKET, SO_DEBUG, &one, sizeof(one)) < 0)
                warn("setsockopt DEBUG (ignored)");
-    {
-       struct sockaddr_storage ss;
-       socklen_t sslen;
-       sslen = sizeof(ss);
-       if (getsockname(rem, (struct sockaddr *)&ss, &sslen) == 0
-        && ((struct sockaddr *)&ss)->sa_family == AF_INET) {
-               one = IPTOS_LOWDELAY;
-               if (setsockopt(rem, IPPROTO_IP, IP_TOS, (char *)&one,
-                               sizeof(int)) < 0) {
-                       warn("setsockopt TOS (ignored)");
+       if (nflag &&
+           setsockopt(rem, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) < 0)
+               warn("setsockopt NODELAY (ignored)");
+
+       {
+               struct sockaddr_storage ss;
+               socklen_t sslen = sizeof(ss);
+               if (getsockname(rem, (struct sockaddr *)&ss, &sslen) == 0
+                    && ((struct sockaddr *)&ss)->sa_family == AF_INET) {
+                       one = IPTOS_LOWDELAY;
+                       if (setsockopt(rem, IPPROTO_IP, IP_TOS, (char *)&one,
+                           sizeof(int)) < 0)
+                               warn("setsockopt TOS (ignored)");
                }
        }
-    }
 
        (void)setuid(uid);
        doit(&smask);
@@ -471,14 +474,14 @@
                                continue;
                        }
                        if (c != escapechar) {
-                                       (void)write(rem, &escapechar, 1);
+                               (void)write(rem, &escapechar, 1);
                        }
                }
 
-                       if (write(rem, &c, 1) == 0) {
-                               msg("line gone");
-                               break;
-                       }
+               if (write(rem, &c, 1) == 0) {
+                       msg("line gone");
+                       break;
+               }
 
                bol = CCEQ(deftty.c_cc[VKILL], c) ||
                    CCEQ(deftty.c_cc[VEOF], c) ||
@@ -559,7 +562,7 @@
        wp->ws_xpixel = htons(winsize.ws_xpixel);
        wp->ws_ypixel = htons(winsize.ws_ypixel);
 
-               (void)write(rem, obuf, sizeof(obuf));
+       (void)write(rem, obuf, sizeof(obuf));
 }
 
 /*
@@ -689,8 +692,7 @@
                rcvcnt = 0;
                rcvstate = READING;
 
-                       rcvcnt = read(rem, rcvbuf, sizeof (rcvbuf));
-
+               rcvcnt = read(rem, rcvbuf, sizeof (rcvbuf));
                if (rcvcnt == 0)
                        return (0);
                if (rcvcnt < 0) {
@@ -759,13 +761,12 @@
        (void)fprintf(stderr, "rlogin: %s\r\n", str);
 }
 
-
 static void
 usage(void)
 {
        (void)fprintf(stderr,
-           "usage: rlogin [-%s]%s[-e char] [-l username] [-p port] [username@]host\n",
-           "468Ed", " ");
+           "Usage: %s [-468Edn] [-e char] [-l username] [-p port] "
+           "[username@]host\n", getprogname());
        exit(1);
 }
 



Home | Main Index | Thread Index | Old Index