From: Jakub Kicinski <kuba@kernel•org>
To: davem@davemloft•net, johannes@sipsolutions•net
Cc: netdev@vger•kernel.org, edumazet@google•com, pabeni@redhat•com,
jiri@resnulli•us, razor@blackwall•org, nicolas.dichtel@6wind•com,
gnault@redhat•com, jacob.e.keller@intel•com, fw@strlen•de,
Jakub Kicinski <kuba@kernel•org>
Subject: [PATCH net-next 11/13] genetlink: inline old iteration helpers
Date: Tue, 18 Oct 2022 16:07:26 -0700 [thread overview]
Message-ID: <20221018230728.1039524-12-kuba@kernel.org> (raw)
In-Reply-To: <20221018230728.1039524-1-kuba@kernel.org>
All dumpers use the iterators now, inline the cmd by index
stuff into iterator code.
Signed-off-by: Jakub Kicinski <kuba@kernel•org>
---
net/netlink/genetlink.c | 32 +++++++++-----------------------
1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 63807204805a..301981bae83d 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -99,11 +99,6 @@ static const struct genl_family *genl_family_find_byname(char *name)
return NULL;
}
-static int genl_get_cmd_cnt(const struct genl_family *family)
-{
- return family->n_ops + family->n_small_ops;
-}
-
static void genl_op_from_full(const struct genl_family *family,
unsigned int i, struct genl_ops *op)
{
@@ -217,18 +212,6 @@ genl_get_cmd(u32 cmd, u8 flags, const struct genl_family *family,
return genl_cmd_full_to_split(op, family, &full, flags);
}
-static void genl_get_cmd_by_index(unsigned int i,
- const struct genl_family *family,
- struct genl_ops *op)
-{
- if (i < family->n_ops)
- genl_op_from_full(family, i, op);
- else if (i < family->n_ops + family->n_small_ops)
- genl_op_from_small(family, i - family->n_ops, op);
- else
- WARN_ON_ONCE(1);
-}
-
struct genl_op_iter {
const struct genl_family *family;
struct genl_split_ops doit;
@@ -246,22 +229,25 @@ genl_op_iter_init(const struct genl_family *family, struct genl_op_iter *iter)
iter->flags = 0;
- return genl_get_cmd_cnt(iter->family);
+ return iter->family->n_ops + iter->family->n_small_ops;
}
static bool genl_op_iter_next(struct genl_op_iter *iter)
{
+ const struct genl_family *family = iter->family;
struct genl_ops op;
- if (iter->i >= genl_get_cmd_cnt(iter->family))
+ if (iter->i < family->n_ops)
+ genl_op_from_full(family, iter->i, &op);
+ else if (iter->i < family->n_ops + family->n_small_ops)
+ genl_op_from_small(family, iter->i - family->n_ops, &op);
+ else
return false;
- genl_get_cmd_by_index(iter->i, iter->family, &op);
iter->i++;
- genl_cmd_full_to_split(&iter->doit, iter->family, &op, GENL_CMD_CAP_DO);
- genl_cmd_full_to_split(&iter->dumpit, iter->family,
- &op, GENL_CMD_CAP_DUMP);
+ genl_cmd_full_to_split(&iter->doit, family, &op, GENL_CMD_CAP_DO);
+ genl_cmd_full_to_split(&iter->dumpit, family, &op, GENL_CMD_CAP_DUMP);
iter->cmd = iter->doit.cmd | iter->dumpit.cmd;
iter->flags = iter->doit.flags | iter->dumpit.flags;
--
2.37.3
next prev parent reply other threads:[~2022-10-18 23:08 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 23:07 [PATCH net-next 00/13] genetlink: support per op type policies Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 01/13] genetlink: refactor the cmd <> policy mapping dump Jakub Kicinski
2022-10-19 7:50 ` Johannes Berg
2022-10-19 15:59 ` Jakub Kicinski
2022-10-19 21:20 ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 02/13] genetlink: move the private fields in struct genl_family Jakub Kicinski
2022-10-19 7:51 ` Johannes Berg
2022-10-19 21:21 ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 03/13] genetlink: introduce split op representation Jakub Kicinski
2022-10-19 7:59 ` Johannes Berg
2022-10-19 19:14 ` Jakub Kicinski
2022-10-19 19:36 ` Johannes Berg
2022-10-19 19:50 ` Jakub Kicinski
2022-10-19 21:28 ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 04/13] genetlink: load policy based on validation flags Jakub Kicinski
2022-10-19 8:01 ` Johannes Berg
2022-10-19 19:20 ` Jakub Kicinski
2022-10-19 19:33 ` Johannes Berg
2022-10-19 19:49 ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 05/13] genetlink: check for callback type at op load time Jakub Kicinski
2022-10-19 21:33 ` Jacob Keller
2022-10-19 21:45 ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 06/13] genetlink: add policies for both doit and dumpit in ctrl_dumppolicy_start() Jakub Kicinski
2022-10-19 8:08 ` Johannes Berg
2022-10-19 19:22 ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 07/13] genetlink: support split policies in ctrl_dumppolicy_put_op() Jakub Kicinski
2022-10-19 21:38 ` Jacob Keller
2022-10-19 21:46 ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 08/13] genetlink: inline genl_get_cmd() Jakub Kicinski
2022-10-19 21:46 ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 09/13] genetlink: add iterator for walking family ops Jakub Kicinski
2022-10-19 21:49 ` Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 10/13] genetlink: use iterator in the op to policy map dumping Jakub Kicinski
2022-10-19 21:53 ` Jacob Keller
2022-10-18 23:07 ` Jakub Kicinski [this message]
2022-10-19 22:15 ` [PATCH net-next 11/13] genetlink: inline old iteration helpers Jacob Keller
2022-10-18 23:07 ` [PATCH net-next 12/13] genetlink: allow families to use split ops directly Jakub Kicinski
2022-10-19 8:15 ` Johannes Berg
2022-10-19 19:25 ` Jakub Kicinski
2022-10-19 19:37 ` Johannes Berg
2022-10-19 19:57 ` Jakub Kicinski
2022-10-20 7:32 ` Johannes Berg
2022-10-20 18:09 ` Jakub Kicinski
2022-10-21 11:02 ` Johannes Berg
2022-10-21 15:01 ` Jakub Kicinski
2022-10-18 23:07 ` [PATCH net-next 13/13] genetlink: convert control family to split ops Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221018230728.1039524-12-kuba@kernel.org \
--to=kuba@kernel$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=fw@strlen$(echo .)de \
--cc=gnault@redhat$(echo .)com \
--cc=jacob.e.keller@intel$(echo .)com \
--cc=jiri@resnulli$(echo .)us \
--cc=johannes@sipsolutions$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nicolas.dichtel@6wind$(echo .)com \
--cc=pabeni@redhat$(echo .)com \
--cc=razor@blackwall$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox