send without tab! netstat address family and interface, well-known protocols

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

send without tab! netstat address family and interface, well-known protocols

marfabastewart
I apologize!!! I have my mail client set to use plaintext
so I didn't think tabs woud be a problem. I'm
re-posting with just spaces.

Synopsis:    netstat address family and interface, well-known protocols
Category:    user
Environment:
    System      : OpenBSD 6.7
    Details     : OpenBSD 6.7-current (GENERIC.MP) #351: Wed Jul 15 16:57:00 MDT 2020
             [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP

    Architecture: OpenBSD.amd64
    Machine     : amd64
Description:
    netstat doesn't limit output to address family when used with -I, and protocol list problem
How-To-Repeat:
    netstat -f inet -s -I lo0
    or
    netstat -s -f inet -I lo0
    netstat -f inet -I lo0

    Any interface can be used instead of lo0.
    Netstat shows ipv6 information also although man netstat says
        If the -f address_family option (with the -s option) is present,
            show per-interface statistics on the given interface for the
            specified address_family.

    (It does, but doesn't limit output to the specified address_family.)

    netstat -p only works for the protocols hard-coded in the protox struct in
    /usr/src/usr.bin/netstat/main.c

Fix:
    I'm not too well-versed in C (as perhaps my questions make clear)
    but happy to try to offer patches if someone would suggest
    the general direction of changes to make (and if the whole problem is not EBKAC).

    I note that netstat -f inet works but adding the -I doesn't seem to work.
    Is it because if iflag is set, we call intpr:
        if (iflag) {
            intpr(interval, repeatcount);
            exit(0);
        }
    in lines 295-296 in /usr/src/usr.bin/netstat/main.c?

    For the protocol problem, I see the call to getprotoent but
    no call to getprotobyname in the name2protox function in
    /usr/src/usr.b/in/netstat/main.c





Reply | Threaded
Open this post in threaded view
|

Re: send without tab! netstat address family and interface, well-known protocols

Jason McIntyre-2
On Sat, Jul 18, 2020 at 03:17:05PM +0000, marfabastewart wrote:

> I apologize!!! I have my mail client set to use plaintext
> so I didn't think tabs woud be a problem. I'm
> re-posting with just spaces.
>
> Synopsis:    netstat address family and interface, well-known protocols
> Category:    user
> Environment:
>     System      : OpenBSD 6.7
>     Details     : OpenBSD 6.7-current (GENERIC.MP) #351: Wed Jul 15 16:57:00 MDT 2020
>              [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>
>     Architecture: OpenBSD.amd64
>     Machine     : amd64
> Description:
>     netstat doesn't limit output to address family when used with -I, and protocol list problem
> How-To-Repeat:
>     netstat -f inet -s -I lo0
>     or
>     netstat -s -f inet -I lo0
>     netstat -f inet -I lo0
>
>     Any interface can be used instead of lo0.
>     Netstat shows ipv6 information also although man netstat says
>         If the -f address_family option (with the -s option) is present,
>             show per-interface statistics on the given interface for the
>             specified address_family.
>
>     (It does, but doesn't limit output to the specified address_family.)
>
>     netstat -p only works for the protocols hard-coded in the protox struct in
>     /usr/src/usr.bin/netstat/main.c
>
> Fix:
>     I'm not too well-versed in C (as perhaps my questions make clear)
>     but happy to try to offer patches if someone would suggest
>     the general direction of changes to make (and if the whole problem is not EBKAC).
>
>     I note that netstat -f inet works but adding the -I doesn't seem to work.
>     Is it because if iflag is set, we call intpr:
>         if (iflag) {
>             intpr(interval, repeatcount);
>             exit(0);
>         }
>     in lines 295-296 in /usr/src/usr.bin/netstat/main.c?
>
>     For the protocol problem, I see the call to getprotoent but
>     no call to getprotobyname in the name2protox function in
>     /usr/src/usr.b/in/netstat/main.c
>
>

hi.

at the very least, there is a doc bug here. before the last change to
netstat.1, we showed -I and -f being compatible, in SYNOPSIS. in the
most recent change to netstat.1, i removed that after some help from
guenther in trying to track down what actually works. the -f text in the
description of -I remained.

i will try to work out whether it's a doc fix or a code fix (i.e. bug
those who know).

jmc

Reply | Threaded
Open this post in threaded view
|

Re: send without tab! netstat address family and interface, well-known protocols

Jason McIntyre-2
On Sat, Jul 18, 2020 at 05:37:40PM +0100, Jason McIntyre wrote:

> On Sat, Jul 18, 2020 at 03:17:05PM +0000, marfabastewart wrote:
> > I apologize!!! I have my mail client set to use plaintext
> > so I didn't think tabs woud be a problem. I'm
> > re-posting with just spaces.
> >
> > Synopsis:    netstat address family and interface, well-known protocols
> > Category:    user
> > Environment:
> >     System      : OpenBSD 6.7
> >     Details     : OpenBSD 6.7-current (GENERIC.MP) #351: Wed Jul 15 16:57:00 MDT 2020
> >              [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> >
> >     Architecture: OpenBSD.amd64
> >     Machine     : amd64
> > Description:
> >     netstat doesn't limit output to address family when used with -I, and protocol list problem
> > How-To-Repeat:
> >     netstat -f inet -s -I lo0
> >     or
> >     netstat -s -f inet -I lo0
> >     netstat -f inet -I lo0
> >
> >     Any interface can be used instead of lo0.
> >     Netstat shows ipv6 information also although man netstat says
> >         If the -f address_family option (with the -s option) is present,
> >             show per-interface statistics on the given interface for the
> >             specified address_family.
> >
> >     (It does, but doesn't limit output to the specified address_family.)
> >
> >     netstat -p only works for the protocols hard-coded in the protox struct in
> >     /usr/src/usr.bin/netstat/main.c
> >
> > Fix:
> >     I'm not too well-versed in C (as perhaps my questions make clear)
> >     but happy to try to offer patches if someone would suggest
> >     the general direction of changes to make (and if the whole problem is not EBKAC).
> >
> >     I note that netstat -f inet works but adding the -I doesn't seem to work.
> >     Is it because if iflag is set, we call intpr:
> >         if (iflag) {
> >             intpr(interval, repeatcount);
> >             exit(0);
> >         }
> >     in lines 295-296 in /usr/src/usr.bin/netstat/main.c?
> >
> >     For the protocol problem, I see the call to getprotoent but
> >     no call to getprotobyname in the name2protox function in
> >     /usr/src/usr.b/in/netstat/main.c
> >
> >
>
> hi.
>
> at the very least, there is a doc bug here. before the last change to
> netstat.1, we showed -I and -f being compatible, in SYNOPSIS. in the
> most recent change to netstat.1, i removed that after some help from
> guenther in trying to track down what actually works. the -f text in the
> description of -I remained.
>
> i will try to work out whether it's a doc fix or a code fix (i.e. bug
> those who know).
>
> jmc

so, philip guenther did all the hard work: it seems the text additions
were made 21 years ago with ip6 support, but the code was never added.
so the current SYNOPSIS was (and still is) correct: -f is not used with
-I. the text in -I describing -f was wrong, and i've just removed it.

thanks for your mail,
jmc

Reply | Threaded
Open this post in threaded view
|

Re: send without tab! netstat address family and interface, well-known protocols

marfabastewart
> > >     netstat -p only works for the protocols hard-coded in the protox struct in
> > >     /usr/src/usr.bin/netstat/main.c
> > >

> > >
> > >     For the protocol problem, I see the call to getprotoent but
> > >     no call to getprotobyname in the name2protox function in
> > >     /usr/src/usr.b/in/netstat/main.c
> > >
> >
>
> so, philip guenther did all the hard work: it seems the text additions
> were made 21 years ago with ip6 support, but the code was never added.
> so the current SYNOPSIS was (and still is) correct: -f is not used with
> -I. the text in -I describing -f was wrong, and i've just removed it.
>
> thanks for your mail,
> jmc

Hi, thank you very much for your quick reply.
It also appears that netstat isn't checking /etc/protcols
when the -p option is called:

$netstat -an -p rdp
netstat: rdp: unknown protocol

although rdp is in /etc/protocols.

In contrast, other protocols in struct protx
do get a different response:

$netstat -an -p icmp
netstat: no protocol handler for protocol icmp

Although I admit I don't know enough to know
whether it would make sense to generate statistics
for icmp.

Of course other protocols like tcp do work without
problems.


Reply | Threaded
Open this post in threaded view
|

Re: send without tab! netstat address family and interface, well-known protocols

Jason McIntyre-2
On Sat, Jul 18, 2020 at 08:11:15PM +0000, marfabastewart wrote:

> > > >     netstat -p only works for the protocols hard-coded in the protox struct in
> > > >     /usr/src/usr.bin/netstat/main.c
> > > >
>
> > > >
> > > >     For the protocol problem, I see the call to getprotoent but
> > > >     no call to getprotobyname in the name2protox function in
> > > >     /usr/src/usr.b/in/netstat/main.c
> > > >
> > >
> >
> > so, philip guenther did all the hard work: it seems the text additions
> > were made 21 years ago with ip6 support, but the code was never added.
> > so the current SYNOPSIS was (and still is) correct: -f is not used with
> > -I. the text in -I describing -f was wrong, and i've just removed it.
> >
> > thanks for your mail,
> > jmc
>
> Hi, thank you very much for your quick reply.
> It also appears that netstat isn't checking /etc/protcols
> when the -p option is called:
>
> $netstat -an -p rdp
> netstat: rdp: unknown protocol
>
> although rdp is in /etc/protocols.
>

well, netstat(1) does not claim to read /etc/protocols, only
that some well known protocols may be listed there:

                 Some protocol names and aliases are listed in the
                 file /etc/protocols.

> In contrast, other protocols in struct protx
> do get a different response:
>
> $netstat -an -p icmp
> netstat: no protocol handler for protocol icmp
>
> Although I admit I don't know enough to know
> whether it would make sense to generate statistics
> for icmp.
>

i'm not sure whether the combination makes sense. looking at SYNOPSIS,
it does suggest it should work. but if you run "-an" without -p it will
show you what protocols are supported for that usage (not icmp).

you want -s for stats:

        $ netstat -s -p icmp

> Of course other protocols like tcp do work without
> problems.
>

so we could easily add a list of the supported protocol names to -p. i
guess most people will know what makes sense, and if you try "netstat -p
bob" and it errors out, you'll know it isn;t supported. so i'm unsure
whether it's worth adding such a list. personally i think it probably
should...

jmc