You are not logged in.

#1 2015-04-21 10:55:58

sakishrist
Member
Registered: 2012-03-04
Posts: 42

Network interface modes

Hello *,

I would like to know where ethtool gets it's information on the modes (10baseT Full etc) that an interface supports.

I can always use grep in my script but was just wondering if there is maybe something in /sys that could provice that info to me (already searched there though). And human readable seems less error-prone to me.

Thanks in advance!

Offline

#2 2015-04-21 11:17:06

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,524
Website

Re: Network interface modes

ethtool uses system calls to get information from the kernel - it looks like this is done with functions defined in /usr/include/net/if.h.

If you want to do this in a compiled program, that should do it.  But it sounds like you just want to do this from a script, so that wouldn't work.

You say you use grep - what exactly do you grep?  I suspect the output of `ip` might be most useful.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2015-04-21 11:46:32

sakishrist
Member
Registered: 2012-03-04
Posts: 42

Re: Network interface modes

Currently I grep for something like this:

ethtool $i | egrep -q "10(0(0)?)?baseT/Full"

What I need to know is that the card is not a 10G (or more) and that it is not a virtio interface. Currently that handles the situation but I was wondering if there is something cleaner.

For 10G links I could grep for

Supported ports: [ FIBRE ]

but then, virtio interfaces return nothing at all with ethtool.

I'm not really sure how to do this with ip. By the way, I am more interested in the available link modes than the currently negotiated mode.

Thanks

Offline

#4 2015-04-21 12:24:33

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,524
Website

Re: Network interface modes

I stand corrected, I don't know if ip can provided those details.  I thought you were looking for alternatives to ethtool which I'm not familiar with aside from a quick glance at the code.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB