Setting Dscp (tos, QoS) for ssh sockets
Per Hedeland
per@REDACTED
Mon Feb 17 20:44:18 CET 2020
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) <ctornkvi@REDACTED <mailto:ctornkvi@REDACTED>> 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
> >
> >
> >
More information about the erlang-questions
mailing list