Feature request: more information sent to ProxyCommand

Darren Tucker dtucker at zip.com.au
Wed Dec 15 18:57:03 EST 2010


On Tue, Dec 14, 2010 at 11:18:54PM -0500, Daniel Kahn Gillmor wrote:
> On 12/14/2010 06:32 PM, Daniel Colascione wrote:
> > I use ProxyCommand is connect to several servers, but the command
> > executed doesn't know the difference between being called for ssh or
> > scp; in the latter case, I'd like to set QoS bits so the traffic is
> > flagged as bulk. Would it be possible to send additional information to
> > the proxy command so it can make better decisions about how to relay its
> > traffic?
> 
> I think this suggestion dovetails nicely with a feature request i opened
> several months ago:
> 
>   https://bugzilla.mindrot.org/show_bug.cgi?id=1766
> 
> Unfortunately, i haven't had a chance to implement it.  If someone
> offers a patch, i'd be happy to review, test, and give feedback, though.

It's not as simple as it seems at first because currently ssh will
change the qos based on SSH-protocol level things (eg "you've requested
a pty or X11 forwarding) ssh doesn't know these things when the
proxycommand is invoked.

You could, however do an approximation.  Here's a minimal implementation
which uses %q to pass the (hex) qos to the proxycommand.  Something like:

Host foo
  ProxyCommand nc -T %q %h %p

Expanding %q for ControlMaster is also potentially useful too (eg you
could have one master for interactive sessions and one for copies) but
this is not currently implemented.

Index: readconf.h
===================================================================
RCS file: /cvs/src/usr.bin/ssh/readconf.h,v
retrieving revision 1.88
diff -u -p -r1.88 readconf.h
--- readconf.h	13 Nov 2010 23:27:50 -0000	1.88
+++ readconf.h	15 Dec 2010 05:47:19 -0000
@@ -61,6 +61,7 @@ typedef struct {
 	int     tcp_keep_alive;	/* Set SO_KEEPALIVE. */
 	int	ip_qos_interactive;	/* IP ToS/DSCP/class for interactive */
 	int	ip_qos_bulk;		/* IP ToS/DSCP/class for bulk traffic */
+	int	ip_qos_effective;	/* IP ToS/DSCP currently in use */
 	LogLevel log_level;	/* Level for logging. */
 
 	int     port;		/* Port to connect. */
Index: ssh.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/ssh.c,v
retrieving revision 1.355
diff -u -p -r1.355 ssh.c
--- ssh.c	29 Nov 2010 23:45:51 -0000	1.355
+++ ssh.c	15 Dec 2010 07:48:49 -0000
@@ -678,6 +678,9 @@ main(int ac, char **av)
 		options.port = sp ? ntohs(sp->s_port) : SSH_DEFAULT_PORT;
 	}
 
+	options.ip_qos_effective = tty_flag ? options.ip_qos_interactive :
+	   options.ip_qos_bulk;
+
 	if (options.hostname != NULL) {
 		host = percent_expand(options.hostname,
 		    "h", host, (char *)NULL);
Index: sshconnect.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/sshconnect.c,v
retrieving revision 1.230
diff -u -p -r1.230 sshconnect.c
--- sshconnect.c	14 Dec 2010 11:59:06 -0000	1.230
+++ sshconnect.c	15 Dec 2010 06:03:59 -0000
@@ -77,13 +77,14 @@ ssh_proxy_connect(const char *host, u_sh
 	char *command_string, *tmp;
 	int pin[2], pout[2];
 	pid_t pid;
-	char *shell, strport[NI_MAXSERV];
+	char *shell, strport[NI_MAXSERV], strqos[16];
 
 	if ((shell = getenv("SHELL")) == NULL || *shell == '\0')
 		shell = _PATH_BSHELL;
 
-	/* Convert the port number into a string. */
+	/* Convert the port and qps number into a string. */
 	snprintf(strport, sizeof strport, "%hu", port);
+	snprintf(strqos, sizeof strqos, "0x%02x", options.ip_qos_effective);
 
 	/*
 	 * Build the final command string in the buffer by making the
@@ -94,7 +95,7 @@ ssh_proxy_connect(const char *host, u_sh
 	 */
 	xasprintf(&tmp, "exec %s", proxy_command);
 	command_string = percent_expand(tmp, "h", host, "p", strport,
-	    "r", options.user, (char *)NULL);
+	    "r", options.user, "q", strqos, (char *)NULL);
 	xfree(tmp);
 
 	/* Create pipes for communicating with the proxy. */

-- 
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.


More information about the openssh-unix-dev mailing list