how does /sys/class/net/*/operstate work?

2

I'm looking for a way to check network state for a 'control panel' site. For the most part it appears that the tree /sys/class/net/*/ has the appropriate information. The confusing part is the operstate file seems to have three modes:

  • up
  • down
  • unknown

When I first query this for a known working NIC its either 'up' or 'unknown'. If I pull the wire its 'down'. Reconnecting will give 'up'. So why the 'unknown'? And it doesn't work at all for wireless access points - always 'down'.

ethrbunny

Posted 2013-12-04T19:24:49.990

Reputation: 347

Answers

1

As it is explained in Documentation/networking/operstates.txt in kernel sources:

IF_OPER_UNKNOWN (0):
 Interface is in unknown state, neither driver nor userspace has set
 operational state. Interface must be considered for user data as
 setting operational state has not been implemented in every driver.

Iavael

Posted 2013-12-04T19:24:49.990

Reputation: 11