diff mbox series

[iproute2,3/4] ip-monitor: Include stats events in default and "all" cases

Message ID 20220922061938.202705-4-bpoirier@nvidia.com (mailing list archive)
State Accepted
Delegated to: Stephen Hemminger
Headers show
Series monitor command fixes | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Benjamin Poirier Sept. 22, 2022, 6:19 a.m. UTC
It seems that stats were omitted from `ip monitor` and `ip monitor all`.
Since all other event types are included, include stats as well. Use the
same logic as for nexthops.

Fixes: a05a27c07cbf ("ipmonitor: Add monitoring support for stats events")
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
---
 ip/ipmonitor.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Stephen Hemminger Oct. 25, 2022, 3:51 p.m. UTC | #1
On Thu, 22 Sep 2022 15:19:37 +0900
Benjamin Poirier <bpoirier@nvidia.com> wrote:

> It seems that stats were omitted from `ip monitor` and `ip monitor all`.
> Since all other event types are included, include stats as well. Use the
> same logic as for nexthops.
> 
> Fixes: a05a27c07cbf ("ipmonitor: Add monitoring support for stats events")
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>

This change has caused a regression. Simple ip monitor command now fails.

$ ip monitor
Failed to add stats group to list

The failure is from setsockopt() returning -EINVAL

Using git bisect this patch is identified as the cause.
Please fix ASAP or will revert from next release and maybe even make
a point release to remove it.
diff mbox series

Patch

diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c
index 380ab526..cb2195d1 100644
--- a/ip/ipmonitor.c
+++ b/ip/ipmonitor.c
@@ -180,6 +180,7 @@  static int accept_msg(struct rtnl_ctrl_data *ctrl,
 
 int do_ipmonitor(int argc, char **argv)
 {
+	int lstats = 0, stats_set = 1;
 	int lnexthop = 0, nh_set = 1;
 	char *file = NULL;
 	unsigned int groups = 0;
@@ -190,7 +191,6 @@  int do_ipmonitor(int argc, char **argv)
 	int lprefix = 0;
 	int lneigh = 0;
 	int lnetconf = 0;
-	int lstats = 0;
 	int lrule = 0;
 	int lnsid = 0;
 	int ifindex = 0;
@@ -224,41 +224,51 @@  int do_ipmonitor(int argc, char **argv)
 			llink = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "address") == 0) {
 			laddr = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "route") == 0) {
 			lroute = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "mroute") == 0) {
 			lmroute = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "prefix") == 0) {
 			lprefix = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "neigh") == 0) {
 			lneigh = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "netconf") == 0) {
 			lnetconf = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "rule") == 0) {
 			lrule = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "nsid") == 0) {
 			lnsid = 1;
 			groups = 0;
 			nh_set = 0;
+			stats_set = 0;
 		} else if (matches(*argv, "nexthop") == 0) {
 			lnexthop = 1;
 			groups = 0;
+			stats_set = 0;
 		} else if (strcmp(*argv, "stats") == 0) {
 			lstats = 1;
 			groups = 0;
@@ -336,6 +346,8 @@  int do_ipmonitor(int argc, char **argv)
 	}
 	if (nh_set)
 		lnexthop = 1;
+	if (stats_set)
+		lstats = 1;
 
 	if (file) {
 		FILE *fp;