Setting Dscp (tos, QoS) for ssh sockets

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting Dscp (tos, QoS) for ssh sockets

Christofer Tornkvist (ctornkvi)
Hi,

I would like to set the quality of service flag Dscp of the Tos field in the IP packet
of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).

It should be possible to set the Dscp per IP packet sent.

How do I get hold of the Ssh socket down in my Ssh channel module ?


Regards
/Christofer



Reply | Threaded
Open this post in threaded view
|

Re: Setting Dscp (tos, QoS) for ssh sockets

Dmytro Lytovchenko
As we discussed with you before, there are two options right now:

1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}

Maybe someone sees other ways to do it?

On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email]> wrote:
Hi,

I would like to set the quality of service flag Dscp of the Tos field in the IP packet
of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).

It should be possible to set the Dscp per IP packet sent.

How do I get hold of the Ssh socket down in my Ssh channel module ?


Regards
/Christofer



Reply | Threaded
Open this post in threaded view
|

Re: Setting Dscp (tos, QoS) for ssh sockets

Per Hedeland
On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
 > As we discussed with you before, there are two options right now:
 >
 > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
 > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
 >
 > Maybe someone sees other ways to do it?

Why would you need to use inet:setopts/2 specifically? Changing DSCP
on the fly is probably not meaningful in general, and from what I know
about your application, not required there (but maybe I'm wrong about
that).

IMHO it would be reasonable to allow most/all options that can be
given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
'tos' as option), respectively, also for ssh:connect/2,3,4 and
ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
as I can see.

Alternatively you can at least for ssh:connect/2,3 apparently pass an
already connected socket from gen_tcp:connect(), where you can pass
'tos' to the latter. It seems the socket that can be passed to
ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
natural to me to pass a "listen socket" from gen_tcp:listen() (which
can be passed 'tos'), but I guess you can do the accept-loop outside
ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
passing it to ssh:daemon/2,3.

--Per

 > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <mailto:[hidden email]>> wrote:
 >
 >     Hi,
 >
 >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
 >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
 >
 >     It should be possible to set the Dscp per IP packet sent.
 >
 >     How do I get hold of the Ssh socket down in my Ssh channel module ?
 >
 >
 >     Regards
 >     /Christofer
 >
 >
 >

Reply | Threaded
Open this post in threaded view
|

Re: Setting Dscp (tos, QoS) for ssh sockets

Per Hedeland
On 2020-02-17 16:03, Per Hedeland wrote:
 > On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
 >  > As we discussed with you before, there are two options right now:
 >  >
 >  > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
 >  > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
 >  >
 >  > Maybe someone sees other ways to do it?
 >
 > Why would you need to use inet:setopts/2 specifically? Changing DSCP
 > on the fly is probably not meaningful in general, and from what I know
 > about your application, not required there (but maybe I'm wrong about
 > that).

I learned off-list that this requirement comes from RFC 8639, where a
NETCONF client/subscriber can request that the server uses a specific
DSCP value in the "establish-subscription" RPC (which is sent in an
already established session a.k.a. SSH channel). Surely OTP ssh should
support this in a "nice/clean" way...?

 > IMHO it would be reasonable to allow most/all options that can be
 > given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
 > 'tos' as option), respectively, also for ssh:connect/2,3,4 and
 > ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
 > as I can see.
 >
 > Alternatively you can at least for ssh:connect/2,3 apparently pass an
 > already connected socket from gen_tcp:connect(), where you can pass
 > 'tos' to the latter. It seems the socket that can be passed to
 > ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
 > natural to me to pass a "listen socket" from gen_tcp:listen() (which
 > can be passed 'tos'), but I guess you can do the accept-loop outside
 > ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
 > passing it to ssh:daemon/2,3.

For this alternative, the way to go would rather be to pass the 'tos'
option to gen_tcp:listen(), and have it be "inherited" by the sockets
returned from gen_tcp:accept() - i.e. no need for inet:setopts/2
there. But of course neither alternative supports changing the DSCP
value for an already established connection.

--Per

 >  > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <mailto:[hidden email]>> wrote:
 >  >
 >  >     Hi,
 >  >
 >  >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
 >  >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
 >  >
 >  >     It should be possible to set the Dscp per IP packet sent.
 >  >
 >  >     How do I get hold of the Ssh socket down in my Ssh channel module ?
 >  >
 >  >
 >  >     Regards
 >  >     /Christofer
 >  >
 >  >
 >  >

Reply | Threaded
Open this post in threaded view
|

Sv: Setting Dscp (tos, QoS) for ssh sockets

Hans Nilsson R (AL/EAB)
It is both possible and documented to give the gen_tcp:connect_options() in a call to ssh:connect.

See

where second from last is a link to

Let's try:

