[Drbd-dev] drbd_nl.c:drbd_adm_prepare() indexes drbd_genl_ops[] by cmd number

David Butterfield dab21774 at gmail.com
Fri May 31 21:01:24 CEST 2019


(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().
  	/*
  	 * 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;
  	}


More information about the drbd-dev mailing list