* [PATCH iproute2-next 1/2] mnlg: remove unnused mnlg_socket structure
@ 2022-08-26 18:17 Jacob Keller
2022-08-26 18:17 ` [PATCH iproute2-next 2/2] utils: extract CTRL_ATTR_MAXATTR and save it Jacob Keller
2022-09-01 3:00 ` [PATCH iproute2-next 1/2] mnlg: remove unnused mnlg_socket structure patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jacob Keller @ 2022-08-26 18:17 UTC (permalink / raw)
To: netdev; +Cc: Jiri Pirko, Jacob Keller
Commit 62ff25e51bb6 ("devlink: Use generic socket helpers from library")
removed all of the users of struct mnlg_socket, but didn't remove the
structure itself. Fix that.
Fixes: 62ff25e51bb6 ("devlink: Use generic socket helpers from library")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
devlink/mnlg.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/devlink/mnlg.c b/devlink/mnlg.c
index e6d92742c150..b2e0b8c0f274 100644
--- a/devlink/mnlg.c
+++ b/devlink/mnlg.c
@@ -22,14 +22,6 @@
#include "utils.h"
#include "mnlg.h"
-struct mnlg_socket {
- struct mnl_socket *nl;
- char *buf;
- uint32_t id;
- uint8_t version;
- unsigned int seq;
-};
-
int mnlg_socket_send(struct mnlu_gen_socket *nlg, const struct nlmsghdr *nlh)
{
return mnl_socket_sendto(nlg->nl, nlh, nlh->nlmsg_len);
base-commit: fc6be06cab4327eecac5885f80048e7a57dd28e8
--
2.37.1.394.gc50926e1f488
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH iproute2-next 2/2] utils: extract CTRL_ATTR_MAXATTR and save it
2022-08-26 18:17 [PATCH iproute2-next 1/2] mnlg: remove unnused mnlg_socket structure Jacob Keller
@ 2022-08-26 18:17 ` Jacob Keller
2022-09-01 3:00 ` [PATCH iproute2-next 1/2] mnlg: remove unnused mnlg_socket structure patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2022-08-26 18:17 UTC (permalink / raw)
To: netdev; +Cc: Jiri Pirko, Jacob Keller
mnlu_gen_socket_open opens a socket and configures it for use with a
generic netlink family. As part of this process it sends a
CTRL_CMD_GETFAMILY to get the ID for the family name requested.
In addition to the family id, this command reports a few other useful
values including the maximum attribute. The maximum attribute is useful in
order to know whether a given attribute is supported and for knowing the
necessary size to allocate for other operations such as policy dumping.
Since we already have to issue a CTRL_CMD_GETFAMILY to get the id, we can
also store the maximum attribute as well. Modify the callback functions to
parse the maximum attribute NLA and store it in the mnlu_gen_socket
structure.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
include/mnl_utils.h | 1 +
lib/mnl_utils.c | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/include/mnl_utils.h b/include/mnl_utils.h
index aa5f0a9b17c7..2193934849e1 100644
--- a/include/mnl_utils.h
+++ b/include/mnl_utils.h
@@ -6,6 +6,7 @@ struct mnlu_gen_socket {
struct mnl_socket *nl;
char *buf;
uint32_t family;
+ uint32_t maxattr;
unsigned int seq;
uint8_t version;
};
diff --git a/lib/mnl_utils.c b/lib/mnl_utils.c
index d5abff58d816..79bac5cfd4de 100644
--- a/lib/mnl_utils.c
+++ b/lib/mnl_utils.c
@@ -110,7 +110,7 @@ int mnlu_socket_recv_run(struct mnl_socket *nl, unsigned int seq, void *buf, siz
return err;
}
-static int get_family_id_attr_cb(const struct nlattr *attr, void *data)
+static int get_family_attrs_cb(const struct nlattr *attr, void *data)
{
int type = mnl_attr_get_type(attr);
const struct nlattr **tb = data;
@@ -121,20 +121,26 @@ static int get_family_id_attr_cb(const struct nlattr *attr, void *data)
if (type == CTRL_ATTR_FAMILY_ID &&
mnl_attr_validate(attr, MNL_TYPE_U16) < 0)
return MNL_CB_ERROR;
+ if (type == CTRL_ATTR_MAXATTR &&
+ mnl_attr_validate(attr, MNL_TYPE_U32) < 0)
+ return MNL_CB_ERROR;
tb[type] = attr;
return MNL_CB_OK;
}
-static int get_family_id_cb(const struct nlmsghdr *nlh, void *data)
+static int get_family_cb(const struct nlmsghdr *nlh, void *data)
{
struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
struct nlattr *tb[CTRL_ATTR_MAX + 1] = {};
- uint32_t *p_id = data;
+ struct mnlu_gen_socket *nlg = data;
- mnl_attr_parse(nlh, sizeof(*genl), get_family_id_attr_cb, tb);
+ mnl_attr_parse(nlh, sizeof(*genl), get_family_attrs_cb, tb);
if (!tb[CTRL_ATTR_FAMILY_ID])
return MNL_CB_ERROR;
- *p_id = mnl_attr_get_u16(tb[CTRL_ATTR_FAMILY_ID]);
+ if (!tb[CTRL_ATTR_MAXATTR])
+ return MNL_CB_ERROR;
+ nlg->family = mnl_attr_get_u16(tb[CTRL_ATTR_FAMILY_ID]);
+ nlg->maxattr = mnl_attr_get_u32(tb[CTRL_ATTR_MAXATTR]);
return MNL_CB_OK;
}
@@ -159,7 +165,7 @@ static int family_get(struct mnlu_gen_socket *nlg, const char *family_name)
err = mnlu_socket_recv_run(nlg->nl, nlh->nlmsg_seq, nlg->buf,
MNL_SOCKET_BUFFER_SIZE,
- get_family_id_cb, &nlg->family);
+ get_family_cb, nlg);
return err;
}
--
2.37.1.394.gc50926e1f488
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2-next 1/2] mnlg: remove unnused mnlg_socket structure
2022-08-26 18:17 [PATCH iproute2-next 1/2] mnlg: remove unnused mnlg_socket structure Jacob Keller
2022-08-26 18:17 ` [PATCH iproute2-next 2/2] utils: extract CTRL_ATTR_MAXATTR and save it Jacob Keller
@ 2022-09-01 3:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-01 3:00 UTC (permalink / raw)
To: Jacob Keller; +Cc: netdev, jiri
Hello:
This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:
On Fri, 26 Aug 2022 11:17:40 -0700 you wrote:
> Commit 62ff25e51bb6 ("devlink: Use generic socket helpers from library")
> removed all of the users of struct mnlg_socket, but didn't remove the
> structure itself. Fix that.
>
> Fixes: 62ff25e51bb6 ("devlink: Use generic socket helpers from library")
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
>
> [...]
Here is the summary with links:
- [iproute2-next,1/2] mnlg: remove unnused mnlg_socket structure
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=0c3540635d67
- [iproute2-next,2/2] utils: extract CTRL_ATTR_MAXATTR and save it
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=89afe6ef89e5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-01 3:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 18:17 [PATCH iproute2-next 1/2] mnlg: remove unnused mnlg_socket structure Jacob Keller
2022-08-26 18:17 ` [PATCH iproute2-next 2/2] utils: extract CTRL_ATTR_MAXATTR and save it Jacob Keller
2022-09-01 3:00 ` [PATCH iproute2-next 1/2] mnlg: remove unnused mnlg_socket structure patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.