From: Jarod Wilson <hidden> Date: 2016-01-22 19:12:10
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
p7p1: 14783346 140430 0 140428 0 0 0 2040 680 8 0 0 0 0 0 0
p7p2: 14805198 140648 0 0 0 0 0 2034 0 0 0 0 0 0 0 0
bond0: 53365248 532798 0 421160 0 0 0 115151 2040 24 0 0 0 0 0 0
lo: 5420 54 0 0 0 0 0 0 5420 54 0 0 0 0 0 0
p5p1: 19292195 196197 0 140368 0 0 0 56564 680 8 0 0 0 0 0 0
p5p2: 19289707 196171 0 140364 0 0 0 56547 680 8 0 0 0 0 0 0
em3: 20996626 158214 0 0 0 0 0 383 0 0 0 0 0 0 0 0
em2: 14065122 138462 0 0 0 0 0 310 0 0 0 0 0 0 0 0
em1: 14063162 138440 0 0 0 0 0 308 0 0 0 0 0 0 0 0
em4: 21050830 158729 0 0 0 0 0 385 71662 469 0 0 0 0 0 0
ib0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In this scenario, p5p1, p5p2 and p7p1 are all inactive slaves in an
active-backup bond0, and you can see that all three have high drop counts,
with the master bond0 showing a tally of all three.
I know that this was previously discussed some here:
http://www.spinics.net/lists/netdev/msg226341.html
It seems additional counters never came to fruition, but honestly, for
this particular case, I'm not even sure they're warranted, I'd be inclined
to say just silently drop these packets without incrementing a counter. At
least, that's probably what would make someone who has complained loudly
about this issue happy, as they have monitoring tools that are squaking
loudly at any increments to rx_dropped.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
net/core/dev.c | 3 +++
1 file changed, 3 insertions(+)
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
From: Jay Vosburgh <hidden> Date: 2016-01-22 20:59:26
Jarod Wilson [off-list ref] wrote:
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
[...]
In this scenario, p5p1, p5p2 and p7p1 are all inactive slaves in an
active-backup bond0, and you can see that all three have high drop counts,
with the master bond0 showing a tally of all three.
I know that this was previously discussed some here:
http://www.spinics.net/lists/netdev/msg226341.html
It seems additional counters never came to fruition, but honestly, for
this particular case, I'm not even sure they're warranted, I'd be inclined
to say just silently drop these packets without incrementing a counter. At
least, that's probably what would make someone who has complained loudly
about this issue happy, as they have monitoring tools that are squaking
loudly at any increments to rx_dropped.
I don't think the kernel should silently drop packets; there
should be a counter somewhere. If a packet is being thrown away
deliberately, it should not just vanish into the screaming void of
space. Someday someone will try and track down where that packet is
being dropped.
I've had that same conversation with customers who insist on
accounting for every packet drop (from the "any drop is an error"
mindset), so I understand the issue.
Thinking about the prior discussion, the rx_drop_inactive is
still a good idea, but I'd actually today get good use from a
"rx_drop_unforwardable" (or an equivalent but shorter name) counter that
counts every time a packet is dropped due to is_skb_forwardable()
returning false. __dev_forward_skb does this (and hits rx_dropped), as
does the bridge (and does not count it).
-J
quoted hunk
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
net/core/dev.c | 3 +++
1 file changed, 3 insertions(+)
else
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
} else {
+ if (deliver_exact)
+ goto inactive; /* bond or team inactive slave */
drop:
atomic_long_inc(&skb->dev->rx_dropped);
+inactive:
kfree_skb(skb);
/* Jamal, now you will not able to escape explaining
* me how you were going to use this. :-)
--
1.8.3.1
Fri, Jan 22, 2016 at 08:11:22PM CET, jarod@redhat.com wrote:
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
p7p1: 14783346 140430 0 140428 0 0 0 2040 680 8 0 0 0 0 0 0
p7p2: 14805198 140648 0 0 0 0 0 2034 0 0 0 0 0 0 0 0
bond0: 53365248 532798 0 421160 0 0 0 115151 2040 24 0 0 0 0 0 0
lo: 5420 54 0 0 0 0 0 0 5420 54 0 0 0 0 0 0
p5p1: 19292195 196197 0 140368 0 0 0 56564 680 8 0 0 0 0 0 0
p5p2: 19289707 196171 0 140364 0 0 0 56547 680 8 0 0 0 0 0 0
em3: 20996626 158214 0 0 0 0 0 383 0 0 0 0 0 0 0 0
em2: 14065122 138462 0 0 0 0 0 310 0 0 0 0 0 0 0 0
em1: 14063162 138440 0 0 0 0 0 308 0 0 0 0 0 0 0 0
em4: 21050830 158729 0 0 0 0 0 385 71662 469 0 0 0 0 0 0
ib0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In this scenario, p5p1, p5p2 and p7p1 are all inactive slaves in an
active-backup bond0, and you can see that all three have high drop counts,
with the master bond0 showing a tally of all three.
I know that this was previously discussed some here:
http://www.spinics.net/lists/netdev/msg226341.html
It seems additional counters never came to fruition, but honestly, for
this particular case, I'm not even sure they're warranted, I'd be inclined
to say just silently drop these packets without incrementing a counter. At
least, that's probably what would make someone who has complained loudly
about this issue happy, as they have monitoring tools that are squaking
loudly at any increments to rx_dropped.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
Acked-by: Jiri Pirko <redacted>
I think this should be considered as a bug and go to -net.
Fri, Jan 22, 2016 at 09:59:12PM CET, jay.vosburgh@canonical.com wrote:
Jarod Wilson [off-list ref] wrote:
quoted
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
[...]
quoted
In this scenario, p5p1, p5p2 and p7p1 are all inactive slaves in an
active-backup bond0, and you can see that all three have high drop counts,
with the master bond0 showing a tally of all three.
I know that this was previously discussed some here:
http://www.spinics.net/lists/netdev/msg226341.html
It seems additional counters never came to fruition, but honestly, for
this particular case, I'm not even sure they're warranted, I'd be inclined
to say just silently drop these packets without incrementing a counter. At
least, that's probably what would make someone who has complained loudly
about this issue happy, as they have monitoring tools that are squaking
loudly at any increments to rx_dropped.
In this case, it is delivered with exact delivery according to per-dev
registered callback. We just have to avoid it gets to bond. So this case
is not "to drop", but rather "to block skb to don't get where it does
not belong".
I don't think the kernel should silently drop packets; there
should be a counter somewhere. If a packet is being thrown away
deliberately, it should not just vanish into the screaming void of
space. Someday someone will try and track down where that packet is
being dropped.
I've had that same conversation with customers who insist on
accounting for every packet drop (from the "any drop is an error"
mindset), so I understand the issue.
Thinking about the prior discussion, the rx_drop_inactive is
still a good idea, but I'd actually today get good use from a
"rx_drop_unforwardable" (or an equivalent but shorter name) counter that
counts every time a packet is dropped due to is_skb_forwardable()
returning false. __dev_forward_skb does this (and hits rx_dropped), as
does the bridge (and does not count it).
-J
quoted
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
net/core/dev.c | 3 +++
1 file changed, 3 insertions(+)
else
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
} else {
+ if (deliver_exact)
+ goto inactive; /* bond or team inactive slave */
drop:
atomic_long_inc(&skb->dev->rx_dropped);
+inactive:
kfree_skb(skb);
/* Jamal, now you will not able to escape explaining
* me how you were going to use this. :-)
--
1.8.3.1
From: Andy Gospodarek <hidden> Date: 2016-01-23 14:19:50
On Fri, Jan 22, 2016 at 02:11:22PM -0500, Jarod Wilson wrote:
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
p7p1: 14783346 140430 0 140428 0 0 0 2040 680 8 0 0 0 0 0 0
p7p2: 14805198 140648 0 0 0 0 0 2034 0 0 0 0 0 0 0 0
bond0: 53365248 532798 0 421160 0 0 0 115151 2040 24 0 0 0 0 0 0
lo: 5420 54 0 0 0 0 0 0 5420 54 0 0 0 0 0 0
p5p1: 19292195 196197 0 140368 0 0 0 56564 680 8 0 0 0 0 0 0
p5p2: 19289707 196171 0 140364 0 0 0 56547 680 8 0 0 0 0 0 0
em3: 20996626 158214 0 0 0 0 0 383 0 0 0 0 0 0 0 0
em2: 14065122 138462 0 0 0 0 0 310 0 0 0 0 0 0 0 0
em1: 14063162 138440 0 0 0 0 0 308 0 0 0 0 0 0 0 0
em4: 21050830 158729 0 0 0 0 0 385 71662 469 0 0 0 0 0 0
ib0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In this scenario, p5p1, p5p2 and p7p1 are all inactive slaves in an
active-backup bond0, and you can see that all three have high drop counts,
with the master bond0 showing a tally of all three.
I know that this was previously discussed some here:
http://www.spinics.net/lists/netdev/msg226341.html
It seems additional counters never came to fruition, but honestly, for
this particular case, I'm not even sure they're warranted, I'd be inclined
to say just silently drop these packets without incrementing a counter. At
least, that's probably what would make someone who has complained loudly
about this issue happy, as they have monitoring tools that are squaking
loudly at any increments to rx_dropped.
I completely agree.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
Note that if you still have a kfree_skb() instead of consume_skb(),
some tools will still give you a wrong signal (packet dropped ...).
But then maybe the signal is telling some truth.
We receive a packet, and decide to drop it because no one was willing to
handle it.
Maybe someone wants to know a particular slave receives 10,000 such
frames per second and hurts performance with useless work.
We should at least increment some counter and maybe dump it with
"ethtool -S" or something.
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
--
1.8.3.1
I agree that rx_dropped is not the correct stat to bump here, but
I'm totally against the event disappearing completely into thin
air.
You have to replace the rx_dropped bump with _something_.
The only reason this hasn't been "fixed" yet is that everyone is
too damn lazy to implement that "something".
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
--
1.8.3.1
I agree that rx_dropped is not the correct stat to bump here, but
I'm totally against the event disappearing completely into thin
air.
You have to replace the rx_dropped bump with _something_.
The only reason this hasn't been "fixed" yet is that everyone is
too damn lazy to implement that "something".
Would you want to see all things that shouldn't increment rx_dropped come
in one shot, along with the four or so other counters, as discussed in the
prior thread, or can they be done piecemeal? To date, I'm really only
familiar with this particular case, and could probably get something
together this week. To address the rest, I'd have to poke around a bit
more and see what there is to see and do.
--
Jarod Wilson
jarod@redhat.com
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
I agree that rx_dropped is not the correct stat to bump here, but
I'm totally against the event disappearing completely into thin
air.
You have to replace the rx_dropped bump with _something_.
The only reason this hasn't been "fixed" yet is that everyone is
too damn lazy to implement that "something".
Would you want to see all things that shouldn't increment rx_dropped come
in one shot, along with the four or so other counters, as discussed in the
prior thread, or can they be done piecemeal? To date, I'm really only
familiar with this particular case, and could probably get something
together this week. To address the rest, I'd have to poke around a bit
more and see what there is to see and do.
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
Note that if you still have a kfree_skb() instead of consume_skb(),
some tools will still give you a wrong signal (packet dropped ...).
But then maybe the signal is telling some truth.
We receive a packet, and decide to drop it because no one was willing to
handle it.
Maybe someone wants to know a particular slave receives 10,000 such
frames per second and hurts performance with useless work.
We should at least increment some counter and maybe dump it with
"ethtool -S" or something.
I've been digging into ethtool -S a little bit, and am somewhat at a loss
as to how I would wire into this. From what I've been able to figure out,
it's entirely device-specific-ish counters spit out. On my sfc cards, I
get rx_noskb_drops and rx_nodesc_drop_cnt output from ethtool -S, but for
the core network stack, these are actually added up and shoved into
rx_dropped, and no other network driver has those two individual counters.
By itself, rx_dropped isn't output directly anywhere from ethtool,
so far as I can see. And ethtool -S bondX shows absolutely nothing.
*Should* ethtool -S be dumping all the network core stats? I have to say I
was more than a little surprised at this:
# ethtool -S bond0
no stats available
Particularly given that if I look in /proc/net/dev or
/sys/devices/virtual/net/bond0/statistics/*, there are quite a few stats
that are being tracked and make their way out to userspace...
--
Jarod Wilson
jarod@redhat.com
From: David Miller <davem@davemloft.net> Date: 2016-01-26 21:21:06
From: Jarod Wilson <redacted>
Date: Tue, 26 Jan 2016 16:14:53 -0500
# ethtool -S bond0
no stats available
ethtool -S is for device specific stats.
Some drivers use this facility to provide per-RX-queue and per-TX-queue
versions of the existing core netdev stats.
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
Note that if you still have a kfree_skb() instead of consume_skb(),
some tools will still give you a wrong signal (packet dropped ...).
But then maybe the signal is telling some truth.
We receive a packet, and decide to drop it because no one was willing to
handle it.
Maybe someone wants to know a particular slave receives 10,000 such
frames per second and hurts performance with useless work.
We should at least increment some counter and maybe dump it with
"ethtool -S" or something.
I've been digging into ethtool -S a little bit, and am somewhat at a loss
as to how I would wire into this. From what I've been able to figure out,
it's entirely device-specific-ish counters spit out. On my sfc cards, I
get rx_noskb_drops and rx_nodesc_drop_cnt output from ethtool -S, but for
the core network stack, these are actually added up and shoved into
rx_dropped, and no other network driver has those two individual counters.
By itself, rx_dropped isn't output directly anywhere from ethtool,
so far as I can see. And ethtool -S bondX shows absolutely nothing.
*Should* ethtool -S be dumping all the network core stats? I have to say I
was more than a little surprised at this:
# ip -s -s link sh dev eth0
15: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc
pfifo_fast state DOWN mode DEFAULT group default qlen 1000
link/ether 3c:97:0e:be:91:7b brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
RX errors: length crc frame fifo missed
0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
TX errors: aborted fifo window heartbeat
0 0 0 0
So start with the following patch :
@@ -68,6 +68,8 @@ struct rtnl_link_stats64 {/* for cslip etc */__u64rx_compressed;__u64tx_compressed;++__u64rx_nohandler;/* packet was of no interest */};/* The struct should be in sync with struct ifmap */
@@ -4153,8 +4153,11 @@ ncls:elseret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{+if(deliver_exact)+gotoinactive;/* bond or team inactive slave */drop:atomic_long_inc(&skb->dev->rx_dropped);+inactive:kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
Note that if you still have a kfree_skb() instead of consume_skb(),
some tools will still give you a wrong signal (packet dropped ...).
But then maybe the signal is telling some truth.
We receive a packet, and decide to drop it because no one was willing to
handle it.
Maybe someone wants to know a particular slave receives 10,000 such
frames per second and hurts performance with useless work.
We should at least increment some counter and maybe dump it with
"ethtool -S" or something.
I've been digging into ethtool -S a little bit, and am somewhat at a loss
as to how I would wire into this. From what I've been able to figure out,
it's entirely device-specific-ish counters spit out. On my sfc cards, I
get rx_noskb_drops and rx_nodesc_drop_cnt output from ethtool -S, but for
the core network stack, these are actually added up and shoved into
rx_dropped, and no other network driver has those two individual counters.
By itself, rx_dropped isn't output directly anywhere from ethtool,
so far as I can see. And ethtool -S bondX shows absolutely nothing.
*Should* ethtool -S be dumping all the network core stats? I have to say I
was more than a little surprised at this:
# ip -s -s link sh dev eth0
15: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc
pfifo_fast state DOWN mode DEFAULT group default qlen 1000
link/ether 3c:97:0e:be:91:7b brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
RX errors: length crc frame fifo missed
0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
TX errors: aborted fifo window heartbeat
0 0 0 0
So start with the following patch :
@@ -68,6 +68,8 @@ struct rtnl_link_stats64 {/* for cslip etc */__u64rx_compressed;__u64tx_compressed;++__u64rx_nohandler;/* packet was of no interest */};/* The struct should be in sync with struct ifmap */
I'm already well past that point, using rx_dropped_inactive as the stat
name though, based on the prior discussion. I can certainly convert that
over to rx_nohandler easily enough. It looks like adding a column to ip's
output there would be as simple as fetching the stat over netlink and
spitting it out.
--
Jarod Wilson
jarod@redhat.com
From: Jarod Wilson <hidden> Date: 2016-01-26 21:36:58
On Tue, Jan 26, 2016 at 01:21:00PM -0800, David Miller wrote:
From: Jarod Wilson <redacted>
Date: Tue, 26 Jan 2016 16:14:53 -0500
quoted
# ethtool -S bond0
no stats available
ethtool -S is for device specific stats.
Okay, good, that was what it looked like to me. Glad I'm not completely
lost here. :)
So this sort of output wouldn't belong there, it should show up in sysfs,
procfs, and be available to ip over netlink.
Some drivers use this facility to provide per-RX-queue and per-TX-queue
versions of the existing core netdev stats.
From: Jarod Wilson <hidden> Date: 2016-01-27 20:21:57
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
p7p1: 14783346 140430 0 140428 0 0 0 2040 680 8 0 0 0 0 0 0
p7p2: 14805198 140648 0 0 0 0 0 2034 0 0 0 0 0 0 0 0
bond0: 53365248 532798 0 421160 0 0 0 115151 2040 24 0 0 0 0 0 0
lo: 5420 54 0 0 0 0 0 0 5420 54 0 0 0 0 0 0
p5p1: 19292195 196197 0 140368 0 0 0 56564 680 8 0 0 0 0 0 0
p5p2: 19289707 196171 0 140364 0 0 0 56547 680 8 0 0 0 0 0 0
em3: 20996626 158214 0 0 0 0 0 383 0 0 0 0 0 0 0 0
em2: 14065122 138462 0 0 0 0 0 310 0 0 0 0 0 0 0 0
em1: 14063162 138440 0 0 0 0 0 308 0 0 0 0 0 0 0 0
em4: 21050830 158729 0 0 0 0 0 385 71662 469 0 0 0 0 0 0
ib0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In this scenario, p5p1, p5p2 and p7p1 are all inactive slaves in an
active-backup bond0, and you can see that all three have high drop counts,
with the master bond0 showing a tally of all three.
I know that this was previously discussed some here:
http://www.spinics.net/lists/netdev/msg226341.html
It seems additional counters never came to fruition, so this is a first
attempt at creating one of them, so that we stop calling these drops,
which for users monitoring rx_dropped, causes great alarm, and renders the
counter much less useful for them.
This adds a sysfs statistics node and copies the counter out via netlink,
procfs additions will be handled separately, as I'm unsure if the current
output should be considered a stable interface...
Additionally, I'm not certain if this set qualifies for net, or if it
should be put aside and resubmitted for net-next after 4.5 is put to
bed, but I do have users who consider this an important bugfix.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
include/linux/netdevice.h | 4 ++++
include/uapi/linux/if_link.h | 4 ++++
net/core/dev.c | 6 +++++-
net/core/net-sysfs.c | 2 ++
net/core/rtnetlink.c | 2 ++
5 files changed, 17 insertions(+), 1 deletion(-)
@@ -35,6 +35,8 @@ struct rtnl_link_stats {/* for cslip etc */__u32rx_compressed;__u32tx_compressed;++__u32rx_unhandled;/* dropped, no handler found */};/* The main device statistics structure */
@@ -68,6 +70,8 @@ struct rtnl_link_stats64 {/* for cslip etc */__u64rx_compressed;__u64tx_compressed;++__u64rx_unhandled;/* dropped, no handler found */};/* The struct should be in sync with struct ifmap */
@@ -4154,7 +4154,10 @@ ncls:ret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{drop:-atomic_long_inc(&skb->dev->rx_dropped);+if(!deliver_exact)+atomic_long_inc(&skb->dev->rx_dropped);+else+atomic_long_inc(&skb->dev->rx_unhandled);kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
From: Jarod Wilson <hidden> Date: 2016-01-27 20:22:09
This adds an rx_unhandled stat counter, along with a sysfs statistics
node, and copies the counter out via netlink as well.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
include/linux/netdevice.h | 4 ++++
include/uapi/linux/if_link.h | 4 ++++
net/core/dev.c | 6 +++++-
net/core/net-sysfs.c | 2 ++
net/core/rtnetlink.c | 2 ++
5 files changed, 17 insertions(+), 1 deletion(-)
@@ -35,6 +35,8 @@ struct rtnl_link_stats {/* for cslip etc */__u32rx_compressed;__u32tx_compressed;++__u32rx_unhandled;/* dropped, no handler found */};/* The main device statistics structure */
@@ -68,6 +70,8 @@ struct rtnl_link_stats64 {/* for cslip etc */__u64rx_compressed;__u64tx_compressed;++__u64rx_unhandled;/* dropped, no handler found */};/* The struct should be in sync with struct ifmap */
@@ -4154,7 +4154,10 @@ ncls:ret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{drop:-atomic_long_inc(&skb->dev->rx_dropped);+if(!deliver_exact)+atomic_long_inc(&skb->dev->rx_dropped);+else+atomic_long_inc(&skb->dev->rx_unhandled);kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
From: Jarod Wilson <hidden> Date: 2016-01-27 20:22:14
The rx_unhandled counters get output here in a column after drop with
a heading name of unh. I'm not sure if perhaps /proc/net/dev should be
considered a stable interface that shouldn't be mucked with. If so,
this can certainly be dropped, without impacting the core functionality.
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
net/core/net-procfs.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
This structure is deprecated, please do not add new fields in it,
as it will increase netlink answers for no good reason.
rtnl_link_stats64 is what really matters these days.
This structure is deprecated, please do not add new fields in it,
as it will increase netlink answers for no good reason.
rtnl_link_stats64 is what really matters these days.
I'll respin the set without that, along with s/unhandled/nohandler/, which
I somehow got screwed up in my head and realized a split second after
hitting send. Outside of that, does this approach look sane? Should I
bother with touching /proc/net/dev output or not?
Thanks much,
--
Jarod Wilson
jarod@redhat.com
This structure is deprecated, please do not add new fields in it,
as it will increase netlink answers for no good reason.
rtnl_link_stats64 is what really matters these days.
I'll respin the set without that, along with s/unhandled/nohandler/, which
I somehow got screwed up in my head and realized a split second after
hitting send. Outside of that, does this approach look sane? Should I
bother with touching /proc/net/dev output or not?
Also, please excuse the poor excuse for a cover-letter that had a
duplicate of patch 1 in it. I'll fix that the next pass too.
/me hangs head in shame...
--
Jarod Wilson
jarod@redhat.com
This structure is deprecated, please do not add new fields in it,
as it will increase netlink answers for no good reason.
rtnl_link_stats64 is what really matters these days.
I'll respin the set without that
Or not. Now I remember why I added that in the first place:
In file included from ./arch/x86/include/asm/uaccess.h:7:0,
from net/core/dev.c:75:
net/core/dev.c: In function 'netdev_stats_to_stats64':
include/linux/compiler.h:484:20: error: call to '__compiletime_assert_7263' declared with attribute error: BUILD_BUG_ON failed: sizeof(*stats64) != sizeof(*netdev_stats)
prefix ## suffix(); \
^
Things are actually hard-wired to require that addition at the moment, or
you get the above build failure. Not sure if it's safe to remove that
BUILD_BUG_ON() yet, haven't looked closely, it's past my bed time. :)
--
Jarod Wilson
jarod@redhat.com
From: Eric Dumazet <hidden> Date: 2016-01-28 13:00:10
On Thu, 2016-01-28 at 01:18 -0500, Jarod Wilson wrote:
Or not. Now I remember why I added that in the first place:
In file included from ./arch/x86/include/asm/uaccess.h:7:0,
from net/core/dev.c:75:
net/core/dev.c: In function 'netdev_stats_to_stats64':
include/linux/compiler.h:484:20: error: call to '__compiletime_assert_7263' declared with attribute error: BUILD_BUG_ON failed: sizeof(*stats64) != sizeof(*netdev_stats)
prefix ## suffix(); \
^
Things are actually hard-wired to require that addition at the moment, or
you get the above build failure. Not sure if it's safe to remove that
BUILD_BUG_ON() yet, haven't looked closely, it's past my bed time. :)
This was done for the transition from "unsigned long" to "u64", which is
a nop on 64bit arches.
But as we do not need to be compatible, since no linux kernel in the
past had this new field in struct net_device_stats,
and we do not need to add this new field as it is only accessed from
core networking stack [1], you need to adapt this helper.
[1] And maybe some virtual devices like bonding/team
From: Jarod Wilson <hidden> Date: 2016-01-28 14:38:11
On Thu, Jan 28, 2016 at 05:00:02AM -0800, Eric Dumazet wrote:
On Thu, 2016-01-28 at 01:18 -0500, Jarod Wilson wrote:
quoted
Or not. Now I remember why I added that in the first place:
In file included from ./arch/x86/include/asm/uaccess.h:7:0,
from net/core/dev.c:75:
net/core/dev.c: In function 'netdev_stats_to_stats64':
include/linux/compiler.h:484:20: error: call to '__compiletime_assert_7263' declared with attribute error: BUILD_BUG_ON failed: sizeof(*stats64) != sizeof(*netdev_stats)
prefix ## suffix(); \
^
Things are actually hard-wired to require that addition at the moment, or
you get the above build failure. Not sure if it's safe to remove that
BUILD_BUG_ON() yet, haven't looked closely, it's past my bed time. :)
This was done for the transition from "unsigned long" to "u64", which is
a nop on 64bit arches.
But as we do not need to be compatible, since no linux kernel in the
past had this new field in struct net_device_stats,
and we do not need to add this new field as it is only accessed from
core networking stack [1], you need to adapt this helper.
From: Jarod Wilson <hidden> Date: 2016-01-28 15:11:11
On Thu, Jan 28, 2016 at 06:46:50AM -0800, Eric Dumazet wrote:
On Thu, 2016-01-28 at 06:44 -0800, Eric Dumazet wrote:
quoted
On Thu, 2016-01-28 at 06:42 -0800, Eric Dumazet wrote:
quoted
Sure, you also can set stats64->rx_unhandled to 0 here, just to be 100%
safe.
And not add the memset(stats64, 0, sizeof(*stats64)), since we have the
guarantee to properly init whole stats64 structure.
Or a more tricky
memset((char *)stats64 + sizeof(struct net_device_stats),
0,
sizeof(*stats64) - sizeof(struct net_device_stats));
I think I like this best, since it won't require someone to notice they
have to add an explicit initialization if they add a new counter, as well
as saving us from memset'ing the entire struct, the majority of which
we'll initialize moments later. Just needs some documentation updates,
which I've done locally. Will rebuild, re-test, then hopefully get an
updated patchset out the door.
--
Jarod Wilson
jarod@redhat.com
From: Jarod Wilson <hidden> Date: 2016-01-28 15:50:12
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
$ cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
p7p1: 14783346 140430 0 140428 0 0 0 2040 680 8 0 0 0 0 0 0
p7p2: 14805198 140648 0 0 0 0 0 2034 0 0 0 0 0 0 0 0
bond0: 53365248 532798 0 421160 0 0 0 115151 2040 24 0 0 0 0 0 0
lo: 5420 54 0 0 0 0 0 0 5420 54 0 0 0 0 0 0
p5p1: 19292195 196197 0 140368 0 0 0 56564 680 8 0 0 0 0 0 0
p5p2: 19289707 196171 0 140364 0 0 0 56547 680 8 0 0 0 0 0 0
em3: 20996626 158214 0 0 0 0 0 383 0 0 0 0 0 0 0 0
em2: 14065122 138462 0 0 0 0 0 310 0 0 0 0 0 0 0 0
em1: 14063162 138440 0 0 0 0 0 308 0 0 0 0 0 0 0 0
em4: 21050830 158729 0 0 0 0 0 385 71662 469 0 0 0 0 0 0
ib0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In this scenario, p5p1, p5p2 and p7p1 are all inactive slaves in an
active-backup bond0, and you can see that all three have high drop counts,
with the master bond0 showing a tally of all three.
I know that this was previously discussed some here:
http://www.spinics.net/lists/netdev/msg226341.html
It seems additional counters never came to fruition, so this is a first
attempt at creating one of them, so that we stop calling these drops,
which for users monitoring rx_dropped, causes great alarm, and renders the
counter much less useful for them.
This adds a sysfs statistics node and makes the counter available via
netlink.
Additionally, I'm not certain if this set qualifies for net, or if it
should be put aside and resubmitted for net-next after 4.5 is put to
bed, but I do have users who consider this an important bugfix.
Jarod Wilson (4):
net/core: relax BUILD_BUG_ON in netdev_stats_to_stats64
net: add rx_nohandler stat counter
team: track sum of rx_nohandler for all slaves
bond: track sum of rx_nohandler for all slaves
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
drivers/net/bonding/bond_main.c | 1 +
drivers/net/team/team.c | 10 +++++++---
include/linux/if_team.h | 1 +
include/linux/netdevice.h | 3 +++
include/uapi/linux/if_link.h | 4 ++++
net/core/dev.c | 19 ++++++++++++++-----
net/core/net-sysfs.c | 2 ++
net/core/rtnetlink.c | 2 ++
8 files changed, 34 insertions(+), 8 deletions(-)
--
1.8.3.1
From: Jarod Wilson <hidden> Date: 2016-01-28 15:51:35
This adds an rx_nohandler stat counter, along with a sysfs statistics
node, and copies the counter out via netlink as well.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
include/linux/netdevice.h | 3 +++
include/uapi/linux/if_link.h | 4 ++++
net/core/dev.c | 6 +++++-
net/core/net-sysfs.c | 2 ++
net/core/rtnetlink.c | 2 ++
5 files changed, 16 insertions(+), 1 deletion(-)
@@ -35,6 +35,8 @@ struct rtnl_link_stats {/* for cslip etc */__u32rx_compressed;__u32tx_compressed;++__u32rx_nohandler;/* dropped, no handler found */};/* The main device statistics structure */
@@ -68,6 +70,8 @@ struct rtnl_link_stats64 {/* for cslip etc */__u64rx_compressed;__u64tx_compressed;++__u64rx_nohandler;/* dropped, no handler found */};/* The struct should be in sync with struct ifmap */
@@ -4154,7 +4154,10 @@ ncls:ret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{drop:-atomic_long_inc(&skb->dev->rx_dropped);+if(!deliver_exact)+atomic_long_inc(&skb->dev->rx_dropped);+else+atomic_long_inc(&skb->dev->rx_nohandler);kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
From: Jarod Wilson <hidden> Date: 2016-01-28 16:22:49
The netdev_stats_to_stats64 function copies the deprecated
net_device_stats format stats into rtnl_link_stats64 for legacy support
purposes, but with the BUILD_BUG_ON as it was, it wasn't possible to
extend rtnl_link_stats64 without also extending net_device_stats. Relax
the BUILD_BUG_ON to only require that rtnl_link_stats64 is larger, and
zero out all the stat counters that aren't present in net_device_stats.
CC: Eric Dumazet <edumazet@google.com>
CC: netdev@ger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
v3: get the CC list right, moron
net/core/dev.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
@@ -7253,25 +7253,30 @@ void netdev_run_todo(void)}}-/* Convert net_device_stats to rtnl_link_stats64. They have the same-*fieldsinthesameorder,withonlythetypediffering.+/* Convert net_device_stats to rtnl_link_stats64. rtnl_link_stats64 has+*allthesamefieldsinthesameorderasnet_device_stats,withonly+*thetypediffering,butrtnl_link_stats64mayhaveadditionalfields+*attheendfornewercounters.*/voidnetdev_stats_to_stats64(structrtnl_link_stats64*stats64,conststructnet_device_stats*netdev_stats){#if BITS_PER_LONG == 64-BUILD_BUG_ON(sizeof(*stats64)!=sizeof(*netdev_stats));+BUILD_BUG_ON(sizeof(*stats64)<sizeof(*netdev_stats));memcpy(stats64,netdev_stats,sizeof(*stats64));#elsesize_ti,n=sizeof(*stats64)/sizeof(u64);constunsignedlong*src=(constunsignedlong*)netdev_stats;u64*dst=(u64*)stats64;-BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)!=+BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)>sizeof(*stats64)/sizeof(u64));for(i=0;i<n;i++)dst[i]=src[i];#endif+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+sizeof(*netdev_stats),0,+sizeof(*stats64)-sizeof(*netdev_stats));}EXPORT_SYMBOL(netdev_stats_to_stats64);
From: David Miller <davem@davemloft.net> Date: 2016-01-30 03:37:54
From: Jarod Wilson <redacted>
Date: Thu, 28 Jan 2016 10:49:44 -0500
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
...
Both my inbox and patchwork only show patch 2, 3, and 4. Where is #1?
Thanks.
From: Jarod Wilson <hidden> Date: 2016-01-30 18:16:52
On Fri, Jan 29, 2016 at 07:37:51PM -0800, David Miller wrote:
From: Jarod Wilson <redacted>
Date: Thu, 28 Jan 2016 10:49:44 -0500
quoted
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
...
Both my inbox and patchwork only show patch 2, 3, and 4. Where is #1?
Crap. It seems I fat-fingered netdev@vger.kernel.org without the v in
front of ger. Will re-send in a sec, hopefully finallly not screwing it up
this time.
--
Jarod Wilson
jarod@redhat.com
From: Jarod Wilson <hidden> Date: 2016-01-30 18:19:49
The netdev_stats_to_stats64 function copies the deprecated
net_device_stats format stats into rtnl_link_stats64 for legacy support
purposes, but with the BUILD_BUG_ON as it was, it wasn't possible to
extend rtnl_link_stats64 without also extending net_device_stats. Relax
the BUILD_BUG_ON to only require that rtnl_link_stats64 is larger, and
zero out all the stat counters that aren't present in net_device_stats.
CC: Eric Dumazet <edumazet@google.com>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
Re-re-sending, hopefully getting the patch to the right list this time.
net/core/dev.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
@@ -7253,25 +7253,30 @@ void netdev_run_todo(void)}}-/* Convert net_device_stats to rtnl_link_stats64. They have the same-*fieldsinthesameorder,withonlythetypediffering.+/* Convert net_device_stats to rtnl_link_stats64. rtnl_link_stats64 has+*allthesamefieldsinthesameorderasnet_device_stats,withonly+*thetypediffering,butrtnl_link_stats64mayhaveadditionalfields+*attheendfornewercounters.*/voidnetdev_stats_to_stats64(structrtnl_link_stats64*stats64,conststructnet_device_stats*netdev_stats){#if BITS_PER_LONG == 64-BUILD_BUG_ON(sizeof(*stats64)!=sizeof(*netdev_stats));+BUILD_BUG_ON(sizeof(*stats64)<sizeof(*netdev_stats));memcpy(stats64,netdev_stats,sizeof(*stats64));#elsesize_ti,n=sizeof(*stats64)/sizeof(u64);constunsignedlong*src=(constunsignedlong*)netdev_stats;u64*dst=(u64*)stats64;-BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)!=+BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)>sizeof(*stats64)/sizeof(u64));for(i=0;i<n;i++)dst[i]=src[i];#endif+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+sizeof(*netdev_stats),0,+sizeof(*stats64)-sizeof(*netdev_stats));}EXPORT_SYMBOL(netdev_stats_to_stats64);
From: Eric Dumazet <hidden> Date: 2016-01-30 18:34:36
On Sat, 2016-01-30 at 13:19 -0500, Jarod Wilson wrote:
quoted hunk
The netdev_stats_to_stats64 function copies the deprecated
net_device_stats format stats into rtnl_link_stats64 for legacy support
purposes, but with the BUILD_BUG_ON as it was, it wasn't possible to
extend rtnl_link_stats64 without also extending net_device_stats. Relax
the BUILD_BUG_ON to only require that rtnl_link_stats64 is larger, and
zero out all the stat counters that aren't present in net_device_stats.
CC: Eric Dumazet <edumazet@google.com>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
Re-re-sending, hopefully getting the patch to the right list this time.
net/core/dev.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
@@ -7253,25 +7253,30 @@ void netdev_run_todo(void)}}-/* Convert net_device_stats to rtnl_link_stats64. They have the same-*fieldsinthesameorder,withonlythetypediffering.+/* Convert net_device_stats to rtnl_link_stats64. rtnl_link_stats64 has+*allthesamefieldsinthesameorderasnet_device_stats,withonly+*thetypediffering,butrtnl_link_stats64mayhaveadditionalfields+*attheendfornewercounters.*/voidnetdev_stats_to_stats64(structrtnl_link_stats64*stats64,conststructnet_device_stats*netdev_stats){#if BITS_PER_LONG == 64-BUILD_BUG_ON(sizeof(*stats64)!=sizeof(*netdev_stats));+BUILD_BUG_ON(sizeof(*stats64)<sizeof(*netdev_stats));memcpy(stats64,netdev_stats,sizeof(*stats64));#elsesize_ti,n=sizeof(*stats64)/sizeof(u64);constunsignedlong*src=(constunsignedlong*)netdev_stats;u64*dst=(u64*)stats64;-BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)!=+BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)>sizeof(*stats64)/sizeof(u64));for(i=0;i<n;i++)dst[i]=src[i];#endif+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+sizeof(*netdev_stats),0,+sizeof(*stats64)-sizeof(*netdev_stats));
From: Jarod Wilson <hidden> Date: 2016-01-30 20:39:04
On Sat, Jan 30, 2016 at 10:34:32AM -0800, Eric Dumazet wrote:
On Sat, 2016-01-30 at 13:19 -0500, Jarod Wilson wrote:
quoted
The netdev_stats_to_stats64 function copies the deprecated
net_device_stats format stats into rtnl_link_stats64 for legacy support
purposes, but with the BUILD_BUG_ON as it was, it wasn't possible to
extend rtnl_link_stats64 without also extending net_device_stats. Relax
the BUILD_BUG_ON to only require that rtnl_link_stats64 is larger, and
zero out all the stat counters that aren't present in net_device_stats.
CC: Eric Dumazet <edumazet@google.com>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
Re-re-sending, hopefully getting the patch to the right list this time.
net/core/dev.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
@@ -7253,25 +7253,30 @@ void netdev_run_todo(void)}}-/* Convert net_device_stats to rtnl_link_stats64. They have the same-*fieldsinthesameorder,withonlythetypediffering.+/* Convert net_device_stats to rtnl_link_stats64. rtnl_link_stats64 has+*allthesamefieldsinthesameorderasnet_device_stats,withonly+*thetypediffering,butrtnl_link_stats64mayhaveadditionalfields+*attheendfornewercounters.*/voidnetdev_stats_to_stats64(structrtnl_link_stats64*stats64,conststructnet_device_stats*netdev_stats){#if BITS_PER_LONG == 64-BUILD_BUG_ON(sizeof(*stats64)!=sizeof(*netdev_stats));+BUILD_BUG_ON(sizeof(*stats64)<sizeof(*netdev_stats));memcpy(stats64,netdev_stats,sizeof(*stats64));#elsesize_ti,n=sizeof(*stats64)/sizeof(u64);constunsignedlong*src=(constunsignedlong*)netdev_stats;u64*dst=(u64*)stats64;-BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)!=+BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)>sizeof(*stats64)/sizeof(u64));for(i=0;i<n;i++)dst[i]=src[i];#endif+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+sizeof(*netdev_stats),0,+sizeof(*stats64)-sizeof(*netdev_stats));
Are you sure it works on 32bit arches ?
Ew, no, it won't work correctly on 32-bit. The for loop is going to copy
data into dst from beyond the end of netdev_stats, and the range looks
like it won't be right either, only half of the added stats64 space will
get zeroed out. Okay, I'll fix that up correctly.
--
Jarod Wilson
jarod@redhat.com
From: Jarod Wilson <hidden> Date: 2016-01-30 20:53:09
On Sat, Jan 30, 2016 at 03:39:01PM -0500, Jarod Wilson wrote:
On Sat, Jan 30, 2016 at 10:34:32AM -0800, Eric Dumazet wrote:
quoted
On Sat, 2016-01-30 at 13:19 -0500, Jarod Wilson wrote:
quoted
The netdev_stats_to_stats64 function copies the deprecated
net_device_stats format stats into rtnl_link_stats64 for legacy support
purposes, but with the BUILD_BUG_ON as it was, it wasn't possible to
extend rtnl_link_stats64 without also extending net_device_stats. Relax
the BUILD_BUG_ON to only require that rtnl_link_stats64 is larger, and
zero out all the stat counters that aren't present in net_device_stats.
CC: Eric Dumazet <edumazet@google.com>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
Re-re-sending, hopefully getting the patch to the right list this time.
net/core/dev.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
@@ -7253,25 +7253,30 @@ void netdev_run_todo(void)}}-/* Convert net_device_stats to rtnl_link_stats64. They have the same-*fieldsinthesameorder,withonlythetypediffering.+/* Convert net_device_stats to rtnl_link_stats64. rtnl_link_stats64 has+*allthesamefieldsinthesameorderasnet_device_stats,withonly+*thetypediffering,butrtnl_link_stats64mayhaveadditionalfields+*attheendfornewercounters.*/voidnetdev_stats_to_stats64(structrtnl_link_stats64*stats64,conststructnet_device_stats*netdev_stats){#if BITS_PER_LONG == 64-BUILD_BUG_ON(sizeof(*stats64)!=sizeof(*netdev_stats));+BUILD_BUG_ON(sizeof(*stats64)<sizeof(*netdev_stats));memcpy(stats64,netdev_stats,sizeof(*stats64));#elsesize_ti,n=sizeof(*stats64)/sizeof(u64);constunsignedlong*src=(constunsignedlong*)netdev_stats;u64*dst=(u64*)stats64;-BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)!=+BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)>sizeof(*stats64)/sizeof(u64));for(i=0;i<n;i++)dst[i]=src[i];#endif+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+sizeof(*netdev_stats),0,+sizeof(*stats64)-sizeof(*netdev_stats));
Are you sure it works on 32bit arches ?
Ew, no, it won't work correctly on 32-bit. The for loop is going to copy
data into dst from beyond the end of netdev_stats, and the range looks
like it won't be right either, only half of the added stats64 space will
get zeroed out. Okay, I'll fix that up correctly.
Completely untested as of yet, but I think something like the following
looks correct. I'll give it a spin as soon as I can.
@@ -7253,24 +7253,31 @@ void netdev_run_todo(void)}}-/* Convert net_device_stats to rtnl_link_stats64. They have the same-*fieldsinthesameorder,withonlythetypediffering.+/* Convert net_device_stats to rtnl_link_stats64. rtnl_link_stats64 has+*allthesamefieldsinthesameorderasnet_device_stats,withonly+*thetypediffering,butrtnl_link_stats64mayhaveadditionalfields+*attheendfornewercounters.*/voidnetdev_stats_to_stats64(structrtnl_link_stats64*stats64,conststructnet_device_stats*netdev_stats){#if BITS_PER_LONG == 64-BUILD_BUG_ON(sizeof(*stats64)!=sizeof(*netdev_stats));+BUILD_BUG_ON(sizeof(*stats64)<sizeof(*netdev_stats));memcpy(stats64,netdev_stats,sizeof(*stats64));+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+sizeof(*netdev_stats),0,+sizeof(*stats64)-sizeof(*netdev_stats));#else-size_ti,n=sizeof(*stats64)/sizeof(u64);+size_ti,n=sizeof(*netdev_stats)/sizeof(unsignedlong);constunsignedlong*src=(constunsignedlong*)netdev_stats;u64*dst=(u64*)stats64;-BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)!=-sizeof(*stats64)/sizeof(u64));+BUILD_BUG_ON(n>sizeof(*stats64)/sizeof(u64));for(i=0;i<n;i++)dst[i]=src[i];+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+n*sizeof(u64),0,+sizeof(*stats64)-n*sizeof(u64));#endif}EXPORT_SYMBOL(netdev_stats_to_stats64);
From: David Miller <davem@davemloft.net> Date: 2016-01-30 23:26:42
From: Jarod Wilson <redacted>
Date: Sat, 30 Jan 2016 15:53:05 -0500
On Sat, Jan 30, 2016 at 03:39:01PM -0500, Jarod Wilson wrote:
quoted
Ew, no, it won't work correctly on 32-bit. The for loop is going to copy
data into dst from beyond the end of netdev_stats, and the range looks
like it won't be right either, only half of the added stats64 space will
get zeroed out. Okay, I'll fix that up correctly.
Completely untested as of yet, but I think something like the following
looks correct. I'll give it a spin as soon as I can.
Jarod, please respin your entire series as a v3 once you sort this out.
Thanks.
From: Jarod Wilson <hidden> Date: 2016-01-31 18:07:08
On Sat, Jan 30, 2016 at 03:26:35PM -0800, David Miller wrote:
From: Jarod Wilson <redacted>
Date: Sat, 30 Jan 2016 15:53:05 -0500
quoted
On Sat, Jan 30, 2016 at 03:39:01PM -0500, Jarod Wilson wrote:
quoted
Ew, no, it won't work correctly on 32-bit. The for loop is going to copy
data into dst from beyond the end of netdev_stats, and the range looks
like it won't be right either, only half of the added stats64 space will
get zeroed out. Okay, I'll fix that up correctly.
Completely untested as of yet, but I think something like the following
looks correct. I'll give it a spin as soon as I can.
Jarod, please respin your entire series as a v3 once you sort this out.
Will do. I should be able to get it tested out on a 32-bit setup Monday.
--
Jarod Wilson
jarod@redhat.com
From: Jarod Wilson <hidden> Date: 2016-02-01 23:51:15
The network core tries to keep track of dropped packets, but some packets
you wouldn't really call dropped, so much as intentionally ignored, under
certain circumstances. One such case is that of bonding and team device
slaves that are currently inactive. Their respective rx_handler functions
return RX_HANDLER_EXACT (the only places in the kernel that return that),
which ends up tracking into the network core's __netif_receive_skb_core()
function's drop path, with no pt_prev set. On a noisy network, this can
result in a very rapidly incrementing rx_dropped counter, not only on the
inactive slave(s), but also on the master device, such as the following:
$ cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
p7p1: 14783346 140430 0 140428 0 0 0 2040 680 8 0 0 0 0 0 0
p7p2: 14805198 140648 0 0 0 0 0 2034 0 0 0 0 0 0 0 0
bond0: 53365248 532798 0 421160 0 0 0 115151 2040 24 0 0 0 0 0 0
lo: 5420 54 0 0 0 0 0 0 5420 54 0 0 0 0 0 0
p5p1: 19292195 196197 0 140368 0 0 0 56564 680 8 0 0 0 0 0 0
p5p2: 19289707 196171 0 140364 0 0 0 56547 680 8 0 0 0 0 0 0
em3: 20996626 158214 0 0 0 0 0 383 0 0 0 0 0 0 0 0
em2: 14065122 138462 0 0 0 0 0 310 0 0 0 0 0 0 0 0
em1: 14063162 138440 0 0 0 0 0 308 0 0 0 0 0 0 0 0
em4: 21050830 158729 0 0 0 0 0 385 71662 469 0 0 0 0 0 0
ib0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
In this scenario, p5p1, p5p2 and p7p1 are all inactive slaves in an
active-backup bond0, and you can see that all three have high drop counts,
with the master bond0 showing a tally of all three.
I know that this was previously discussed some here:
http://www.spinics.net/lists/netdev/msg226341.html
It seems additional counters never came to fruition, so this is a first
attempt at creating one of them, so that we stop calling these drops,
which for users monitoring rx_dropped, causes great alarm, and renders the
counter much less useful for them.
This adds a sysfs statistics node and makes the counter available via
netlink.
Additionally, I'm not certain if this set qualifies for net, or if it
should be put aside and resubmitted for net-next after 4.5 is put to
bed, but I do have users who consider this an important bugfix.
This has been tested quite a bit on x86_64, and now lightly on i686 as
well, to verify functionality of updates to netdev_stats_to_stats64()
on 32-bit arches.
Jarod Wilson (4):
net/core: relax BUILD_BUG_ON in netdev_stats_to_stats64
net: add rx_nohandler stat counter
team: track sum of rx_nohandler for all slaves
bond: track sum of rx_nohandler for all slaves
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
drivers/net/bonding/bond_main.c | 1 +
drivers/net/team/team.c | 10 +++++++---
include/linux/if_team.h | 1 +
include/linux/netdevice.h | 3 +++
include/uapi/linux/if_link.h | 4 ++++
net/core/dev.c | 25 ++++++++++++++++++-------
net/core/net-sysfs.c | 2 ++
net/core/rtnetlink.c | 2 ++
8 files changed, 38 insertions(+), 10 deletions(-)
--
1.8.3.1
From: Jarod Wilson <hidden> Date: 2016-02-01 23:51:17
The netdev_stats_to_stats64 function copies the deprecated
net_device_stats format stats into rtnl_link_stats64 for legacy support
purposes, but with the BUILD_BUG_ON as it was, it wasn't possible to
extend rtnl_link_stats64 without also extending net_device_stats. Relax
the BUILD_BUG_ON to only require that rtnl_link_stats64 is larger, and
zero out all the stat counters that aren't present in net_device_stats.
CC: Eric Dumazet <edumazet@google.com>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
net/core/dev.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
@@ -7253,24 +7253,31 @@ void netdev_run_todo(void)}}-/* Convert net_device_stats to rtnl_link_stats64. They have the same-*fieldsinthesameorder,withonlythetypediffering.+/* Convert net_device_stats to rtnl_link_stats64. rtnl_link_stats64 has+*allthesamefieldsinthesameorderasnet_device_stats,withonly+*thetypediffering,butrtnl_link_stats64mayhaveadditionalfields+*attheendfornewercounters.*/voidnetdev_stats_to_stats64(structrtnl_link_stats64*stats64,conststructnet_device_stats*netdev_stats){#if BITS_PER_LONG == 64-BUILD_BUG_ON(sizeof(*stats64)!=sizeof(*netdev_stats));+BUILD_BUG_ON(sizeof(*stats64)<sizeof(*netdev_stats));memcpy(stats64,netdev_stats,sizeof(*stats64));+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+sizeof(*netdev_stats),0,+sizeof(*stats64)-sizeof(*netdev_stats));#else-size_ti,n=sizeof(*stats64)/sizeof(u64);+size_ti,n=sizeof(*netdev_stats)/sizeof(unsignedlong);constunsignedlong*src=(constunsignedlong*)netdev_stats;u64*dst=(u64*)stats64;-BUILD_BUG_ON(sizeof(*netdev_stats)/sizeof(unsignedlong)!=-sizeof(*stats64)/sizeof(u64));+BUILD_BUG_ON(n>sizeof(*stats64)/sizeof(u64));for(i=0;i<n;i++)dst[i]=src[i];+/* zero out counters that only exist in rtnl_link_stats64 */+memset((char*)stats64+n*sizeof(u64),0,+sizeof(*stats64)-n*sizeof(u64));#endif}EXPORT_SYMBOL(netdev_stats_to_stats64);
From: Jarod Wilson <hidden> Date: 2016-02-01 23:54:21
This adds an rx_nohandler stat counter, along with a sysfs statistics
node, and copies the counter out via netlink as well.
CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <redacted>
CC: Daniel Borkmann <daniel@iogearbox.net>
CC: Tom Herbert <redacted>
CC: Jay Vosburgh <redacted>
CC: Veaceslav Falico <redacted>
CC: Andy Gospodarek <redacted>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <redacted>
---
include/linux/netdevice.h | 3 +++
include/uapi/linux/if_link.h | 4 ++++
net/core/dev.c | 6 +++++-
net/core/net-sysfs.c | 2 ++
net/core/rtnetlink.c | 2 ++
5 files changed, 16 insertions(+), 1 deletion(-)
@@ -35,6 +35,8 @@ struct rtnl_link_stats {/* for cslip etc */__u32rx_compressed;__u32tx_compressed;++__u32rx_nohandler;/* dropped, no handler found */};/* The main device statistics structure */
@@ -68,6 +70,8 @@ struct rtnl_link_stats64 {/* for cslip etc */__u64rx_compressed;__u64tx_compressed;++__u64rx_nohandler;/* dropped, no handler found */};/* The struct should be in sync with struct ifmap */
@@ -4154,7 +4154,10 @@ ncls:ret=pt_prev->func(skb,skb->dev,pt_prev,orig_dev);}else{drop:-atomic_long_inc(&skb->dev->rx_dropped);+if(!deliver_exact)+atomic_long_inc(&skb->dev->rx_dropped);+else+atomic_long_inc(&skb->dev->rx_nohandler);kfree_skb(skb);/* Jamal, now you will not able to escape explaining*mehowyouweregoingtousethis.:-)
From: David Miller <davem@davemloft.net> Date: 2016-02-06 08:00:49
From: Jarod Wilson <redacted>
Date: Mon, 1 Feb 2016 18:51:03 -0500
...
It seems additional counters never came to fruition, so this is a first
attempt at creating one of them, so that we stop calling these drops,
which for users monitoring rx_dropped, causes great alarm, and renders the
counter much less useful for them.
This adds a sysfs statistics node and makes the counter available via
netlink.
Additionally, I'm not certain if this set qualifies for net, or if it
should be put aside and resubmitted for net-next after 4.5 is put to
bed, but I do have users who consider this an important bugfix.
This has been tested quite a bit on x86_64, and now lightly on i686 as
well, to verify functionality of updates to netdev_stats_to_stats64()
on 32-bit arches.
@@ -35,6 +35,8 @@ struct rtnl_link_stats {/* for cslip etc */__u32rx_compressed;__u32tx_compressed;++__u32rx_nohandler;/* dropped, no handler found */};/* The main device statistics structure */
@@ -68,6 +70,8 @@ struct rtnl_link_stats64 {/* for cslip etc */__u64rx_compressed;__u64tx_compressed;++__u64rx_nohandler;/* dropped, no handler found */};
Why was this userspace ABI change allowed?
The stats structure is exposed to user space via netlink
and changing the size of responses will break iproute2 commands.
The code will be expecting one size and the response will vary and
break existing code. Yes, the code should check the size
of the response, but it doesn't and I am sure iproute2 is not
the only code that does this.
@@ -35,6 +35,8 @@ struct rtnl_link_stats {/* for cslip etc */__u32rx_compressed;__u32tx_compressed;++__u32rx_nohandler;/* dropped, no handler found */};/* The main device statistics structure */
@@ -68,6 +70,8 @@ struct rtnl_link_stats64 {/* for cslip etc */__u64rx_compressed;__u64tx_compressed;++__u64rx_nohandler;/* dropped, no handler found */};
Why was this userspace ABI change allowed?
The stats structure is exposed to user space via netlink
and changing the size of responses will break iproute2 commands.
The code will be expecting one size and the response will vary and
break existing code. Yes, the code should check the size
of the response, but it doesn't and I am sure iproute2 is not
the only code that does this.
From: Eric Dumazet <hidden> Date: 2016-02-07 20:19:36
On Sun, 2016-02-07 at 14:46 -0500, David Miller wrote:
quoted
Why was this userspace ABI change allowed?
The stats structure is exposed to user space via netlink
and changing the size of responses will break iproute2 commands.
I do not think it breaks anything.
iproute2 always assumed kernel was sending at least 23 u64, and does not
check at all if the kernel sends more. (or less, so iproute2 can print
garbage if kernel is malicious)
an iproute2 patch will be needed to automatically detect if new kernels
are sending more data and print it accordingly.
quoted
The code will be expecting one size and the response will vary and
break existing code. Yes, the code should check the size
of the response, but it doesn't and I am sure iproute2 is not
the only code that does this.
Jarod, please look into this.
Running latest net-next, and old iproute2 is just fine.
# ip -s link sh dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq portid
001a11fffec30d80 state UP mode DEFAULT group default qlen 16000
link/ether 00:1a:11:c3:0d:7f brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
533766 1875 0 0 0 135
TX: bytes packets errors dropped carrier collsns
209204 1858 0 0 0 0
From: Jarod Wilson <hidden> Date: 2016-02-08 18:32:59
On Sun, Feb 07, 2016 at 12:19:28PM -0800, Eric Dumazet wrote:
On Sun, 2016-02-07 at 14:46 -0500, David Miller wrote:
quoted
quoted
Why was this userspace ABI change allowed?
The stats structure is exposed to user space via netlink
and changing the size of responses will break iproute2 commands.
I do not think it breaks anything.
iproute2 always assumed kernel was sending at least 23 u64, and does not
check at all if the kernel sends more. (or less, so iproute2 can print
garbage if kernel is malicious)
an iproute2 patch will be needed to automatically detect if new kernels
are sending more data and print it accordingly.
My TODO list did include poking at iproute2 to expose the new info, I can
take a closer look for possible issues as well, but...
quoted
quoted
The code will be expecting one size and the response will vary and
break existing code. Yes, the code should check the size
of the response, but it doesn't and I am sure iproute2 is not
the only code that does this.
Jarod, please look into this.
Running latest net-next, and old iproute2 is just fine.
...I haven't run into anything that didn't work with current iproute2
either while testing out functionality of these patches. If there's
something in particular that seems most suspect that I perhaps simply
haven't tried, I can give that a go as well.
In any case, I'm definitely due to take a look at iproute2 as it relates
to this patchset.
--
Jarod Wilson
jarod@redhat.com
From: Stephen Hemminger <stephen@networkplumber.org> Date: 2016-02-08 19:38:14
On Mon, 8 Feb 2016 13:32:54 -0500
Jarod Wilson [off-list ref] wrote:
On Sun, Feb 07, 2016 at 12:19:28PM -0800, Eric Dumazet wrote:
quoted
On Sun, 2016-02-07 at 14:46 -0500, David Miller wrote:
quoted
quoted
Why was this userspace ABI change allowed?
The stats structure is exposed to user space via netlink
and changing the size of responses will break iproute2 commands.
I do not think it breaks anything.
iproute2 always assumed kernel was sending at least 23 u64, and does not
check at all if the kernel sends more. (or less, so iproute2 can print
garbage if kernel is malicious)
an iproute2 patch will be needed to automatically detect if new kernels
are sending more data and print it accordingly.
My TODO list did include poking at iproute2 to expose the new info, I can
take a closer look for possible issues as well, but...
quoted
quoted
quoted
The code will be expecting one size and the response will vary and
break existing code. Yes, the code should check the size
of the response, but it doesn't and I am sure iproute2 is not
the only code that does this.
Jarod, please look into this.
Running latest net-next, and old iproute2 is just fine.
...I haven't run into anything that didn't work with current iproute2
either while testing out functionality of these patches. If there's
something in particular that seems most suspect that I perhaps simply
haven't tried, I can give that a go as well.
In any case, I'm definitely due to take a look at iproute2 as it relates
to this patchset.
The iproute2 command can be fixed, but adding dependency on size of response
gets gross fast. Imagine when 4 more fields get added, this doesn't scale well.
Also, the definition of userspace ABI is that structures can't change.
There are many other utilities that are not visible that may get broken.
Traditionally Linux has guaranteed that programs will continue to work
no matter how they were coded.
From: Eric Dumazet <hidden> Date: 2016-02-08 22:57:49
On Mon, 2016-02-08 at 11:38 -0800, Stephen Hemminger wrote:
The iproute2 command can be fixed, but adding dependency on size of response
gets gross fast. Imagine when 4 more fields get added, this doesn't scale well.
Really ? I see no problem at all doing the proper tests.
Also, the definition of userspace ABI is that structures can't change.
There are many other utilities that are not visible that may get broken.
Traditionally Linux has guaranteed that programs will continue to work
no matter how they were coded.
Stephen, we have been doing that for years.
Whole point of TLV is that it allows us to add new fields at the end of
the structures.
Yes, some buggy programs might need a fix.
Look at iproute2, you were the one adding in 2004 code to cope with
various tcp_info sizes.
So 12 years later, you cannot say it does not work anymore.
From: David Miller <davem@davemloft.net> Date: 2016-02-09 08:40:35
From: Eric Dumazet <redacted>
Date: Mon, 08 Feb 2016 14:57:40 -0800
Whole point of TLV is that it allows us to add new fields at the end of
the structures.
...
Look at iproute2, you were the one adding in 2004 code to cope with
various tcp_info sizes.
So 12 years later, you cannot say it does not work anymore.
From: Jamal Hadi Salim <jhs@mojatatu.com> Date: 2016-02-09 10:56:34
On 16-02-09 03:40 AM, David Miller wrote:
From: Eric Dumazet <redacted>
Date: Mon, 08 Feb 2016 14:57:40 -0800
quoted
Whole point of TLV is that it allows us to add new fields at the end of
the structures.
...
quoted
Look at iproute2, you were the one adding in 2004 code to cope with
various tcp_info sizes.
So 12 years later, you cannot say it does not work anymore.
+1
The TLV L should be canonical way to determine length. i.e should be
sufficient to just look at L and understand that content has changed.
But:
Using sizeof could be dangerous unless the data is packed to be
32-bit aligned. Looking INET_DIAG_INFO check for sizeof
there is a small 8 bit hole in tcp_info I think between
these two fields:
----
__u8 tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
__u32 tcpi_rto;
---
The kernel will pad to make sure the TLV data is 32-bit aligned.
I am not sure if that will be the same length as sizeof() in all
hardware + compilers... For this case,
it is almost safe to just add a version field - probably in the hole.
Or have a #define to say what the expected length should be. Or add
an 8 bit pad.
In general adding new fields that are non-optional is problematic. i.e
by non-optional i mean always expected to be present.
I think a good test is old kernel with new iproute2. If the new field
is non-optional, it will fail (example iproute2 may try to print a value
that it expects but because old kernel doesnt understand it; it is
non-existent).
cheers,
jamal
From: Stephen Hemminger <stephen@networkplumber.org> Date: 2016-02-09 19:17:49
Support for the new rx_nohandler statistic.
This code is designed to handle the case where the kernel reported statistic
structure is smaller than the larger structure in later releases (and vice versa).
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/ipaddress.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
From: Jarod Wilson <hidden> Date: 2016-02-09 23:51:39
On Tue, Feb 09, 2016 at 11:17:57AM -0800, Stephen Hemminger wrote:
Support for the new rx_nohandler statistic.
This code is designed to handle the case where the kernel reported statistic
structure is smaller than the larger structure in later releases (and vice versa).
This seems to work here, for the most part. However, if you are running a
kernel with the new counter, and the counter happens to contain 0, aren't
we going to not print anything?
I've got a tweaked version here locally that gets a touch messy, where I
get a count of members from RTA_DATA(IFLA_STATS{,64} / sizeof(__u{32,64}),
pass that into the print functions, and key off that length for whether or
not to print the extra members, so they'll show up even when 0, if they're
supported. This does rely on strict ordering of the struct members, no
reordering, no removals, etc., but I think everyone is already in favor of
that. Looks like the same sort of length checks could be used for
rx_compressed and tx_compressed as well, as I think they fall victim to
the same issue of not printing if those counters are legitimately 0. Yes,
it's a little uglier, and more brittle, but more accurate output.
Work-in-progress patch:
From: Stephen Hemminger <stephen@networkplumber.org> Date: 2016-02-10 01:40:54
On Tue, 9 Feb 2016 18:51:35 -0500
Jarod Wilson [off-list ref] wrote:
On Tue, Feb 09, 2016 at 11:17:57AM -0800, Stephen Hemminger wrote:
quoted
Support for the new rx_nohandler statistic.
This code is designed to handle the case where the kernel reported statistic
structure is smaller than the larger structure in later releases (and vice versa).
This seems to work here, for the most part. However, if you are running a
kernel with the new counter, and the counter happens to contain 0, aren't
we going to not print anything?
That is the desirable outcome, since if run on older system the
output format will not change from current format.
I've got a tweaked version here locally that gets a touch messy, where I
get a count of members from RTA_DATA(IFLA_STATS{,64} / sizeof(__u{32,64}),
pass that into the print functions, and key off that length for whether or
not to print the extra members, so they'll show up even when 0, if they're
supported. This does rely on strict ordering of the struct members, no
reordering, no removals, etc., but I think everyone is already in favor of
that. Looks like the same sort of length checks could be used for
rx_compressed and tx_compressed as well, as I think they fall victim to
the same issue of not printing if those counters are legitimately 0. Yes,
it's a little uglier, and more brittle, but more accurate output.
From: Eric Dumazet <hidden> Date: 2016-02-10 04:52:46
On Tue, 2016-02-09 at 17:41 -0800, Stephen Hemminger wrote:
On Tue, 9 Feb 2016 18:51:35 -0500
Jarod Wilson [off-list ref] wrote:
quoted
On Tue, Feb 09, 2016 at 11:17:57AM -0800, Stephen Hemminger wrote:
quoted
Support for the new rx_nohandler statistic.
This code is designed to handle the case where the kernel reported statistic
structure is smaller than the larger structure in later releases (and vice versa).
This seems to work here, for the most part. However, if you are running a
kernel with the new counter, and the counter happens to contain 0, aren't
we going to not print anything?
That is the desirable outcome, since if run on older system the
output format will not change from current format.
The problem here is that a change in output might break some user
scripts using sed/whatever games.
So it might be better to output a zero field, so that such breakages are
detected early, even if no packet was dropped at the time the new kernel
was tested.
Having a binary that adds the new field only in some cases hides the
change. It looks fine for us humans, but not for programs processing the
output.
From: Jarod Wilson <hidden> Date: 2016-02-10 13:21:03
On Tue, Feb 09, 2016 at 08:52:38PM -0800, Eric Dumazet wrote:
On Tue, 2016-02-09 at 17:41 -0800, Stephen Hemminger wrote:
quoted
On Tue, 9 Feb 2016 18:51:35 -0500
Jarod Wilson [off-list ref] wrote:
quoted
On Tue, Feb 09, 2016 at 11:17:57AM -0800, Stephen Hemminger wrote:
quoted
Support for the new rx_nohandler statistic.
This code is designed to handle the case where the kernel reported statistic
structure is smaller than the larger structure in later releases (and vice versa).
This seems to work here, for the most part. However, if you are running a
kernel with the new counter, and the counter happens to contain 0, aren't
we going to not print anything?
That is the desirable outcome, since if run on older system the
output format will not change from current format.
The problem here is that a change in output might break some user
scripts using sed/whatever games.
So it might be better to output a zero field, so that such breakages are
detected early, even if no packet was dropped at the time the new kernel
was tested.
Having a binary that adds the new field only in some cases hides the
change. It looks fine for us humans, but not for programs processing the
output.
On my test setup, my bond's active interface currently has 0, while the
backup interface has a few thousand, so I can alternate back and forth
checking the interfaces, and one doesn't print the counter while the other
does, which is what seemed odd to me and prompted the added ugliness. But
most setups (anything outside of bond/team currently) should never have
this counter incremented, we do have prior art with the compressed fields,
and scripts really probably ought to be scraping stats out of sysfs rather
than using ip, so I can sort of understand not wanting the added ugliness.
I do tend to prefer consistency though.
--
Jarod Wilson
jarod@redhat.com
From: Andy Gospodarek <hidden> Date: 2016-02-10 15:06:42
On Wed, Feb 10, 2016 at 08:20:59AM -0500, Jarod Wilson wrote:
On Tue, Feb 09, 2016 at 08:52:38PM -0800, Eric Dumazet wrote:
quoted
On Tue, 2016-02-09 at 17:41 -0800, Stephen Hemminger wrote:
quoted
On Tue, 9 Feb 2016 18:51:35 -0500
Jarod Wilson [off-list ref] wrote:
quoted
On Tue, Feb 09, 2016 at 11:17:57AM -0800, Stephen Hemminger wrote:
quoted
Support for the new rx_nohandler statistic.
This code is designed to handle the case where the kernel reported statistic
structure is smaller than the larger structure in later releases (and vice versa).
This seems to work here, for the most part. However, if you are running a
kernel with the new counter, and the counter happens to contain 0, aren't
we going to not print anything?
That is the desirable outcome, since if run on older system the
output format will not change from current format.
The problem here is that a change in output might break some user
scripts using sed/whatever games.
So it might be better to output a zero field, so that such breakages are
detected early, even if no packet was dropped at the time the new kernel
was tested.
Having a binary that adds the new field only in some cases hides the
change. It looks fine for us humans, but not for programs processing the
output.
On my test setup, my bond's active interface currently has 0, while the
backup interface has a few thousand, so I can alternate back and forth
checking the interfaces, and one doesn't print the counter while the other
does, which is what seemed odd to me and prompted the added ugliness. But
most setups (anything outside of bond/team currently) should never have
this counter incremented, we do have prior art with the compressed fields,
and scripts really probably ought to be scraping stats out of sysfs rather
than using ip, so I can sort of understand not wanting the added ugliness.
I do tend to prefer consistency though.
FWIW, I tend to agree with Jarod and Eric on this. Consistency seems
better, even if 0 all the time.