Thread (30 messages) flat view 30 messages, 3 authors, 2021-01-18

Re: [PATCH v6 net-next 11/15] net: catch errors from dev_get_stats

From: Vladimir Oltean <olteanv@gmail.com>
Date: 2021-01-12 00:35:11

On Mon, Jan 11, 2021 at 02:54:50PM -0800, Saeed Mahameed wrote:
On Sat, 2021-01-09 at 19:26 +0200, Vladimir Oltean wrote:
quoted
From: Vladimir Oltean <vladimir.oltean@nxp.com>

dev_get_stats can now return error codes. Convert all remaining call
sites to look at that error code and stop processing.

The effects of simulating a kernel error (returning -ENOMEM) upon
existing programs or kernel interfaces:

- ifconfig and "cat /proc/net/dev" print up until the interface that
  failed, and there they return:
cat: read error: Cannot allocate memory

- ifstat and "ip -s -s link show":
RTNETLINK answers: Cannot allocate memory
Dump terminated

Some call sites are coming from a context that returns void (ethtool
stats, workqueue context). So since we can't report to the upper
layer,
do the next best thing: print an error to the console.
another concern, one buggy netdev driver in a system will cause
unnecessary global failures when reading stats via netlink/procfs for
all the netdev in a netns, when other drivers will be happy to report.

can't we just show a message in that driver's stats line about the
occurred err ? and show the normal stats line of all others ?
So you're worried that user space apps won't handle an error code when
reading from a file, but you're not worried that they'll start scraping
junk from procfs when we print this?

cat /proc/net/dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed
    lo:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
 bond0: Cannot allocate memory
  sit0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help