Eshell V10.6.4  (abort with ^G)
1> ssh:start().
ok
2> dbg:start().
{ok,<0.92.0>}
3> dbg:tracer().
{ok,<0.92.0>}
4> dbg:p(all,c).
{ok,[{matched,nonode@nohost,46}]}
5> dbg:tp(gen_tcp,connect,x).
{ok,[{matched,nonode@nohost,2},{saved,x}]}
6>
6> ssh:connect(loopback, 22, [{nodelay,true}, {tos,14}, {raw,1,2,<<3>>}]).
(<0.80.0>) call gen_tcp:connect({127,0,0,1},22,[{active,false},{raw,1,2,<<3>>},{tos,14},{nodelay,true}],infinity)
(<0.80.0>) returned from gen_tcp:connect/4 -> {ok,#Port<0.6>}
{ok,<0.99.0>}
7>

The gen_tcp options in 6> are really passed down to gen_tcp:connect.

/Hans


Från: erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
Skickat: den 17 februari 2020 20:44
Till: [hidden email] <[hidden email]>
Ämne: Re: Setting Dscp (tos, QoS) for ssh sockets
 
On 2020-02-17 16:03, Per Hedeland wrote:
 > On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
 >  > As we discussed with you before, there are two options right now:
 >  >
 >  > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
 >  > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
 >  >
 >  > Maybe someone sees other ways to do it?
 >
 > Why would you need to use inet:setopts/2 specifically? Changing DSCP
 > on the fly is probably not meaningful in general, and from what I know
 > about your application, not required there (but maybe I'm wrong about
 > that).

I learned off-list that this requirement comes from RFC 8639, where a
NETCONF client/subscriber can request that the server uses a specific
DSCP value in the "establish-subscription" RPC (which is sent in an
already established session a.k.a. SSH channel). Surely OTP ssh should
support this in a "nice/clean" way...?

 > IMHO it would be reasonable to allow most/all options that can be
 > given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
 > 'tos' as option), respectively, also for ssh:connect/2,3,4 and
 > ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
 > as I can see.
 >
 > Alternatively you can at least for ssh:connect/2,3 apparently pass an
 > already connected socket from gen_tcp:connect(), where you can pass
 > 'tos' to the latter. It seems the socket that can be passed to
 > ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
 > natural to me to pass a "listen socket" from gen_tcp:listen() (which
 > can be passed 'tos'), but I guess you can do the accept-loop outside
 > ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
 > passing it to ssh:daemon/2,3.

For this alternative, the way to go would rather be to pass the 'tos'
option to gen_tcp:listen(), and have it be "inherited" by the sockets
returned from gen_tcp:accept() - i.e. no need for inet:setopts/2
there. But of course neither alternative supports changing the DSCP
value for an already established connection.

--Per

 >  > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <[hidden email]>> wrote:
 >  >
 >  >     Hi,
 >  >
 >  >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
 >  >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
 >  >
 >  >     It should be possible to set the Dscp per IP packet sent.
 >  >
 >  >     How do I get hold of the Ssh socket down in my Ssh channel module ?
 >  >
 >  >
 >  >     Regards
 >  >     /Christofer
 >  >
 >  >
 >  >

Reply | Threaded
Open this post in threaded view
|

Re: Sv: Setting Dscp (tos, QoS) for ssh sockets

Per Hedeland
On 2020-02-18 12:58, Hans Nilsson R wrote:
> It is both possible and documented to give the gen_tcp:connect_options() in a call to ssh:connect.
>
> See
>     https://erlang.org/doc/man/ssh.html#type-client_option
>
> where second from last is a link to
>     https://erlang.org/doc/man/gen_tcp.html#type-connect_option

Sorry, don't know how I missed that - too much going back and forth
between the "textual" man pages for ssh and gen_tcp, perhaps... And
indeed gen_tcp:listen_option() is also listed for daemon_option(). So
there is no problem whatsoever with setting DSCP at the start of a
connection.

Is there also some "clean" way within ssh to address Christofer's and
Dmytro's original question (below), which I managed to obscure - i.e.
setting DSCP for an already established connection? (Which is needed
for an implementation of RFC 8639.)

--Per

