netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/ncsi: add control packet payload to NC-SI commands from netlink
@ 2019-08-19  4:33 Ben Wei
  2019-08-19 20:17 ` Justin.Lee1
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Wei @ 2019-08-19  4:33 UTC (permalink / raw)
  To: Ben Wei
  Cc: openbmc, Samuel Mendoza-Jonas, David S. Miller, netdev,
	linux-kernel, Ben Wei

This patch adds support for NCSI_CMD_SEND_CMD netlink command to load packet data payload (up to 16 bytes) to standard NC-SI commands.

Packet data will be loaded from NCSI_ATTR_DATA attribute similar to NC-SI OEM commands

Signed-off-by: Ben Wei <benwei@fb.com>
---
 net/ncsi/internal.h     | 7 ++++---
 net/ncsi/ncsi-netlink.c | 9 +++++++++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index 0b3f0673e1a2..4ff442faf5dc 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -328,9 +328,10 @@ struct ncsi_cmd_arg {
 	unsigned short       payload;     /* Command packet payload length */
 	unsigned int         req_flags;   /* NCSI request properties       */
 	union {
-		unsigned char  bytes[16]; /* Command packet specific data  */
-		unsigned short words[8];
-		unsigned int   dwords[4];
+#define NCSI_MAX_DATA_BYTES 16
+		unsigned char  bytes[NCSI_MAX_DATA_BYTES]; /* Command packet specific data  */
+		unsigned short words[NCSI_MAX_DATA_BYTES / sizeof(unsigned short)];
+		unsigned int   dwords[NCSI_MAX_DATA_BYTES / sizeof(unsigned int)];
 	};
 	unsigned char        *data;       /* NCSI OEM data                 */
 	struct genl_info     *info;       /* Netlink information           */
diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c index 8b386d766e7d..7d2a43f30eb1 100644
--- a/net/ncsi/ncsi-netlink.c
+++ b/net/ncsi/ncsi-netlink.c
@@ -459,6 +459,15 @@ static int ncsi_send_cmd_nl(struct sk_buff *msg, struct genl_info *info)
 	nca.payload = ntohs(hdr->length);
 	nca.data = data + sizeof(*hdr);
 
+	if (nca.payload <= NCSI_MAX_DATA_BYTES) {
+		memcpy(nca.bytes, nca.data, nca.payload);
+	} else {
+		netdev_info(ndp->ndev.dev, "NCSI:payload size %u exceeds max %u\n",
+			    nca.payload, NCSI_MAX_DATA_BYTES);
+		ret = -EINVAL;
+		goto out_netlink;
+	}
+
 	ret = ncsi_xmit_cmd(&nca);
 out_netlink:
 	if (ret != 0) {
--
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-20 22:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19  4:33 [PATCH] net/ncsi: add control packet payload to NC-SI commands from netlink Ben Wei
2019-08-19 20:17 ` Justin.Lee1
2019-08-19 20:56   ` Ben Wei
2019-08-20 16:29     ` Justin.Lee1
2019-08-20 22:26       ` Ben Wei

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).