lkml.org 
[lkml]   [2019]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] net/ncsi: add control packet payload to NC-SI commands from netlink
Date
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
\
 
 \ /
  Last update: 2019-08-19 06:35    [W:0.118 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site