On 09/11/2024 19:34, David Ahern wrote: > On 11/7/24 1:02 AM, Chiara Meiohas wrote: >> diff --git a/rdma/monitor.c b/rdma/monitor.c >> new file mode 100644 >> index 00000000..0a2d3053 >> --- /dev/null >> +++ b/rdma/monitor.c >> @@ -0,0 +1,169 @@ >> +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB >> +/* >> + * monitor.c RDMA tool >> + * Authors: Chiara Meiohas <cmeiohas@xxxxxxxxxx> >> + */ >> + >> +#include "rdma.h" >> + >> +/* Global utils flags */ >> +extern int json; > use include utils.h instead > >> + >> +static void mon_print_event_type(struct nlattr **tb) >> +{ >> + static const char *const event_types_str[] = { >> + "[REGISTER]", >> + "[UNREGISTER]", >> + "[NETDEV_ATTACH]", >> + "[NETDEV_DETACH]", >> + }; >> + enum rdma_nl_notify_event_type etype; >> + static char unknown_type[32]; > why static? > >> + >> + if (!tb[RDMA_NLDEV_ATTR_EVENT_TYPE]) >> + return; >> + >> + etype = mnl_attr_get_u8(tb[RDMA_NLDEV_ATTR_EVENT_TYPE]); >> + if (etype < ARRAY_SIZE(event_types_str)) { >> + print_string(PRINT_ANY, "event_type", "%s\t", >> + event_types_str[etype]); >> + } else { >> + snprintf(unknown_type, sizeof(unknown_type), "[UNKNOWN 0x%02x]", etype); > wrap at about 80 columns; in this case etype should go on the next line I'll prepare the v3 patch with these changes. Additionally, in the case where rdma monitor is not supported (rdma sys returns "monitor off"), it will return an error instead of looping. Thanks, Chiara