> Let's try:
>
> Eshell V10.6.4  (abort with ^G)
> 1> ssh:start().
> ok
> 2> dbg:start().
> {ok,<0.92.0>}
> 3> dbg:tracer().
> {ok,<0.92.0>}
> 4> dbg:p(all,c).
> {ok,[{matched,nonode@nohost,46}]}
> 5> dbg:tp(gen_tcp,connect,x).
> {ok,[{matched,nonode@nohost,2},{saved,x}]}
> 6>
> 6> ssh:connect(loopback, 22, [{nodelay,true}, {tos,14}, {raw,1,2,<<3>>}]).
> (<0.80.0>) call gen_tcp:connect({127,0,0,1},22,[{active,false},{raw,1,2,<<3>>},{tos,14},{nodelay,true}],infinity)
> (<0.80.0>) returned from gen_tcp:connect/4 -> {ok,#Port<0.6>}
> {ok,<0.99.0>}
> 7>
>
> The gen_tcp options in 6> are really passed down to gen_tcp:connect.
>
> /Hans
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *Från:* erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
> *Skickat:* den 17 februari 2020 20:44
> *Till:* [hidden email] <[hidden email]>
> *Ämne:* Re: Setting Dscp (tos, QoS) for ssh sockets
>
> On 2020-02-17 16:03, Per Hedeland wrote:
>  > On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
>  >  > As we discussed with you before, there are two options right now:
>  >  >
>  >  > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
>  >  > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
>  >  >
>  >  > Maybe someone sees other ways to do it?
>  >
>  > Why would you need to use inet:setopts/2 specifically? Changing DSCP
>  > on the fly is probably not meaningful in general, and from what I know
>  > about your application, not required there (but maybe I'm wrong about
>  > that).
>
> I learned off-list that this requirement comes from RFC 8639, where a
> NETCONF client/subscriber can request that the server uses a specific
> DSCP value in the "establish-subscription" RPC (which is sent in an
> already established session a.k.a. SSH channel). Surely OTP ssh should
> support this in a "nice/clean" way...?
>
>  > IMHO it would be reasonable to allow most/all options that can be
>  > given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
>  > 'tos' as option), respectively, also for ssh:connect/2,3,4 and
>  > ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
>  > as I can see.
>  >
>  > Alternatively you can at least for ssh:connect/2,3 apparently pass an
>  > already connected socket from gen_tcp:connect(), where you can pass
>  > 'tos' to the latter. It seems the socket that can be passed to
>  > ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
>  > natural to me to pass a "listen socket" from gen_tcp:listen() (which
>  > can be passed 'tos'), but I guess you can do the accept-loop outside
>  > ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
>  > passing it to ssh:daemon/2,3.
>
> For this alternative, the way to go would rather be to pass the 'tos'
> option to gen_tcp:listen(), and have it be "inherited" by the sockets
> returned from gen_tcp:accept() - i.e. no need for inet:setopts/2
> there. But of course neither alternative supports changing the DSCP
> value for an already established connection.
>
> --Per
>
>  >  > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <mailto:[hidden email]>> wrote:
>  >  >
>  >  >     Hi,
>  >  >
>  >  >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
>  >  >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
>  >  >
>  >  >     It should be possible to set the Dscp per IP packet sent.
>  >  >
>  >  >     How do I get hold of the Ssh socket down in my Ssh channel module ?
>  >  >
>  >  >
>  >  >     Regards
>  >  >     /Christofer
>  >  >
>  >  >
>  >  >
>

Reply | Threaded
Open this post in threaded view
|

Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets

Hans Nilsson R (AL/EAB)
Hej Per!

So an ssh:setopts(SshConnection, InetOptions) and an ssh:getopts similar to two functions in inet would solve the problem?

/Hans


Från: erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
Skickat: den 18 februari 2020 14:08
Till: [hidden email] <[hidden email]>
Ämne: Re: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
On 2020-02-18 12:58, Hans Nilsson R wrote:
> It is both possible and documented to give the gen_tcp:connect_options() in a call to ssh:connect.
>
> See
>     https://protect2.fireeye.com/v1/url?k=6eb80c5a-326c0004-6eb84cc1-8691959ed9b7-0b75d45a9ce427c8&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fssh.html%23type-client_option
>
> where second from last is a link to
>     https://protect2.fireeye.com/v1/url?k=a1d9ada1-fd0da1ff-a1d9ed3a-8691959ed9b7-d0da1a82086ec97e&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fgen_tcp.html%23type-connect_option

Sorry, don't know how I missed that - too much going back and forth
between the "textual" man pages for ssh and gen_tcp, perhaps... And
indeed gen_tcp:listen_option() is also listed for daemon_option(). So
there is no problem whatsoever with setting DSCP at the start of a
connection.

Is there also some "clean" way within ssh to address Christofer's and
Dmytro's original question (below), which I managed to obscure - i.e.
setting DSCP for an already established connection? (Which is needed
for an implementation of RFC 8639.)

--Per

> Let's try:
>
> Eshell V10.6.4  (abort with ^G)
> 1> ssh:start().
> ok
> 2> dbg:start().
> {ok,<0.92.0>}
> 3> dbg:tracer().
> {ok,<0.92.0>}
> 4> dbg:p(all,c).
> {ok,[{matched,nonode@nohost,46}]}
> 5> dbg:tp(gen_tcp,connect,x).
> {ok,[{matched,nonode@nohost,2},{saved,x}]}
> 6>
> 6> ssh:connect(loopback, 22, [{nodelay,true}, {tos,14}, {raw,1,2,<<3>>}]).
> (<0.80.0>) call gen_tcp:connect({127,0,0,1},22,[{active,false},{raw,1,2,<<3>>},{tos,14},{nodelay,true}],infinity)
> (<0.80.0>) returned from gen_tcp:connect/4 -> {ok,#Port<0.6>}
> {ok,<0.99.0>}
> 7>
>
> The gen_tcp options in 6> are really passed down to gen_tcp:connect.
>
> /Hans
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *Från:* erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
> *Skickat:* den 17 februari 2020 20:44
> *Till:* [hidden email] <[hidden email]>
> *Ämne:* Re: Setting Dscp (tos, QoS) for ssh sockets
>
> On 2020-02-17 16:03, Per Hedeland wrote:
>  > On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
>  >  > As we discussed with you before, there are two options right now:
>  >  >
>  >  > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
>  >  > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
>  >  >
>  >  > Maybe someone sees other ways to do it?
>  >
>  > Why would you need to use inet:setopts/2 specifically? Changing DSCP
>  > on the fly is probably not meaningful in general, and from what I know
>  > about your application, not required there (but maybe I'm wrong about
>  > that).
>
> I learned off-list that this requirement comes from RFC 8639, where a
> NETCONF client/subscriber can request that the server uses a specific
> DSCP value in the "establish-subscription" RPC (which is sent in an
> already established session a.k.a. SSH channel). Surely OTP ssh should
> support this in a "nice/clean" way...?
>
>  > IMHO it would be reasonable to allow most/all options that can be
>  > given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
>  > 'tos' as option), respectively, also for ssh:connect/2,3,4 and
>  > ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
>  > as I can see.
>  >
>  > Alternatively you can at least for ssh:connect/2,3 apparently pass an
>  > already connected socket from gen_tcp:connect(), where you can pass
>  > 'tos' to the latter. It seems the socket that can be passed to
>  > ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
>  > natural to me to pass a "listen socket" from gen_tcp:listen() (which
>  > can be passed 'tos'), but I guess you can do the accept-loop outside
>  > ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
>  > passing it to ssh:daemon/2,3.
>
> For this alternative, the way to go would rather be to pass the 'tos'
> option to gen_tcp:listen(), and have it be "inherited" by the sockets
> returned from gen_tcp:accept() - i.e. no need for inet:setopts/2
> there. But of course neither alternative supports changing the DSCP
> value for an already established connection.
>
> --Per
>
>  >  > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <[hidden email]>> wrote:
>  >  >
>  >  >     Hi,
>  >  >
>  >  >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
>  >  >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
>  >  >
>  >  >     It should be possible to set the Dscp per IP packet sent.
>  >  >
>  >  >     How do I get hold of the Ssh socket down in my Ssh channel module ?
>  >  >
>  >  >
>  >  >     Regards
>  >  >     /Christofer
>  >  >
>  >  >
>  >  >
>

