Hi Marco,

Thank you for your reply!

On 21/09/2022 12:25, Marco d'Itri wrote:
> On Sep 20, Matthieu Baerts <matthieu.bae...@tessares.net> wrote:
> 
>> Would it be acceptable to add Linux specific "internal" protocols in
>> /etc/protocols?
> If they never appear on the wire then I am not sure.
> Do tools like ss show them?

For MPTCP, it doesn't appear on the wire but the protocol number is used
when creating a socket:

    fd = socket(AF_INET(6), SOCK_STREAM, IPPROTO_MPTCP);

That's what was acceptable to do for Network Linux maintainers.
The protocol number is also used when listing connections.

'ss' is probably not a good example because it has already been patched
to list MPTCP sockets. Also, they use an internal function to convert
the protocol number to a name:

https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=9c3be2c0eee01be7832b7900a8be798a19c659a5

But other tools listing sockets might use getprotobynumber() to display
a name instead of a number (if they don't fail because MPTCP is not
supported by getprotobynumber() on Debian so far).


>> Still, having them in /etc/protocols will help programs using
>> getprotobyname() or getprotobynumber() like Perl and others are doing to
>> support these protocols but also to display the proper info about them.
> Can you point me to real world code?

The one that triggered the opening of this bug report is when we looked
at providing an example of using MPTCP in Perl. For TCP, a socket is
typically created like this (c.f. "man perlipc"):

  socket(my $sock, PF_INET, SOCK_STREAM, getprotobyname("tcp"));

For MPTCP, it is not possible to use...

  getprotobyname("mptcp")

... if /etc/protocols has not been updated. Instead, it is required to
define a tuple which is different from the usual way and a bit "dirty".

Regarding real world code, I'm not a Perl dev but that seems to be quite
common to do that, see:

https://codesearch.debian.net/search?q=getprotobyname%28%22tcp%22%29&literal=1
https://github.com/search?q=getprotobyname%28%22tcp%22%29&type=code

It looks like a way of coding with Perl because they also do something
similar when trying to find which port to use, e.g.:

  my $port = getservbyname "http", "tcp";


I don't know if there are programs having an option to use a protocol
defined in a config as a string, e.g. "tcp". Maybe some rely on
getprotobyname(), maybe others use hardcoded values.

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

Reply via email to