lustre-devel-lustre.org archive mirror
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
	Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 18/19] lnet: Netlink improvements
Date: Sun, 28 Nov 2021 18:27:53 -0500	[thread overview]
Message-ID: <1638142074-5945-19-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1638142074-5945-1-git-send-email-jsimmons@infradead.org>

With the expansion of the use of Netlink several issues have been
encountered. This patch fixes many of the issues. The issues are:

1) Fix idx handling in lnet_genl_parse_list() function. It needs
   to always been incremented. Some renaming suggestion for
   enum lnet_nl_scalar_attrs from Neil. New LN_SCALAR_ATTR_INT_VALUE
   to allow pushing integers as well as strings from userspace.

2) Create struct genl_filter_list which will be used to create
   a list of items to pass back to userland. This will be a common
   setup.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9680
Lustre-commit: 82835a1952dcb37e8 ("LU-9680 net: Netlink improvements")
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/44358
Reviewed-by: Ben Evans <beevans@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
 include/linux/lnet/lib-types.h    |  8 +++++++-
 include/uapi/linux/lnet/lnet-nl.h | 29 +++++++++++++++++++++++++----
 net/lnet/lnet/api-ni.c            |  9 +++++----
 3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/include/linux/lnet/lib-types.h b/include/linux/lnet/lib-types.h
index 628d133..7631044 100644
--- a/include/linux/lnet/lib-types.h
+++ b/include/linux/lnet/lib-types.h
@@ -1320,7 +1320,13 @@ struct lnet {
 	struct list_head		ln_udsp_list;
 };
 
-static const struct nla_policy scalar_attr_policy[LN_SCALAR_CNT + 1] = {
+struct genl_filter_list {
+	struct list_head	 lp_list;
+	void			*lp_cursor;
+	bool			 lp_first;
+};
+
+static const struct nla_policy scalar_attr_policy[LN_SCALAR_MAX + 1] = {
 	[LN_SCALAR_ATTR_LIST]		= { .type = NLA_NESTED },
 	[LN_SCALAR_ATTR_LIST_SIZE]	= { .type = NLA_U16 },
 	[LN_SCALAR_ATTR_INDEX]		= { .type = NLA_U16 },
diff --git a/include/uapi/linux/lnet/lnet-nl.h b/include/uapi/linux/lnet/lnet-nl.h
index f5bb67c..83f6e27 100644
--- a/include/uapi/linux/lnet/lnet-nl.h
+++ b/include/uapi/linux/lnet/lnet-nl.h
@@ -38,23 +38,44 @@ enum lnet_nl_key_format {
 	LNKF_SEQUENCE		= 4,
 };
 
+/**
+ * enum lnet_nl_scalar_attrs		- scalar LNet netlink attributes used
+ *					  to compose messages for sending or
+ *					  receiving.
+ *
+ * @LN_SCALAR_ATTR_UNSPEC:		unspecified attribute to catch errors
+ * @LN_SCALAR_ATTR_PAD:			padding for 64-bit attributes, ignore
+ *
+ * @LN_SCALAR_ATTR_LIST:		List of scalar attributes (NLA_NESTED)
+ * @LN_SCALAR_ATTR_LIST_SIZE:		Number of items in scalar list (NLA_U16)
+ * @LN_SCALAR_ATTR_INDEX:		True Netlink attr value (NLA_U16)
+ * @LN_SCALAR_ATTR_NLA_TYPE:		Data format for value part of the pair
+ *					(NLA_U16)
+ * @LN_SCALAR_ATTR_VALUE:		String value of key part of the pair.
+ *					(NLA_NUL_STRING)
+ * @LN_SCALAR_ATTR_INT_VALUE:		Numeric value of key part of the pair.
+ *					(NLA_S64)
+ * @LN_SCALAR_ATTR_KEY_FORMAT:		LNKF_* format of the key value pair.
+ */
 enum lnet_nl_scalar_attrs {
 	LN_SCALAR_ATTR_UNSPEC = 0,
-	LN_SCALAR_ATTR_LIST,
+	LN_SCALAR_ATTR_PAD = LN_SCALAR_ATTR_UNSPEC,
 
+	LN_SCALAR_ATTR_LIST,
 	LN_SCALAR_ATTR_LIST_SIZE,
 	LN_SCALAR_ATTR_INDEX,
 	LN_SCALAR_ATTR_NLA_TYPE,
 	LN_SCALAR_ATTR_VALUE,
+	LN_SCALAR_ATTR_INT_VALUE,
 	LN_SCALAR_ATTR_KEY_FORMAT,
 
-	__LN_SCALAR_ATTR_LAST,
+	__LN_SCALAR_ATTR_MAX_PLUS_ONE,
 };
 
-#define LN_SCALAR_CNT (__LN_SCALAR_ATTR_LAST - 1)
+#define LN_SCALAR_MAX (__LN_SCALAR_ATTR_MAX_PLUS_ONE - 1)
 
 struct ln_key_props {
-	char			*lkp_values;
+	char			*lkp_value;
 	__u16			lkp_key_format;
 	__u16			lkp_data_type;
 };
diff --git a/net/lnet/lnet/api-ni.c b/net/lnet/lnet/api-ni.c
index 9d9d0e6..3ed3f0b 100644
--- a/net/lnet/lnet/api-ni.c
+++ b/net/lnet/lnet/api-ni.c
@@ -2670,9 +2670,9 @@ static int lnet_genl_parse_list(struct sk_buff *msg,
 				    list->lkl_maxattr);
 
 		nla_put_u16(msg, LN_SCALAR_ATTR_INDEX, count);
-		if (props[count].lkp_values)
+		if (props[count].lkp_value)
 			nla_put_string(msg, LN_SCALAR_ATTR_VALUE,
-				       props[count].lkp_values);
+				       props[count].lkp_value);
 		if (props[count].lkp_key_format)
 			nla_put_u16(msg, LN_SCALAR_ATTR_KEY_FORMAT,
 				    props[count].lkp_key_format);
@@ -2684,13 +2684,14 @@ static int lnet_genl_parse_list(struct sk_buff *msg,
 			rc = lnet_genl_parse_list(msg, data, ++idx);
 			if (rc < 0)
 				return rc;
+			idx = rc;
 		}
 
 		nla_nest_end(msg, key);
 	}
 
 	nla_nest_end(msg, node);
