2
box101:~ # cat /sys/class/net/eno1/carrier
cat: /sys/class/net/eno1/carrier: Invalid argument

What the...? OK, so what does strace say?

...
open("/sys/class/net/eno1/carrier", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=4096, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
read(3, 0x19c8000, 65536) = -1 EINVAL (Invalid argument)
...

So let me get this straight... The file opens perfectly, yet reading from it is somehow an error?

What's more annoying is that on box103, the exact same command works perfectly! On box101, I can read every single file in that directory except carrier.

Can anyone explain what the hell is going on here?

  • What hardware is that eno1? Which driver does it use? – Milind Dumbare Mar 18 '15 at 13:53
  • 1
    There are some issues with hardware/driver as explained on this LKML thread - lkml.org/lkml/2010/3/22/602 - Even when you have link(cable connected) it will prompt you the -EINVAL error. Power management configurations may issue this error too on an interface that is already plugged and up. – user34720 Mar 18 '15 at 14:06
  • So if the device is powered off, you can "expect" this file to not work? (Now I'm wondering why the heck the kernel doesn't just not display the file, or at least assume false, rather than doing something very strange like this...) You could probably post that as an actual answer. – MathematicalOrchid Mar 18 '15 at 14:37
3

There are some issues with hardware/driver as explained on this LKML thread. Quoting just a little part of the reply mail:

The reason is that most drivers don't even probe the link or negotiate link speed and flow control until the device is brought up. Many don't even power up the PHY when the device is down, in order to save power.

So the behavior you observe is completely expected.

Even when you have link(cable connected) it will prompt you the -EINVAL error. Power management configurations may issue this error too on an interface that is already plugged and up.

mii-tool and ethtool should be more reliable on giving you information about link state of the ethernet interface(maybe ip l l).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.