From: Lars Ellenberg <lars.ellenberg@linbit.com>
To: drbd-dev@lists.linbit.com
Subject: Re: [Drbd-dev] drbd_nl.c:drbd_adm_prepare() indexes drbd_genl_ops[] by cmd number
Date: Mon, 3 Jun 2019 11:21:18 +0200 [thread overview]
Message-ID: <20190603092118.GH5803@soda.linbit> (raw)
In-Reply-To: <f5c1cf53-0eb7-35ab-7fbb-cb64e5f16305@gmail.com>
On Fri, May 31, 2019 at 01:01:24PM -0600, David Butterfield wrote:
> (Is this the right place to send comments on the source code such as this one?)
>
> In drbd_nl.c:
>
> static int drbd_adm_prepare(struct drbd_config_context *adm_ctx,
> struct sk_buff *skb, struct genl_info *info, unsigned flags)
> {
> struct drbd_genlmsghdr *d_in = info->userhdr;
> const u8 cmd = info->genlhdr->cmd;
> int err;
>
> memset(adm_ctx, 0, sizeof(*adm_ctx));
>
> + //XXX I do not think you can find the ops for a command number by indexing this array.
> + //XXX The array is unordered and packed. I think it must search like genl_get_cmd().
drbd_genl_ops is a static struct genl_ops [], indexed by cmd.
family->ops is a struct genl_ops*, pointing to an array
indexed by "i" [0 .. (family->n_ops - 1)]
Any specific reason you are spending time with this code in particular?
> /*
> * genl_rcv_msg() only checks if commands with the GENL_ADMIN_PERM flag
> * set have CAP_NET_ADMIN; we also require CAP_SYS_ADMIN for
> * administrative commands.
> */
> if ((drbd_genl_ops[cmd].flags & GENL_ADMIN_PERM) &&
> drbd_security_netlink_recv(skb, CAP_SYS_ADMIN))
> return -EPERM;
>
> adm_ctx->reply_skb = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
> if (!adm_ctx->reply_skb) {
> err = -ENOMEM;
> goto fail;
> }
--
: Lars Ellenberg
: LINBIT | Keeping the Digital World Running
: DRBD -- Heartbeat -- Corosync -- Pacemaker
: R&D, Integration, Ops, Consulting, Support
DRBD® and LINBIT® are registered trademarks of LINBIT
next prev parent reply other threads:[~2019-06-03 9:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 19:01 [Drbd-dev] drbd_nl.c:drbd_adm_prepare() indexes drbd_genl_ops[] by cmd number David Butterfield
2019-06-03 9:21 ` Lars Ellenberg [this message]
[not found] ` <cf05cd9c-687f-6264-0bc3-aefa90c91b3a@gmail.com>
[not found] ` <CANr6vz8kxacCYSb38G464Y2c1xw1ZqZAddN45LTwEcnE_Y2dsA@mail.gmail.com>
2019-06-04 8:18 ` David Butterfield
2019-06-04 9:41 ` Lars Ellenberg
2019-06-04 9:49 ` Lars Ellenberg
2019-06-05 15:57 ` [Drbd-dev] history uuids misaligned within device_statistics David Butterfield
2019-06-12 13:58 ` Lars Ellenberg
2019-06-18 6:16 ` David Butterfield
2019-06-24 15:35 ` Lars Ellenberg
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=20190603092118.GH5803@soda.linbit \
--to=lars.ellenberg@linbit.com \
--cc=drbd-dev@lists.linbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.