Reply | Threaded
Open this post in threaded view
|

Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets

Christofer Tornkvist (ctornkvi)
Hi Hans,

is the SshConnection the same as the Pid of the Connection Handler ?

Or put otherwise, is it so that, my callback channel module should know about this SshConnection ?

If that is the case, then this solution would be great.

Regards
/Christofer

Från: erlang-questions <[hidden email]> för Hans Nilsson R <[hidden email]>
Skickat: den 19 februari 2020 13:45
Till: Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hej Per!

So an ssh:setopts(SshConnection, InetOptions) and an ssh:getopts similar to two functions in inet would solve the problem?

/Hans


Från: erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
Skickat: den 18 februari 2020 14:08
Till: [hidden email] <[hidden email]>
Ämne: Re: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
On 2020-02-18 12:58, Hans Nilsson R wrote:
> It is both possible and documented to give the gen_tcp:connect_options() in a call to ssh:connect.
>
> See
>     https://protect2.fireeye.com/v1/url?k=6eb80c5a-326c0004-6eb84cc1-8691959ed9b7-0b75d45a9ce427c8&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fssh.html%23type-client_option
>
> where second from last is a link to
>     https://protect2.fireeye.com/v1/url?k=a1d9ada1-fd0da1ff-a1d9ed3a-8691959ed9b7-d0da1a82086ec97e&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fgen_tcp.html%23type-connect_option

Sorry, don't know how I missed that - too much going back and forth
between the "textual" man pages for ssh and gen_tcp, perhaps... And
indeed gen_tcp:listen_option() is also listed for daemon_option(). So
there is no problem whatsoever with setting DSCP at the start of a
connection.

Is there also some "clean" way within ssh to address Christofer's and
Dmytro's original question (below), which I managed to obscure - i.e.
setting DSCP for an already established connection? (Which is needed
for an implementation of RFC 8639.)

--Per

> Let's try:
>
> Eshell V10.6.4  (abort with ^G)
> 1> ssh:start().
> ok
> 2> dbg:start().
> {ok,<0.92.0>}
> 3> dbg:tracer().
> {ok,<0.92.0>}
> 4> dbg:p(all,c).
> {ok,[{matched,nonode@nohost,46}]}
> 5> dbg:tp(gen_tcp,connect,x).
> {ok,[{matched,nonode@nohost,2},{saved,x}]}
> 6>
> 6> ssh:connect(loopback, 22, [{nodelay,true}, {tos,14}, {raw,1,2,<<3>>}]).
> (<0.80.0>) call gen_tcp:connect({127,0,0,1},22,[{active,false},{raw,1,2,<<3>>},{tos,14},{nodelay,true}],infinity)
> (<0.80.0>) returned from gen_tcp:connect/4 -> {ok,#Port<0.6>}
> {ok,<0.99.0>}
> 7>
>
> The gen_tcp options in 6> are really passed down to gen_tcp:connect.
>
> /Hans
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *Från:* erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
> *Skickat:* den 17 februari 2020 20:44
> *Till:* [hidden email] <[hidden email]>
> *Ämne:* Re: Setting Dscp (tos, QoS) for ssh sockets
>
> On 2020-02-17 16:03, Per Hedeland wrote:
>  > On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
>  >  > As we discussed with you before, there are two options right now:
>  >  >
>  >  > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
>  >  > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
>  >  >
>  >  > Maybe someone sees other ways to do it?
>  >
>  > Why would you need to use inet:setopts/2 specifically? Changing DSCP
>  > on the fly is probably not meaningful in general, and from what I know
>  > about your application, not required there (but maybe I'm wrong about
>  > that).
>
> I learned off-list that this requirement comes from RFC 8639, where a
> NETCONF client/subscriber can request that the server uses a specific
> DSCP value in the "establish-subscription" RPC (which is sent in an
> already established session a.k.a. SSH channel). Surely OTP ssh should
> support this in a "nice/clean" way...?
>
>  > IMHO it would be reasonable to allow most/all options that can be
>  > given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
>  > 'tos' as option), respectively, also for ssh:connect/2,3,4 and
>  > ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
>  > as I can see.
>  >
>  > Alternatively you can at least for ssh:connect/2,3 apparently pass an
>  > already connected socket from gen_tcp:connect(), where you can pass
>  > 'tos' to the latter. It seems the socket that can be passed to
>  > ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
>  > natural to me to pass a "listen socket" from gen_tcp:listen() (which
>  > can be passed 'tos'), but I guess you can do the accept-loop outside
>  > ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
>  > passing it to ssh:daemon/2,3.
>
> For this alternative, the way to go would rather be to pass the 'tos'
> option to gen_tcp:listen(), and have it be "inherited" by the sockets
> returned from gen_tcp:accept() - i.e. no need for inet:setopts/2
> there. But of course neither alternative supports changing the DSCP
> value for an already established connection.
>
> --Per
>
>  >  > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <[hidden email]>> wrote:
>  >  >
>  >  >     Hi,
>  >  >
>  >  >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
>  >  >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
>  >  >
>  >  >     It should be possible to set the Dscp per IP packet sent.
>  >  >
>  >  >     How do I get hold of the Ssh socket down in my Ssh channel module ?
>  >  >
>  >  >
>  >  >     Regards
>  >  >     /Christofer
>  >  >
>  >  >
>  >  >
>

Reply | Threaded
Open this post in threaded view
|

Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets

Hans Nilsson R (AL/EAB)
Hi Christofer.

Yes, it is the C in
   {ok,C} = ssh:connect(Host, Port...)

and in the channel messages, for example
   {ssh_channel_up, ChanId, C}
   {ssh_cm, C, {data,...}}
    ....

I'll make this asap.
/Hans

Från: Christofer Tornkvist (ctornkvi) <[hidden email]>
Skickat: den 19 februari 2020 15:25
Till: Hans Nilsson R <[hidden email]>; Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hi Hans,

is the SshConnection the same as the Pid of the Connection Handler ?

Or put otherwise, is it so that, my callback channel module should know about this SshConnection ?

If that is the case, then this solution would be great.

Regards
/Christofer

Från: erlang-questions <[hidden email]> för Hans Nilsson R <[hidden email]>
Skickat: den 19 februari 2020 13:45
Till: Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hej Per!

So an ssh:setopts(SshConnection, InetOptions) and an ssh:getopts similar to two functions in inet would solve the problem?

/Hans


Från: erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
Skickat: den 18 februari 2020 14:08
Till: [hidden email] <[hidden email]>
Ämne: Re: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
On 2020-02-18 12:58, Hans Nilsson R wrote:
> It is both possible and documented to give the gen_tcp:connect_options() in a call to ssh:connect.
>
> See
>     https://protect2.fireeye.com/v1/url?k=6eb80c5a-326c0004-6eb84cc1-8691959ed9b7-0b75d45a9ce427c8&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fssh.html%23type-client_option
>
> where second from last is a link to
>     https://protect2.fireeye.com/v1/url?k=a1d9ada1-fd0da1ff-a1d9ed3a-8691959ed9b7-d0da1a82086ec97e&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fgen_tcp.html%23type-connect_option

Sorry, don't know how I missed that - too much going back and forth
between the "textual" man pages for ssh and gen_tcp, perhaps... And
indeed gen_tcp:listen_option() is also listed for daemon_option(). So
there is no problem whatsoever with setting DSCP at the start of a
connection.

Is there also some "clean" way within ssh to address Christofer's and
Dmytro's original question (below), which I managed to obscure - i.e.
setting DSCP for an already established connection? (Which is needed
for an implementation of RFC 8639.)

--Per

