On Saturday 17 December 2016 05:07, Wildman conveyed the following to
alt.os.linux...
> With your knowledge of the underbelly of Linux, I was hoping
> you will be able to answer a question for me.
Well, I am flattered that you think so highly of my expertise, but I'm
afraid this particular area is way out of my league. :-/
> For a project I am working on, I want to replicate this in
> Python: ip -s link show eth0
>
> I have most of it worked out by using the info found here:
> /sys/class/net/eth0/ and this file: /proc/net/dev.
>
> There is one thing I cannot figure out and that has to do
> with the interface flags. When I use the 'ip' command
> above, I get this for the flags:
> BROADCAST, MULTICAST, UP, LOWER_UP
>
> If I do 'cat /sys/class/net/eth0/flags' I get 0x1003 which
> translates to UP(bit0), BROADCAST(bit1), MULTICAST(bit12).
> LOWER_UP is not included.
>
> In the kernel source the flags are declared here:
> include/uapi/linux/if.h
>
> Below are the declares form the source and as you can see
> IFF_LOWER_UP is in the 'extended' flags using bit 16. The
> flags file I believe is 16 bits (0 to 15).
Well, I don't know whether the flags file ─ which, as everything under
/sys, is only a pseudofile, but I'm guessing you know that already ─
only covers 16 bits, but the hexadecimal number 0x1003 translates to a
13 bit value.
Like I said, this is out of my league, but my guess from the above would
be that the bits commented as "volatile" are not exported via sysfs.
Maybe they are stored in a socket file instead?
Maybe one of the real gurus can jump in? :-/
--
= Aragorn =