diff mbox series

[1/5] monitor: Remove unused code path

Message ID 20231227060954.103572-1-denkenz@gmail.com (mailing list archive)
State New
Headers show
Series [1/5] monitor: Remove unused code path | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-alpine-ci-makedistcheck fail Make Distcheck Configure FAIL: configure.ac:23: installing 'build-aux/compile' configure.ac:36: installing 'build-aux/config.guess' configure.ac:36: installing 'build-aux/config.sub' configure.ac:8: installing 'build-aux/install-sh' configure.ac:8: installing 'build-aux/missing' Makefile.am: installing 'build-aux/depcomp' parallel-tests: installing 'build-aux/test-driver' configure: error: libbpf is required
prestwoj/iwd-ci-makedistcheck fail Make Distcheck Configure FAIL: configure.ac:23: installing 'build-aux/compile' configure.ac:36: installing 'build-aux/config.guess' configure.ac:36: installing 'build-aux/config.sub' configure.ac:8: installing 'build-aux/install-sh' configure.ac:8: installing 'build-aux/missing' Makefile.am: installing 'build-aux/depcomp' parallel-tests: installing 'build-aux/test-driver' configure: error: libbpf is required
prestwoj/iwd-alpine-ci-makecheckvalgrind fail Build Configuration FAIL: configure.ac:23: installing 'build-aux/compile' configure.ac:36: installing 'build-aux/config.guess' configure.ac:36: installing 'build-aux/config.sub' configure.ac:8: installing 'build-aux/install-sh' configure.ac:8: installing 'build-aux/missing' Makefile.am: installing 'build-aux/depcomp' parallel-tests: installing 'build-aux/test-driver' configure: error: libbpf is required
prestwoj/iwd-alpine-ci-build fail Build Configuration FAIL: configure.ac:23: installing 'build-aux/compile' configure.ac:36: installing 'build-aux/config.guess' configure.ac:36: installing 'build-aux/config.sub' configure.ac:8: installing 'build-aux/install-sh' configure.ac:8: installing 'build-aux/missing' Makefile.am: installing 'build-aux/depcomp' parallel-tests: installing 'build-aux/test-driver' configure: error: libbpf is required
prestwoj/iwd-alpine-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-build fail Build Configuration FAIL: configure.ac:23: installing 'build-aux/compile' configure.ac:36: installing 'build-aux/config.guess' configure.ac:36: installing 'build-aux/config.sub' configure.ac:8: installing 'build-aux/install-sh' configure.ac:8: installing 'build-aux/missing' Makefile.am: installing 'build-aux/depcomp' parallel-tests: installing 'build-aux/test-driver' configure: error: libbpf is required
prestwoj/iwd-ci-makecheckvalgrind fail Build Configuration FAIL: configure.ac:23: installing 'build-aux/compile' configure.ac:36: installing 'build-aux/config.guess' configure.ac:36: installing 'build-aux/config.sub' configure.ac:8: installing 'build-aux/install-sh' configure.ac:8: installing 'build-aux/missing' Makefile.am: installing 'build-aux/depcomp' parallel-tests: installing 'build-aux/test-driver' configure: error: libbpf is required
prestwoj/iwd-ci-clang fail Clang IWD - Configuration FAIL: configure.ac:23: installing 'build-aux/compile' configure.ac:36: installing 'build-aux/config.guess' configure.ac:36: installing 'build-aux/config.sub' configure.ac:8: installing 'build-aux/install-sh' configure.ac:8: installing 'build-aux/missing' Makefile.am: installing 'build-aux/depcomp' parallel-tests: installing 'build-aux/test-driver' configure: error: libbpf is required
prestwoj/iwd-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-testrunner pending testrunner SKIP
prestwoj/iwd-ci-incremental_build fail Build Configuration FAIL (patch 4): configure.ac:23: installing 'build-aux/compile' configure.ac:8: installing 'build-aux/missing' Makefile.am: installing 'build-aux/depcomp' configure: error: libbpf is required
prestwoj/iwd-alpine-ci-incremental_build fail Make FAIL (patch 3): monitor/main.c: In function 'open_packet': monitor/main.c:176:17: error: implicit declaration of function 'close'; did you mean 'pclose'? [-Werror=implicit-function-declaration] 176 | close(fd); | ^~~~~ | pclose cc1: all warnings being treated as errors make[1]: *** [Makefile:2541: monitor/main.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1715: all] Error 2

