diff mbox series

Reduce nlctrl name resolution calls

Message ID 20210715013744.5144-1-masashi.honma@gmail.com
State Changes Requested
Headers show
Series Reduce nlctrl name resolution calls | expand

Commit Message

Masashi Honma July 15, 2021, 1:37 a.m. UTC
This patch reduces 3 nlctrl name resolution calls at least.

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
 src/drivers/driver_nl80211.c | 8 +++++++-
 src/drivers/driver_nl80211.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Jouni Malinen Aug. 19, 2021, 5:35 p.m. UTC | #1
On Thu, Jul 15, 2021 at 10:37:44AM +0900, Masashi Honma wrote:
> This patch reduces 3 nlctrl name resolution calls at least.

Can you please provide a more complete commit message explaining why
this is needed, i.e., why would it be an issue of doing couple of
unneeded name resolutions during interface initialization?
diff mbox series

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 8eb033c78..65cd35869 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -604,7 +604,7 @@  static int nl_get_multicast_id(struct nl80211_global *global,
 	msg = nlmsg_alloc();
 	if (!msg)
 		return -ENOMEM;
-	if (!genlmsg_put(msg, 0, 0, genl_ctrl_resolve(global->nl, "nlctrl"),
+	if (!genlmsg_put(msg, 0, 0, global->nlctrl_id,
 			 0, 0, CTRL_CMD_GETFAMILY, 0) ||
 	    nla_put_string(msg, CTRL_ATTR_FAMILY_NAME, family)) {
 		nlmsg_free(msg);
@@ -1883,6 +1883,12 @@  static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global)
 		goto err;
 	}
 
+	global->nlctrl_id = genl_ctrl_resolve(global->nl, "nlctrl");
+	if (global->nlctrl_id < 0) {
+		wpa_printf(MSG_ERROR, "nl80211: 'nlctrl' generic netlink not found");
+		goto err;
+	}
+
 	global->nl_event = nl_create_handle(global->nl_cb, "event");
 	if (global->nl_event == NULL)
 		goto err;
diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h
index 9d61c1d69..80d456472 100644
--- a/src/drivers/driver_nl80211.h
+++ b/src/drivers/driver_nl80211.h
@@ -32,6 +32,7 @@  struct nl80211_global {
 	struct nl_cb *nl_cb;
 	struct nl_sock *nl;
 	int nl80211_id;
+	int nlctrl_id;
 	int ioctl_sock; /* socket for ioctl() use */
 
 	struct nl_sock *nl_event;