> Let's try:
>
> Eshell V10.6.4  (abort with ^G)
> 1> ssh:start().
> ok
> 2> dbg:start().
> {ok,<0.92.0>}
> 3> dbg:tracer().
> {ok,<0.92.0>}
> 4> dbg:p(all,c).
> {ok,[{matched,nonode@nohost,46}]}
> 5> dbg:tp(gen_tcp,connect,x).
> {ok,[{matched,nonode@nohost,2},{saved,x}]}
> 6>
> 6> ssh:connect(loopback, 22, [{nodelay,true}, {tos,14}, {raw,1,2,<<3>>}]).
> (<0.80.0>) call gen_tcp:connect({127,0,0,1},22,[{active,false},{raw,1,2,<<3>>},{tos,14},{nodelay,true}],infinity)
> (<0.80.0>) returned from gen_tcp:connect/4 -> {ok,#Port<0.6>}
> {ok,<0.99.0>}
> 7>
>
> The gen_tcp options in 6> are really passed down to gen_tcp:connect.
>
> /Hans
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *Från:* erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
> *Skickat:* den 17 februari 2020 20:44
> *Till:* [hidden email] <[hidden email]>
> *Ämne:* Re: Setting Dscp (tos, QoS) for ssh sockets
>
> On 2020-02-17 16:03, Per Hedeland wrote:
>  > On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
>  >  > As we discussed with you before, there are two options right now:
>  >  >
>  >  > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
>  >  > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
>  >  >
>  >  > Maybe someone sees other ways to do it?
>  >
>  > Why would you need to use inet:setopts/2 specifically? Changing DSCP
>  > on the fly is probably not meaningful in general, and from what I know
>  > about your application, not required there (but maybe I'm wrong about
>  > that).
>
> I learned off-list that this requirement comes from RFC 8639, where a
> NETCONF client/subscriber can request that the server uses a specific
> DSCP value in the "establish-subscription" RPC (which is sent in an
> already established session a.k.a. SSH channel). Surely OTP ssh should
> support this in a "nice/clean" way...?
>
>  > IMHO it would be reasonable to allow most/all options that can be
>  > given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
>  > 'tos' as option), respectively, also for ssh:connect/2,3,4 and
>  > ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
>  > as I can see.
>  >
>  > Alternatively you can at least for ssh:connect/2,3 apparently pass an
>  > already connected socket from gen_tcp:connect(), where you can pass
>  > 'tos' to the latter. It seems the socket that can be passed to
>  > ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
>  > natural to me to pass a "listen socket" from gen_tcp:listen() (which
>  > can be passed 'tos'), but I guess you can do the accept-loop outside
>  > ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
>  > passing it to ssh:daemon/2,3.
>
> For this alternative, the way to go would rather be to pass the 'tos'
> option to gen_tcp:listen(), and have it be "inherited" by the sockets
> returned from gen_tcp:accept() - i.e. no need for inet:setopts/2
> there. But of course neither alternative supports changing the DSCP
> value for an already established connection.
>
> --Per
>
>  >  > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <[hidden email]>> wrote:
>  >  >
>  >  >     Hi,
>  >  >
>  >  >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
>  >  >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
>  >  >
>  >  >     It should be possible to set the Dscp per IP packet sent.
>  >  >
>  >  >     How do I get hold of the Ssh socket down in my Ssh channel module ?
>  >  >
>  >  >
>  >  >     Regards
>  >  >     /Christofer
>  >  >
>  >  >
>  >  >
>

Reply | Threaded
Open this post in threaded view
|

Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets

Christofer Tornkvist (ctornkvi)
Hi,

sounds fantastic!

Do you know if it will be part of any minor OTP release in the near 3-4 months or so?

Thanks Hans!
Thanks Per for your dedicated involvement!

Regards
/Christofer

Från: Hans Nilsson R <[hidden email]>
Skickat: den 19 februari 2020 16:52
Till: Christofer Tornkvist (ctornkvi) <[hidden email]>; Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hi Christofer.

Yes, it is the C in
   {ok,C} = ssh:connect(Host, Port...)

and in the channel messages, for example
   {ssh_channel_up, ChanId, C}
   {ssh_cm, C, {data,...}}
    ....

I'll make this asap.
/Hans

Från: Christofer Tornkvist (ctornkvi) <[hidden email]>
Skickat: den 19 februari 2020 15:25
Till: Hans Nilsson R <[hidden email]>; Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hi Hans,

is the SshConnection the same as the Pid of the Connection Handler ?

Or put otherwise, is it so that, my callback channel module should know about this SshConnection ?

If that is the case, then this solution would be great.

Regards
/Christofer

Från: erlang-questions <[hidden email]> för Hans Nilsson R <[hidden email]>
Skickat: den 19 februari 2020 13:45
Till: Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hej Per!

So an ssh:setopts(SshConnection, InetOptions) and an ssh:getopts similar to two functions in inet would solve the problem?

/Hans


Från: erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
Skickat: den 18 februari 2020 14:08
Till: [hidden email] <[hidden email]>
Ämne: Re: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
On 2020-02-18 12:58, Hans Nilsson R wrote:
> It is both possible and documented to give the gen_tcp:connect_options() in a call to ssh:connect.
>
> See
>     https://protect2.fireeye.com/v1/url?k=6eb80c5a-326c0004-6eb84cc1-8691959ed9b7-0b75d45a9ce427c8&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fssh.html%23type-client_option
>
> where second from last is a link to
>     https://protect2.fireeye.com/v1/url?k=a1d9ada1-fd0da1ff-a1d9ed3a-8691959ed9b7-d0da1a82086ec97e&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fgen_tcp.html%23type-connect_option

Sorry, don't know how I missed that - too much going back and forth
between the "textual" man pages for ssh and gen_tcp, perhaps... And
indeed gen_tcp:listen_option() is also listed for daemon_option(). So
there is no problem whatsoever with setting DSCP at the start of a
connection.

Is there also some "clean" way within ssh to address Christofer's and
Dmytro's original question (below), which I managed to obscure - i.e.
setting DSCP for an already established connection? (Which is needed
for an implementation of RFC 8639.)

--Per

