[PATCH v2 0/3] tools/libxenstat: small fixes in the Linux network collector

Olivier Lambert posted 3 patches 1 month ago
Only 0 patches received!
tools/libs/stat/xenstat_linux.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
[PATCH v2 0/3] tools/libxenstat: small fixes in the Linux network collector
Posted by Olivier Lambert 1 month ago
While looking at xenstat_collect_networks() for commit 0c53660c1cf3
("tools/libxenstat: don't lose all VIFs when dom0 has no Linux bridge"),
I noticed a few more issues in xenstat_linux.c:

- getBridge() dereferences NULL when /sys/class/net can't be opened,
- after a failed /proc/net/dev header check, the next call skips the
  check and parses the file anyway,
- parseNetDevLine() doesn't initialise all of its outputs (cleanup, no
  functional change intended).

Patches 1 and 2 may be worth backporting. If so, patch 1 should go along
with 0c53660c1cf3: without it, the empty bridge name would make every
VIF disappear instead.

Testing: libxenstat builds with the usual tools CFLAGS (including
-Werror). I also tested the series on an XCP-ng 8.3 host (Xen 4.17.7,
Open vSwitch), applied with 0c53660c1cf3 on top of its libxenstat and
loaded via LD_LIBRARY_PATH:
- xentop reports the same networks and counters with and without the
  series,
- with /sys/class/net made unavailable in a private mount namespace,
  xentop no longer segfaults in readdir() called from
  xenstat_collect_networks(),
- with an invalid /proc/net/dev bind-mounted over the real one, a second
  xenstat_get_node() call fails again instead of parsing the file.

Changes in v2:
- Patch 3: drop "fix" from the subject and add an Amends: tag, as it
  changes no behaviour (Baptiste Le Duc).
- Collect Baptiste's Reviewed-by on patches 1 and 2.

v1: https://lore.kernel.org/xen-devel/1792142033.8631fc262581453bbf619ec5b2062170.1a143fd43ef0008425@vates.tech/

Olivier Lambert (3):
  tools/libxenstat: don't crash when /sys/class/net can't be opened
  tools/libxenstat: don't skip the /proc/net/dev check after a failure
  tools/libxenstat: clean up output initialisation in parseNetDevLine()

 tools/libs/stat/xenstat_linux.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

-- 
2.53.0



-- 
Olivier Lambert | Vates CEO

XCP-ng & Xen Orchestra - Vates solutions
Book a meeting with me: https://calrs.vates.tech/u/olivier-lambert
web: https://vates.tech
Re: [PATCH v2 0/3] tools/libxenstat: small fixes in the Linux network collector
Posted by Baptiste Le Duc 4 weeks ago
I might be wrong but it seems the v2 patches have not been sent
On 10/24/26 10:56 AM, Olivier Lambert wrote:
> While looking at xenstat_collect_networks() for commit 0c53660c1cf3
> ("tools/libxenstat: don't lose all VIFs when dom0 has no Linux bridge"),
> I noticed a few more issues in xenstat_linux.c:
> 
> - getBridge() dereferences NULL when /sys/class/net can't be opened,
> - after a failed /proc/net/dev header check, the next call skips the
>    check and parses the file anyway,
> - parseNetDevLine() doesn't initialise all of its outputs (cleanup, no
>    functional change intended).
> 
> Patches 1 and 2 may be worth backporting. If so, patch 1 should go along
> with 0c53660c1cf3: without it, the empty bridge name would make every
> VIF disappear instead.
> 
> Testing: libxenstat builds with the usual tools CFLAGS (including
> -Werror). I also tested the series on an XCP-ng 8.3 host (Xen 4.17.7,
> Open vSwitch), applied with 0c53660c1cf3 on top of its libxenstat and
> loaded via LD_LIBRARY_PATH:
> - xentop reports the same networks and counters with and without the
>    series,
> - with /sys/class/net made unavailable in a private mount namespace,
>    xentop no longer segfaults in readdir() called from
>    xenstat_collect_networks(),
> - with an invalid /proc/net/dev bind-mounted over the real one, a second
>    xenstat_get_node() call fails again instead of parsing the file.
> 
> Changes in v2:
> - Patch 3: drop "fix" from the subject and add an Amends: tag, as it
>    changes no behaviour (Baptiste Le Duc).
> - Collect Baptiste's Reviewed-by on patches 1 and 2.
> 
> v1: https://lore.kernel.org/xen-devel/1792142033.8631fc262581453bbf619ec5b2062170.1a143fd43ef0008425@vates.tech/
>