Commit Message

Denis Kenzior Dec. 27, 2023, 6:09 a.m. UTC
nlmon_print_genl invokes genl_ctrl when a generic netlink control
message is encountered.  genl_ctrl() tries to filter nl80211 family
appearance messages and setup nlmon->id with the extracted family id.
However, the id is already provided inside main.c by using nlmon_open,
and no control messages are processed by nlmon in 'capture' mode (-r
command line argument not passed) since all genl messages go through
nlmon_message() path instead.
---
 monitor/nlmon.c | 36 +++---------------------------------
 1 file changed, 3 insertions(+), 33 deletions(-)

Comments

Denis Kenzior Jan. 2, 2024, 5:01 p.m. UTC | #1
On 12/27/23 00:09, Denis Kenzior wrote:
> nlmon_print_genl invokes genl_ctrl when a generic netlink control
> message is encountered.  genl_ctrl() tries to filter nl80211 family
> appearance messages and setup nlmon->id with the extracted family id.
> However, the id is already provided inside main.c by using nlmon_open,
> and no control messages are processed by nlmon in 'capture' mode (-r
> command line argument not passed) since all genl messages go through
> nlmon_message() path instead.
> ---
>   monitor/nlmon.c | 36 +++---------------------------------
>   1 file changed, 3 insertions(+), 33 deletions(-)
> 

I went ahead and applied patches 1-4.  The RFC one still needs better support 
from the build system, so it wasn't applied.

Regards,
-Denis
diff mbox series

Patch

diff --git a/monitor/nlmon.c b/monitor/nlmon.c
index ed40264bacd6..7f8ecdaa1996 100644
--- a/monitor/nlmon.c
+++ b/monitor/nlmon.c
@@ -7359,35 +7359,6 @@  void nlmon_destroy(struct nlmon *nlmon)
 	l_free(nlmon);
 }
 
-static void genl_ctrl(struct nlmon *nlmon, const void *data, uint32_t len)
-{
-	const struct genlmsghdr *genlmsg = data;
-	const struct nlattr *nla;
-	char name[GENL_NAMSIZ];
-	uint16_t id = 0;
-
-	if (genlmsg->cmd != CTRL_CMD_NEWFAMILY)
-		return;
-
-	for (nla = data + GENL_HDRLEN; NLA_OK(nla, len);
-						nla = NLA_NEXT(nla, len)) {
-		switch (nla->nla_type & NLA_TYPE_MASK) {
-		case CTRL_ATTR_FAMILY_ID:
-			id = *((uint16_t *) NLA_DATA(nla));
-			break;
-		case CTRL_ATTR_FAMILY_NAME:
-			strncpy(name, NLA_DATA(nla), GENL_NAMSIZ - 1);
-			break;
-		}
-	}
-
-	if (id == 0)
-		return;
-
-	if (!strcmp(name, NL80211_GENL_NAME))
-		nlmon->id = id;
-}
-
 static const char *scope_to_string(uint8_t scope)
 {
 	switch (scope) {
@@ -8208,10 +8179,9 @@  void nlmon_print_genl(struct nlmon *nlmon, const struct timeval *tv,
 	for (nlmsg = data; NLMSG_OK(nlmsg, size);
 				nlmsg = NLMSG_NEXT(nlmsg, size)) {
 		if (nlmsg->nlmsg_type == GENL_ID_CTRL)
-			genl_ctrl(nlmon, NLMSG_DATA(nlmsg),
-						NLMSG_PAYLOAD(nlmsg, 0));
-		else
-			nlmon_message(nlmon, tv, NULL, nlmsg);
+			continue;
+
+		nlmon_message(nlmon, tv, NULL, nlmsg);
 	}
 }