> Let's try:
>
> Eshell V10.6.4  (abort with ^G)
> 1> ssh:start().
> ok
> 2> dbg:start().
> {ok,<0.92.0>}
> 3> dbg:tracer().
> {ok,<0.92.0>}
> 4> dbg:p(all,c).
> {ok,[{matched,nonode@nohost,46}]}
> 5> dbg:tp(gen_tcp,connect,x).
> {ok,[{matched,nonode@nohost,2},{saved,x}]}
> 6>
> 6> ssh:connect(loopback, 22, [{nodelay,true}, {tos,14}, {raw,1,2,<<3>>}]).
> (<0.80.0>) call gen_tcp:connect({127,0,0,1},22,[{active,false},{raw,1,2,<<3>>},{tos,14},{nodelay,true}],infinity)
> (<0.80.0>) returned from gen_tcp:connect/4 -> {ok,#Port<0.6>}
> {ok,<0.99.0>}
> 7>
>
> The gen_tcp options in 6> are really passed down to gen_tcp:connect.
>
> /Hans
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *Från:* erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
> *Skickat:* den 17 februari 2020 20:44
> *Till:* [hidden email] <[hidden email]>
> *Ämne:* Re: Setting Dscp (tos, QoS) for ssh sockets
>
> On 2020-02-17 16:03, Per Hedeland wrote:
>  > On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
>  >  > As we discussed with you before, there are two options right now:
>  >  >
>  >  > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
>  >  > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
>  >  >
>  >  > Maybe someone sees other ways to do it?
>  >
>  > Why would you need to use inet:setopts/2 specifically? Changing DSCP
>  > on the fly is probably not meaningful in general, and from what I know
>  > about your application, not required there (but maybe I'm wrong about
>  > that).
>
> I learned off-list that this requirement comes from RFC 8639, where a
> NETCONF client/subscriber can request that the server uses a specific
> DSCP value in the "establish-subscription" RPC (which is sent in an
> already established session a.k.a. SSH channel). Surely OTP ssh should
> support this in a "nice/clean" way...?
>
>  > IMHO it would be reasonable to allow most/all options that can be
>  > given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
>  > 'tos' as option), respectively, also for ssh:connect/2,3,4 and
>  > ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
>  > as I can see.
>  >
>  > Alternatively you can at least for ssh:connect/2,3 apparently pass an
>  > already connected socket from gen_tcp:connect(), where you can pass
>  > 'tos' to the latter. It seems the socket that can be passed to
>  > ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
>  > natural to me to pass a "listen socket" from gen_tcp:listen() (which
>  > can be passed 'tos'), but I guess you can do the accept-loop outside
>  > ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
>  > passing it to ssh:daemon/2,3.
>
> For this alternative, the way to go would rather be to pass the 'tos'
> option to gen_tcp:listen(), and have it be "inherited" by the sockets
> returned from gen_tcp:accept() - i.e. no need for inet:setopts/2
> there. But of course neither alternative supports changing the DSCP
> value for an already established connection.
>
> --Per
>
>  >  > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <[hidden email]>> wrote:
>  >  >
>  >  >     Hi,
>  >  >
>  >  >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
>  >  >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
>  >  >
>  >  >     It should be possible to set the Dscp per IP packet sent.
>  >  >
>  >  >     How do I get hold of the Ssh socket down in my Ssh channel module ?
>  >  >
>  >  >
>  >  >     Regards
>  >  >     /Christofer
>  >  >
>  >  >
>  >  >
>

Reply | Threaded
Open this post in threaded view
|

Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets

Hans Nilsson R (AL/EAB)
Hi,
I'm aiming at OTP-22.3 which is planned for last part of March.  But if the tests go well, it will be in the maint branch on github next wwek.
/Hans


Från: Christofer Tornkvist (ctornkvi) <[hidden email]>
Skickat: den 20 februari 2020 07:49
Till: Hans Nilsson R <[hidden email]>; Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hi,

sounds fantastic!

Do you know if it will be part of any minor OTP release in the near 3-4 months or so?

Thanks Hans!
Thanks Per for your dedicated involvement!

Regards
/Christofer

Från: Hans Nilsson R <[hidden email]>
Skickat: den 19 februari 2020 16:52
Till: Christofer Tornkvist (ctornkvi) <[hidden email]>; Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hi Christofer.

Yes, it is the C in
   {ok,C} = ssh:connect(Host, Port...)

and in the channel messages, for example
   {ssh_channel_up, ChanId, C}
   {ssh_cm, C, {data,...}}
    ....

I'll make this asap.
/Hans

Från: Christofer Tornkvist (ctornkvi) <[hidden email]>
Skickat: den 19 februari 2020 15:25
Till: Hans Nilsson R <[hidden email]>; Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hi Hans,

is the SshConnection the same as the Pid of the Connection Handler ?

Or put otherwise, is it so that, my callback channel module should know about this SshConnection ?

If that is the case, then this solution would be great.

Regards
/Christofer

Från: erlang-questions <[hidden email]> för Hans Nilsson R <[hidden email]>
Skickat: den 19 februari 2020 13:45
Till: Per Hedeland <[hidden email]>; [hidden email] <[hidden email]>
Ämne: Sv: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
Hej Per!

So an ssh:setopts(SshConnection, InetOptions) and an ssh:getopts similar to two functions in inet would solve the problem?

/Hans


Från: erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
Skickat: den 18 februari 2020 14:08
Till: [hidden email] <[hidden email]>
Ämne: Re: Sv: Setting Dscp (tos, QoS) for ssh sockets
 