-	return 0;
+	return idx;
 }
 
 int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
@@ -2717,7 +2718,7 @@ int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
 canceled:
 	if (rc < 0)
 		genlmsg_cancel(msg, hdr);
-	return rc;
+	return rc > 0 ? 0 : rc;
 }
 EXPORT_SYMBOL(lnet_genl_send_scalar_list);
 
-- 
1.8.3.1

_______________________________________________
lustre-devel mailing list
lustre-devel@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

  parent reply	other threads:[~2021-11-28 23:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-28 23:27 [lustre-devel] [PATCH 00/19] lustre: update to OpenSFS tree Nov 28, 2021 James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 01/19] lnet: fix delay rule crash James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 02/19] lnet: change tp_nid to 16byte in lnet_test_peer James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 03/19] lnet: extend preferred nids in struct lnet_peer_ni James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 04/19] lnet: switch to large lnet_processid for matching James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 05/19] lnet: libcfs: add timeout to cfs_race() to fix race James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 06/19] lustre: llite: tighten condition for fault not drop mmap_sem James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 07/19] lnet: o2iblnd: map_on_demand not needed for frag interop James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 08/19] lnet: o2iblnd: Fix logic for unaligned transfer James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 09/19] lnet: Reset ni_ping_count only on receive James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 10/19] lustre: ptlrpc: fix timeout after spurious wakeup James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 11/19] lnet: Fail peer add for existing gw peer James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 12/19] lustre: ptlrpc: remove bogus LASSERT James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 13/19] lustre: quota: optimize capability check for root squash James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 14/19] lustre: llite: skip request slot for lmv_revalidate_slaves() James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 15/19] lnet: set eth routes needed for multi rail James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 16/19] lustre: llite: Do not count tiny write twice James Simmons
2021-11-28 23:27 ` [lustre-devel] [PATCH 17/19] lustre: llite: mend the trunc_sem_up_write() James Simmons
2021-11-28 23:27 ` James Simmons [this message]
2021-11-28 23:27 ` [lustre-devel] [PATCH 19/19] lnet: libcfs: separate daemon_list from cfs_trace_data James Simmons

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=1638142074-5945-19-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=adilger@whamcloud.com \
    --cc=green@whamcloud.com \
    --cc=lustre-devel@lists.lustre.org \
    --cc=neilb@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).