On 2020-02-18 12:58, Hans Nilsson R wrote:
> It is both possible and documented to give the gen_tcp:connect_options() in a call to ssh:connect.
>
> See
>     https://protect2.fireeye.com/v1/url?k=6eb80c5a-326c0004-6eb84cc1-8691959ed9b7-0b75d45a9ce427c8&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fssh.html%23type-client_option
>
> where second from last is a link to
>     https://protect2.fireeye.com/v1/url?k=a1d9ada1-fd0da1ff-a1d9ed3a-8691959ed9b7-d0da1a82086ec97e&q=1&e=1e4ceab2-3f29-4036-8a8c-cc4774d3d176&u=https%3A%2F%2Ferlang.org%2Fdoc%2Fman%2Fgen_tcp.html%23type-connect_option

Sorry, don't know how I missed that - too much going back and forth
between the "textual" man pages for ssh and gen_tcp, perhaps... And
indeed gen_tcp:listen_option() is also listed for daemon_option(). So
there is no problem whatsoever with setting DSCP at the start of a
connection.

Is there also some "clean" way within ssh to address Christofer's and
Dmytro's original question (below), which I managed to obscure - i.e.
setting DSCP for an already established connection? (Which is needed
for an implementation of RFC 8639.)

--Per

> Let's try:
>
> Eshell V10.6.4  (abort with ^G)
> 1> ssh:start().
> ok
> 2> dbg:start().
> {ok,<0.92.0>}
> 3> dbg:tracer().
> {ok,<0.92.0>}
> 4> dbg:p(all,c).
> {ok,[{matched,nonode@nohost,46}]}
> 5> dbg:tp(gen_tcp,connect,x).
> {ok,[{matched,nonode@nohost,2},{saved,x}]}
> 6>
> 6> ssh:connect(loopback, 22, [{nodelay,true}, {tos,14}, {raw,1,2,<<3>>}]).
> (<0.80.0>) call gen_tcp:connect({127,0,0,1},22,[{active,false},{raw,1,2,<<3>>},{tos,14},{nodelay,true}],infinity)
> (<0.80.0>) returned from gen_tcp:connect/4 -> {ok,#Port<0.6>}
> {ok,<0.99.0>}
> 7>
>
> The gen_tcp options in 6> are really passed down to gen_tcp:connect.
>
> /Hans
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> *Från:* erlang-questions <[hidden email]> för Per Hedeland <[hidden email]>
> *Skickat:* den 17 februari 2020 20:44
> *Till:* [hidden email] <[hidden email]>
> *Ämne:* Re: Setting Dscp (tos, QoS) for ssh sockets
>
> On 2020-02-17 16:03, Per Hedeland wrote:
>  > On 2020-02-17 11:22, Dmytro Lytovchenko wrote:
>  >  > As we discussed with you before, there are two options right now:
>  >  >
>  >  > 1. From SSH connection handler, using sys module, request its state (private #data{} record) which contains the socket in its 9th field.
>  >  > 2. (Christofer's idea) to replace the socket transport module using undocumented option {transport, {_, Module, _}}
>  >  >
>  >  > Maybe someone sees other ways to do it?
>  >
>  > Why would you need to use inet:setopts/2 specifically? Changing DSCP
>  > on the fly is probably not meaningful in general, and from what I know
>  > about your application, not required there (but maybe I'm wrong about
>  > that).
>
> I learned off-list that this requirement comes from RFC 8639, where a
> NETCONF client/subscriber can request that the server uses a specific
> DSCP value in the "establish-subscription" RPC (which is sent in an
> already established session a.k.a. SSH channel). Surely OTP ssh should
> support this in a "nice/clean" way...?
>
>  > IMHO it would be reasonable to allow most/all options that can be
>  > given to gen_tcp:connect/3,4 and gen_tcp:listen/2 (which both have
>  > 'tos' as option), respectively, also for ssh:connect/2,3,4 and
>  > ssh:daemon/2,3 - maybe it is allowed, but if so not documented, as far
>  > as I can see.
>  >
>  > Alternatively you can at least for ssh:connect/2,3 apparently pass an
>  > already connected socket from gen_tcp:connect(), where you can pass
>  > 'tos' to the latter. It seems the socket that can be passed to
>  > ssh:daemon/2,3 should be from gen_tcp:accept() - it would seem more
>  > natural to me to pass a "listen socket" from gen_tcp:listen() (which
>  > can be passed 'tos'), but I guess you can do the accept-loop outside
>  > ssh and use inet:setopts/2 on the socket from gen_tcp:accept() before
>  > passing it to ssh:daemon/2,3.
>
> For this alternative, the way to go would rather be to pass the 'tos'
> option to gen_tcp:listen(), and have it be "inherited" by the sockets
> returned from gen_tcp:accept() - i.e. no need for inet:setopts/2
> there. But of course neither alternative supports changing the DSCP
> value for an already established connection.
>
> --Per
>
>  >  > On Mon, 17 Feb 2020 at 11:12, Christofer Tornkvist (ctornkvi) <[hidden email] <[hidden email]>> wrote:
>  >  >
>  >  >     Hi,
>  >  >
>  >  >     I would like to set the quality of service flag Dscp of the Tos field in the IP packet
>  >  >     of an Ssh socket with the function inet:setopts(Socket, [{tos, Dscp}]).
>  >  >
>  >  >     It should be possible to set the Dscp per IP packet sent.
>  >  >
>  >  >     How do I get hold of the Ssh socket down in my Ssh channel module ?
>  >  >
>  >  >
>  >  >     Regards
>  >  >     /Christofer
>  >  >
>  >  >
>  >  >
>