* [PATCH v4 iproute2 3/7] rdma: Add link object
From: Leon Romanovsky @ 2017-08-15 13:00 UTC (permalink / raw)
To: Doug Ledford, Stephen Hemminger
Cc: linux-rdma, Leon Romanovsky, Dennis Dalessandro, Jason Gunthorpe,
Jiri Pirko, Ariel Almog, Linux Netdev
In-Reply-To: <20170815130020.29509-1-leonro@mellanox.com>
Link (port) object represent struct ib_port to the user space.
Link properties:
* Port capabilities
* IB subnet prefix
* LID, SM_LID and LMC
* Port state
* Physical state
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
rdma/Makefile | 2 +-
rdma/link.c | 274 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rdma/rdma.c | 3 +-
rdma/utils.c | 5 ++
4 files changed, 282 insertions(+), 2 deletions(-)
create mode 100644 rdma/link.c
diff --git a/rdma/Makefile b/rdma/Makefile
index 123d7ac5..1a9e4b1a 100644
--- a/rdma/Makefile
+++ b/rdma/Makefile
@@ -2,7 +2,7 @@ include ../Config
ifeq ($(HAVE_MNL),y)
-RDMA_OBJ = rdma.o utils.o dev.o
+RDMA_OBJ = rdma.o utils.o dev.o link.o
TARGETS=rdma
CFLAGS += $(shell $(PKG_CONFIG) libmnl --cflags)
diff --git a/rdma/link.c b/rdma/link.c
new file mode 100644
index 00000000..51858965
--- /dev/null
+++ b/rdma/link.c
@@ -0,0 +1,274 @@
+/*
+ * link.c RDMA tool
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Leon Romanovsky <leonro@mellanox.com>
+ */
+
+#include "rdma.h"
+
+static int link_help(struct rd *rd)
+{
+ pr_out("Usage: %s link show [DEV/PORT_INDEX]\n", rd->filename);
+ return 0;
+}
+
+static const char *caps_to_str(uint32_t idx)
+{
+ uint64_t cap = 1 << idx;
+
+ switch (cap) {
+ case RDMA_PORT_SM: return "SM";
+ case RDMA_PORT_NOTICE: return "NOTICE";
+ case RDMA_PORT_TRAP: return "TRAP";
+ case RDMA_PORT_OPT_IPD: return "OPT_IPD";
+ case RDMA_PORT_AUTO_MIGR: return "AUTO_MIG";
+ case RDMA_PORT_SL_MAP: return "SL_MAP";
+ case RDMA_PORT_MKEY_NVRAM: return "MKEY_NVRAM";
+ case RDMA_PORT_PKEY_NVRAM: return "PKEY_NVRAM";
+ case RDMA_PORT_LED_INFO: return "LED_INFO";
+ case RDMA_PORT_SM_DISABLED: return "SM_DISABLED";
+ case RDMA_PORT_SYS_IMAGE_GUID: return "SYS_IMAGE_GUID";
+ case RDMA_PORT_PKEY_SW_EXT_PORT_TRAP: return "PKEY_SW_EXT_PORT_TRAP";
+ case RDMA_PORT_EXTENDED_SPEEDS: return "EXTENDED_SPEEDS";
+ case RDMA_PORT_CM: return "CM";
+ case RDMA_PORT_SNMP_TUNNEL: return "SNMP_TUNNEL";
+ case RDMA_PORT_REINIT: return "REINIT";
+ case RDMA_PORT_DEVICE_MGMT: return "DEVICE_MGMT";
+ case RDMA_PORT_VENDOR_CLASS: return "VENDOR_CLASS";
+ case RDMA_PORT_DR_NOTICE: return "PORT_DR_NOTICE";
+ case RDMA_PORT_CAP_MASK_NOTICE: return "CAP_MASK_NOTICE";
+ case RDMA_PORT_BOOT_MGMT: return "BOOT_MGMT";
+ case RDMA_PORT_LINK_LATENCY: return "LINK_LATENCY";
+ case RDMA_PORT_CLIENT_REG: return "CLIENT_REG";
+ case RDMA_PORT_IP_BASED_GIDS: return "IP_BASED_GIDS";
+ default: return "UKNOWN";
+ }
+};
+
+static void link_print_caps(struct nlattr **tb)
+{
+ uint64_t caps;
+ uint32_t idx;
+
+ if (!tb[RDMA_NLDEV_ATTR_CAP_FLAGS])
+ return;
+
+ caps = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_CAP_FLAGS]);
+
+ pr_out("\n caps: <");
+ for (idx = 0; caps; idx++) {
+ if (caps & 0x1) {
+ pr_out("%s", caps_to_str(idx));
+ if (caps >> 0x1)
+ pr_out(", ");
+ }
+ caps >>= 0x1;
+ }
+
+ pr_out(">");
+}
+
+static void link_print_subnet_prefix(struct nlattr **tb)
+{
+ uint64_t subnet_prefix;
+
+ if (!tb[RDMA_NLDEV_ATTR_SUBNET_PREFIX])
+ return;
+
+ subnet_prefix = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_SUBNET_PREFIX]);
+ rd_print_u64("subnet_prefix", subnet_prefix);
+}
+
+static void link_print_lid(struct nlattr **tb)
+{
+ if (!tb[RDMA_NLDEV_ATTR_LID])
+ return;
+
+ pr_out("lid %u ",
+ mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_LID]));
+}
+
+static void link_print_sm_lid(struct nlattr **tb)
+{
+ if (!tb[RDMA_NLDEV_ATTR_SM_LID])
+ return;
+
+ pr_out("sm_lid %u ",
+ mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_SM_LID]));
+}
+
+static void link_print_lmc(struct nlattr **tb)
+{
+ if (!tb[RDMA_NLDEV_ATTR_LMC])
+ return;
+
+ pr_out("lmc %u ", mnl_attr_get_u8(tb[RDMA_NLDEV_ATTR_LMC]));
+}
+
+static const char *link_state_to_str(uint8_t link_state)
+{
+ switch (link_state) {
+ case RDMA_LINK_STATE_NOP: return "NOP";
+ case RDMA_LINK_STATE_DOWN: return "DOWN";
+ case RDMA_LINK_STATE_INIT: return "INIT";
+ case RDMA_LINK_STATE_ARMED: return "ARMED";
+ case RDMA_LINK_STATE_ACTIVE: return "ACTIVE";
+ case RDMA_LINK_STATE_ACTIVE_DEFER: return "ACTIVE_DEFER";
+ default: return "UKNOWN";
+ }
+};
+
+static void link_print_state(struct nlattr **tb)
+{
+ uint8_t state;
+
+ if (!tb[RDMA_NLDEV_ATTR_PORT_STATE])
+ return;
+
+ state = mnl_attr_get_u8(tb[RDMA_NLDEV_ATTR_PORT_STATE]);
+ pr_out("state %s ", link_state_to_str(state));
+}
+
+static const char *phys_state_to_str(uint8_t phys_state)
+{
+ switch (phys_state) {
+ case RDMA_LINK_PHYS_STATE_SLEEP: return "SLEEP";
+ case RDMA_LINK_PHYS_STATE_POLLING: return "POLLING";
+ case RDMA_LINK_PHYS_STATE_DISABLED: return "DISABLED";
+ case RDMA_LINK_PHYS_STATE_PORT_CONFIGURATION_TRAINING: return "ARMED";
+ case RDMA_LINK_PHYS_STATE_LINK_UP: return "LINK_UP";
+ case RDMA_LINK_PHYS_STATE_LINK_ERROR_RECOVER:
+ return "LINK_ERROR_RECOVER";
+ case RDMA_LINK_PHYS_STATE_LINK_PHY_TEST: return "PHY_TEST";
+ default: return "UKNOWN";
+ }
+};
+
+static void link_print_phys_state(struct nlattr **tb)
+{
+ uint8_t phys_state;
+
+ if (!tb[RDMA_NLDEV_ATTR_PORT_PHYS_STATE])
+ return;
+
+ phys_state = mnl_attr_get_u8(tb[RDMA_NLDEV_ATTR_PORT_PHYS_STATE]);
+ pr_out("physical_state %s ", phys_state_to_str(phys_state));
+}
+
+static int link_parse_cb(const struct nlmsghdr *nlh, void *data)
+{
+ struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {};
+ struct rd *rd = data;
+
+ mnl_attr_parse(nlh, 0, rd_attr_cb, tb);
+ if (!tb[RDMA_NLDEV_ATTR_DEV_INDEX] || !tb[RDMA_NLDEV_ATTR_DEV_NAME])
+ return MNL_CB_ERROR;
+
+ if (!tb[RDMA_NLDEV_ATTR_PORT_INDEX]) {
+ pr_err("This tool doesn't support switches yet\n");
+ return MNL_CB_ERROR;
+ }
+
+ pr_out("%u/%u: %s/%u: ",
+ mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]),
+ mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]),
+ mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_DEV_NAME]),
+ mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]));
+ link_print_subnet_prefix(tb);
+ link_print_lid(tb);
+ link_print_sm_lid(tb);
+ link_print_lmc(tb);
+ link_print_state(tb);
+ link_print_phys_state(tb);
+ if (rd->show_details)
+ link_print_caps(tb);
+
+ pr_out("\n");
+ return MNL_CB_OK;
+}
+
+static int link_no_args(struct rd *rd)
+{
+ uint32_t seq;
+ int ret;
+
+ rd_prepare_msg(rd, RDMA_NLDEV_CMD_PORT_GET, &seq,
+ (NLM_F_REQUEST | NLM_F_ACK));
+ mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx);
+ mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_PORT_INDEX, rd->port_idx);
+ ret = rd_send_msg(rd);
+ if (ret)
+ return ret;
+
+ return rd_recv_msg(rd, link_parse_cb, rd, seq);
+}
+
+static int link_one_show(struct rd *rd)
+{
+ const struct rd_cmd cmds[] = {
+ { NULL, link_no_args},
+ { 0 }
+ };
+
+ return rd_exec_cmd(rd, cmds, "parameter");
+}
+
+static int link_show(struct rd *rd)
+{
+ struct dev_map *dev_map;
+ uint32_t port;
+ int ret;
+
+ if (rd_no_arg(rd)) {
+ list_for_each_entry(dev_map, &rd->dev_map_list, list) {
+ rd->dev_idx = dev_map->idx;
+ for (port = 1; port < dev_map->num_ports + 1; port++) {
+ rd->port_idx = port;
+ ret = link_one_show(rd);
+ if (ret)
+ return ret;
+ }
+ }
+
+ } else {
+ dev_map = dev_map_lookup(rd, true);
+ port = get_port_from_argv(rd);
+ if (!dev_map || port > dev_map->num_ports) {
+ pr_err("Wrong device name\n");
+ return -ENOENT;
+ }
+ rd_arg_inc(rd);
+ rd->dev_idx = dev_map->idx;
+ rd->port_idx = port ? : 1;
+ for (; rd->port_idx < dev_map->num_ports + 1; rd->port_idx++) {
+ ret = link_one_show(rd);
+ if (ret)
+ return ret;
+ if (port)
+ /*
+ * We got request to show link for devname
+ * with port index.
+ */
+ break;
+ }
+ }
+ return 0;
+}
+
+int cmd_link(struct rd *rd)
+{
+ const struct rd_cmd cmds[] = {
+ { NULL, link_show },
+ { "show", link_show },
+ { "list", link_show },
+ { "help", link_help },
+ { 0 }
+ };
+
+ return rd_exec_cmd(rd, cmds, "link command");
+}
diff --git a/rdma/rdma.c b/rdma/rdma.c
index 9c2bdc8f..74c09e8b 100644
--- a/rdma/rdma.c
+++ b/rdma/rdma.c
@@ -15,7 +15,7 @@
static void help(char *name)
{
pr_out("Usage: %s [ OPTIONS ] OBJECT { COMMAND | help }\n"
- "where OBJECT := { dev | help }\n"
+ "where OBJECT := { dev | link | help }\n"
" OPTIONS := { -V[ersion] | -d[etails]}\n", name);
}
@@ -31,6 +31,7 @@ static int rd_cmd(struct rd *rd)
{ NULL, cmd_help },
{ "help", cmd_help },
{ "dev", cmd_dev },
+ { "link", cmd_link },
{ 0 }
};
diff --git a/rdma/utils.c b/rdma/utils.c
index 0e32eefe..91d05271 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -107,6 +107,11 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
[RDMA_NLDEV_ATTR_FW_VERSION] = MNL_TYPE_NUL_STRING,
[RDMA_NLDEV_ATTR_NODE_GUID] = MNL_TYPE_U64,
[RDMA_NLDEV_ATTR_SYS_IMAGE_GUID] = MNL_TYPE_U64,
+ [RDMA_NLDEV_ATTR_LID] = MNL_TYPE_U32,
+ [RDMA_NLDEV_ATTR_SM_LID] = MNL_TYPE_U32,
+ [RDMA_NLDEV_ATTR_LMC] = MNL_TYPE_U8,
+ [RDMA_NLDEV_ATTR_PORT_STATE] = MNL_TYPE_U8,
+ [RDMA_NLDEV_ATTR_PORT_PHYS_STATE] = MNL_TYPE_U8,
[RDMA_NLDEV_ATTR_DEV_NODE_TYPE] = MNL_TYPE_U8,
};
--
2.14.0
^ permalink raw reply related
* Re: [iproute PATCH 51/51] lib/bpf: Check return value of write()
From: Daniel Borkmann @ 2017-08-15 13:00 UTC (permalink / raw)
To: David Laight, 'Phil Sutter', Stephen Hemminger
Cc: netdev@vger.kernel.org
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DD0055BA8@AcuExch.aculab.com>
On 08/15/2017 02:31 PM, David Laight wrote:
[...]
> WTF is this code doing anyway?
> write() is a system call, fflush() writes out any data buffered in the
> stdio stream.
> If there was anything buffered you'd want to output it earlier.
> Otherwise if it is going to use fflush() it should be using fwrite().
>
> I presume the function is allowed to write to stderr - since in general
> library functions shouldn't assume fd 0/1/2 or stdin/out/err are valid.
> There is a lot of code out there that does close(0); close(1); close(2);
> but leaves stdout/err valid. Call printf() instead of sprint() and eventually
> 10k of data gets written somewhere rather unexpected.
>
> If it is a copy loop, what is wrong with the last byte of buff[].
> It is valid for write() to return a partial length - the code should
> probably loop until all the data is accepted (or error).
Just send a patch if you really care; would have probably been faster
than typing up your email. ;) Thank you!
^ permalink raw reply
* [PATCH v4 iproute2 4/7] rdma: Add initial manual for the tool
From: Leon Romanovsky @ 2017-08-15 13:00 UTC (permalink / raw)
To: Doug Ledford, Stephen Hemminger
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky,
Dennis Dalessandro, Jason Gunthorpe, Jiri Pirko, Ariel Almog,
Linux Netdev
In-Reply-To: <20170815130020.29509-1-leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Signed-off-by: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
man/man8/rdma-dev.8 | 55 +++++++++++++++++++++++++++
man/man8/rdma-link.8 | 55 +++++++++++++++++++++++++++
man/man8/rdma.8 | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 212 insertions(+)
create mode 100644 man/man8/rdma-dev.8
create mode 100644 man/man8/rdma-link.8
create mode 100644 man/man8/rdma.8
diff --git a/man/man8/rdma-dev.8 b/man/man8/rdma-dev.8
new file mode 100644
index 00000000..461681b6
--- /dev/null
+++ b/man/man8/rdma-dev.8
@@ -0,0 +1,55 @@
+.TH RDMA\-DEV 8 "06 Jul 2017" "iproute2" "Linux"
+.SH NAME
+rdmak-dev \- RDMA device configuration
+.SH SYNOPSIS
+.sp
+.ad l
+.in +8
+.ti -8
+.B rdma
+.RI "[ " OPTIONS " ]"
+.B dev
+.RI " { " COMMAND " | "
+.BR help " }"
+.sp
+
+.ti -8
+.IR OPTIONS " := { "
+\fB\-V\fR[\fIersion\fR] |
+\fB\-d\fR[\fIetails\fR] }
+
+.ti -8
+.B rdma dev show
+.RI "[ " DEV " ]"
+
+.ti -8
+.B rdma dev help
+
+.SH "DESCRIPTION"
+.SS rdma dev show - display rdma device attributes
+
+.PP
+.I "DEV"
+- specifies the RDMA device to show.
+If this argument is omitted all devices are listed.
+
+.SH "EXAMPLES"
+.PP
+rdma dev
+.RS 4
+Shows the state of all RDMA devices on the system.
+.RE
+.PP
+rdma dev show mlx5_3
+.RS 4
+Shows the state of specified RDMA device.
+.RE
+.PP
+
+.SH SEE ALSO
+.BR rdma (8),
+.BR rdma-link (8),
+.br
+
+.SH AUTHOR
+Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
diff --git a/man/man8/rdma-link.8 b/man/man8/rdma-link.8
new file mode 100644
index 00000000..8ed049ef
--- /dev/null
+++ b/man/man8/rdma-link.8
@@ -0,0 +1,55 @@
+.TH RDMA\-LINK 8 "06 Jul 2017" "iproute2" "Linux"
+.SH NAME
+rdma-link \- rdma link configuration
+.SH SYNOPSIS
+.sp
+.ad l
+.in +8
+.ti -8
+.B devlink
+.RI "[ " OPTIONS " ]"
+.B link
+.RI " { " COMMAND " | "
+.BR help " }"
+.sp
+
+.ti -8
+.IR OPTIONS " := { "
+\fB\-V\fR[\fIersion\fR] |
+\fB\-d\fR[\fIetails\fR] }
+
+.ti -8
+.B rdma link show
+.RI "[ " DEV/PORT_INDEX " ]"
+
+.ti -8
+.B rdma link help
+
+.SH "DESCRIPTION"
+.SS rdma link show - display rdma link attributes
+
+.PP
+.I "DEV/PORT_INDEX"
+- specifies the RDMa link to show.
+If this argument is omitted all links are listed.
+
+.SH "EXAMPLES"
+.PP
+rdma link show
+.RS 4
+Shows the state of all rdma links on the system.
+.RE
+.PP
+rdma link show mlx5_2/1
+.RS 4
+Shows the state of specified rdma link.
+.RE
+.PP
+
+.SH SEE ALSO
+.BR rdma (8),
+.BR rdma-dev (8),
+.br
+
+.SH AUTHOR
+Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
diff --git a/man/man8/rdma.8 b/man/man8/rdma.8
new file mode 100644
index 00000000..798b33d3
--- /dev/null
+++ b/man/man8/rdma.8
@@ -0,0 +1,102 @@
+.TH RDMA 8 "28 Mar 2017" "iproute2" "Linux"
+.SH NAME
+rdma \- RDMA tool
+.SH SYNOPSIS
+.sp
+.ad l
+.in +8
+.ti -8
+.B rdma
+.RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
+.BR help " }"
+.sp
+
+.ti -8
+.IR OBJECT " := { "
+.BR dev " | " link " }"
+.sp
+
+.ti -8
+.IR OPTIONS " := { "
+\fB\-V\fR[\fIersion\fR] |
+\fB\-d\fR[\fIetails\fR] }
+\fB\-j\fR[\fIson\fR] }
+\fB\-p\fR[\fIretty\fR] }
+
+.SH OPTIONS
+
+.TP
+.BR "\-V" , " -Version"
+Print the version of the
+.B rdma
+tool and exit.
+
+.TP
+.BR "\-d" , " --details"
+Otuput detailed information.
+
+.TP
+.BR "\-p" , " --pretty"
+When combined with -j generate a pretty JSON output.
+
+.TP
+.BR "\-j" , " --json"
+Generate JSON output.
+
+.SS
+.I OBJECT
+
+.TP
+.B dev
+- RDMA device.
+
+.TP
+.B link
+- RDMA port related.
+
+.PP
+The names of all objects may be written in full or
+abbreviated form, for example
+.B stats
+can be abbreviated as
+.B stat
+or just
+.B s.
+
+.SS
+.I COMMAND
+
+Specifies the action to perform on the object.
+The set of possible actions depends on the object type.
+As a rule, it is possible to
+.B show
+(or
+.B list
+) objects, but some objects do not allow all of these operations
+or have some additional commands. The
+.B help
+command is available for all objects. It prints
+out a list of available commands and argument syntax conventions.
+.sp
+If no command is given, some default command is assumed.
+Usually it is
+.B list
+or, if the objects of this class cannot be listed,
+.BR "help" .
+
+.SH EXIT STATUS
+Exit status is 0 if command was successful or a positive integer upon failure.
+
+.SH SEE ALSO
+.BR rdma-dev (8),
+.BR rdma-link (8),
+.br
+
+.SH REPORTING BUGS
+Report any bugs to the Linux RDMA mailing list
+.B <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
+where the development and maintenance is primarily done.
+You do not have to be subscribed to the list to send a message there.
+
+.SH AUTHOR
+Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
--
2.14.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v4 iproute2 2/7] rdma: Add dev object
From: Leon Romanovsky @ 2017-08-15 13:00 UTC (permalink / raw)
To: Doug Ledford, Stephen Hemminger
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky,
Dennis Dalessandro, Jason Gunthorpe, Jiri Pirko, Ariel Almog,
Linux Netdev
In-Reply-To: <20170815130020.29509-1-leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Device (dev) object represents struct ib_device to the user space.
Device properties:
* Device capabilities
* FW version to the device output
* node_guid and sys_image_guid
* node_type
Signed-off-by: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
rdma/Makefile | 2 +-
rdma/dev.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rdma/rdma.c | 3 +-
rdma/rdma.h | 13 ++++
rdma/utils.c | 54 +++++++++++++-
5 files changed, 296 insertions(+), 3 deletions(-)
create mode 100644 rdma/dev.c
diff --git a/rdma/Makefile b/rdma/Makefile
index 64da2142..123d7ac5 100644
--- a/rdma/Makefile
+++ b/rdma/Makefile
@@ -2,7 +2,7 @@ include ../Config
ifeq ($(HAVE_MNL),y)
-RDMA_OBJ = rdma.o utils.o
+RDMA_OBJ = rdma.o utils.o dev.o
TARGETS=rdma
CFLAGS += $(shell $(PKG_CONFIG) libmnl --cflags)
diff --git a/rdma/dev.c b/rdma/dev.c
new file mode 100644
index 00000000..e984f805
--- /dev/null
+++ b/rdma/dev.c
@@ -0,0 +1,227 @@
+/*
+ * dev.c RDMA tool
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
+ */
+
+#include "rdma.h"
+
+static int dev_help(struct rd *rd)
+{
+ pr_out("Usage: %s dev show [DEV]\n", rd->filename);
+ return 0;
+}
+
+static const char *dev_caps_to_str(uint32_t idx)
+{
+ uint64_t cap = 1 << idx;
+
+ switch (cap) {
+ case RDMA_DEV_RESIZE_MAX_WR: return "RESIZE_MAX_WR";
+ case RDMA_DEV_BAD_PKEY_CNTR: return "BAD_PKEY_CNTR";
+ case RDMA_DEV_BAD_QKEY_CNTR: return "BAD_QKEY_CNTR";
+ case RDMA_DEV_RAW_MULTI: return "RAW_MULTI";
+ case RDMA_DEV_AUTO_PATH_MIG: return "AUTO_PATH_MIG";
+ case RDMA_DEV_CHANGE_PHY_PORT: return "CHANGE_PHY_POR";
+ case RDMA_DEV_UD_AV_PORT_ENFORCE: return "UD_AV_PORT_ENFORCE";
+ case RDMA_DEV_CURR_QP_STATE_MOD: return "CURR_QP_STATE_MOD";
+ case RDMA_DEV_SHUTDOWN_PORT: return "SHUTDOWN_PORT";
+ case RDMA_DEV_INIT_TYPE: return "INIT_TYPE";
+ case RDMA_DEV_PORT_ACTIVE_EVENT: return "PORT_ACTIVE_EVENT";
+ case RDMA_DEV_SYS_IMAGE_GUID: return "SYS_IMAGE_GUID";
+ case RDMA_DEV_RC_RNR_NAK_GEN: return "RC_RNR_NAK_GEN";
+ case RDMA_DEV_SRQ_RESIZE: return "SRQ_RESIZE";
+ case RDMA_DEV_N_NOTIFY_CQ: return "N_NOTIFY_CQ";
+ case RDMA_DEV_LOCAL_DMA_LKEY: return "LOCAL_DMA_LKEY";
+ case RDMA_DEV_MEM_WINDOW: return "MEM_WINDOW";
+ case RDMA_DEV_UD_IP_CSUM: return "UD_IP_CSUM";
+ case RDMA_DEV_UD_TSO: return "UD_TSO";
+ case RDMA_DEV_XRC: return "XRC";
+ case RDMA_DEV_MEM_MGT_EXTENSIONS: return "MEM_MGT_EXTENSIONS";
+ case RDMA_DEV_BLOCK_MULTICAST_LOOPBACK:
+ return "BLOCK_MULTICAST_LOOPBACK";
+ case RDMA_DEV_MEM_WINDOW_TYPE_2A: return "MEM_WINDOW_TYPE_2A";
+ case RDMA_DEV_MEM_WINDOW_TYPE_2B: return "MEM_WINDOW_TYPE_2B";
+ case RDMA_DEV_RC_IP_CSUM: return "RC_IP_CSUM";
+ case RDMA_DEV_RAW_IP_CSUM: return "RAW_IP_CSUM";
+ case RDMA_DEV_CROSS_CHANNEL: return "CROSS_CHANNEL";
+ case RDMA_DEV_MANAGED_FLOW_STEERING: return "MANAGED_FLOW_STEERING";
+ case RDMA_DEV_SIGNATURE_HANDOVER: return "SIGNATURE_HANDOVER";
+ case RDMA_DEV_ON_DEMAND_PAGING: return "ON_DEMAND_PAGING";
+ case RDMA_DEV_SG_GAPS_REG: return "SG_GAPS_REG";
+ case RDMA_DEV_VIRTUAL_FUNCTION: return "VIRTUAL_FUNCTION";
+ case RDMA_DEV_RAW_SCATTER_FCS: return "RAW_SCATTER_FCS";
+ case RDMA_DEV_RDMA_NETDEV_OPA_VNIC: return "RDMA_NETDEV_OPA_VNIC";
+ default: return "UNKNOWN";
+ }
+}
+
+static void dev_print_caps(struct nlattr **tb)
+{
+ uint64_t caps;
+ uint32_t idx;
+
+ if (!tb[RDMA_NLDEV_ATTR_CAP_FLAGS])
+ return;
+
+ caps = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_CAP_FLAGS]);
+
+ pr_out("\n caps: <");
+ for (idx = 0; caps; idx++) {
+ if (caps & 0x1) {
+ pr_out("%s", dev_caps_to_str(idx));
+ if (caps >> 0x1)
+ pr_out(", ");
+ }
+ caps >>= 0x1;
+ }
+
+ pr_out(">");
+}
+
+static void dev_print_fw(struct nlattr **tb)
+{
+ if (!tb[RDMA_NLDEV_ATTR_FW_VERSION])
+ return;
+
+ pr_out("fw %s ",
+ mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_FW_VERSION]));
+}
+
+static void dev_print_node_guid(struct nlattr **tb)
+{
+ uint64_t node_guid;
+
+ if (!tb[RDMA_NLDEV_ATTR_NODE_GUID])
+ return;
+
+ node_guid = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_NODE_GUID]);
+ rd_print_u64("node_guid", node_guid);
+}
+
+static void dev_print_sys_image_guid(struct nlattr **tb)
+{
+ uint64_t sys_image_guid;
+
+ if (!tb[RDMA_NLDEV_ATTR_SYS_IMAGE_GUID])
+ return;
+
+ sys_image_guid = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_SYS_IMAGE_GUID]);
+ rd_print_u64("sys_image_guid", sys_image_guid);
+}
+
+static const char *node_type_to_str(uint8_t node_type)
+{
+ switch (node_type) {
+ case RDMA_NODE_IB_CA: return "ca";
+ case RDMA_NODE_IB_SWITCH: return "switch";
+ case RDMA_NODE_IB_ROUTER: return "router";
+ case RDMA_NODE_RNIC: return "rnic";
+ case RDMA_NODE_USNIC: return "usnic";
+ case RDMA_NODE_USNIC_UDP: return "usnic_dp";
+ default: return "unknown";
+ }
+}
+
+static void dev_print_node_type(struct nlattr **tb)
+{
+ uint8_t node_type;
+
+ if (!tb[RDMA_NLDEV_ATTR_DEV_NODE_TYPE])
+ return;
+
+ node_type = mnl_attr_get_u8(tb[RDMA_NLDEV_ATTR_DEV_NODE_TYPE]);
+ pr_out("node_type %s ", node_type_to_str(node_type));
+}
+
+static int dev_parse_cb(const struct nlmsghdr *nlh, void *data)
+{
+ struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {};
+ struct rd *rd = data;
+
+ mnl_attr_parse(nlh, 0, rd_attr_cb, tb);
+ if (!tb[RDMA_NLDEV_ATTR_DEV_INDEX] || !tb[RDMA_NLDEV_ATTR_DEV_NAME])
+ return MNL_CB_ERROR;
+
+ pr_out("%u: %s: ",
+ mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]),
+ mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_DEV_NAME]));
+ dev_print_node_type(tb);
+ dev_print_fw(tb);
+ dev_print_node_guid(tb);
+ dev_print_sys_image_guid(tb);
+ if (rd->show_details)
+ dev_print_caps(tb);
+
+ pr_out("\n");
+ return MNL_CB_OK;
+}
+
+static int dev_no_args(struct rd *rd)
+{
+ uint32_t seq;
+ int ret;
+
+ rd_prepare_msg(rd, RDMA_NLDEV_CMD_GET,
+ &seq, (NLM_F_REQUEST | NLM_F_ACK));
+ mnl_attr_put_u32(rd->nlh, RDMA_NLDEV_ATTR_DEV_INDEX, rd->dev_idx);
+ ret = rd_send_msg(rd);
+ if (ret)
+ return ret;
+
+ return rd_recv_msg(rd, dev_parse_cb, rd, seq);
+}
+
+static int dev_one_show(struct rd *rd)
+{
+ const struct rd_cmd cmds[] = {
+ { NULL, dev_no_args},
+ { 0 }
+ };
+
+ return rd_exec_cmd(rd, cmds, "parameter");
+}
+
+static int dev_show(struct rd *rd)
+{
+ struct dev_map *dev_map;
+ int ret = 0;
+
+ if (rd_no_arg(rd)) {
+ list_for_each_entry(dev_map, &rd->dev_map_list, list) {
+ rd->dev_idx = dev_map->idx;
+ ret = dev_one_show(rd);
+ if (ret)
+ return ret;
+ }
+
+ } else {
+ dev_map = dev_map_lookup(rd, false);
+ if (!dev_map) {
+ pr_err("Wrong device name\n");
+ return -ENOENT;
+ }
+ rd_arg_inc(rd);
+ rd->dev_idx = dev_map->idx;
+ ret = dev_one_show(rd);
+ }
+ return ret;
+}
+
+int cmd_dev(struct rd *rd)
+{
+ const struct rd_cmd cmds[] = {
+ { NULL, dev_show },
+ { "show", dev_show },
+ { "list", dev_show },
+ { "help", dev_help },
+ { 0 }
+ };
+
+ return rd_exec_cmd(rd, cmds, "dev command");
+}
diff --git a/rdma/rdma.c b/rdma/rdma.c
index d850e396..9c2bdc8f 100644
--- a/rdma/rdma.c
+++ b/rdma/rdma.c
@@ -15,7 +15,7 @@
static void help(char *name)
{
pr_out("Usage: %s [ OPTIONS ] OBJECT { COMMAND | help }\n"
- "where OBJECT := { help }\n"
+ "where OBJECT := { dev | help }\n"
" OPTIONS := { -V[ersion] | -d[etails]}\n", name);
}
@@ -30,6 +30,7 @@ static int rd_cmd(struct rd *rd)
const struct rd_cmd cmds[] = {
{ NULL, cmd_help },
{ "help", cmd_help },
+ { "dev", cmd_dev },
{ 0 }
};
diff --git a/rdma/rdma.h b/rdma/rdma.h
index 361888b8..b9d75d29 100644
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -40,6 +40,8 @@ struct rd {
char *filename;
bool show_details;
struct list_head dev_map_list;
+ uint32_t dev_idx;
+ uint32_t port_idx;
struct mnl_socket *nl;
struct nlmsghdr *nlh;
char *buff;
@@ -56,12 +58,23 @@ struct rd_cmd {
bool rd_no_arg(struct rd *rd);
void rd_arg_inc(struct rd *rd);
+char *rd_argv(struct rd *rd);
+uint32_t get_port_from_argv(struct rd *rd);
+
+void rd_print_u64(char *name, uint64_t val);
+/*
+ * Commands interface
+ */
+int cmd_dev(struct rd *rd);
+int cmd_link(struct rd *rd);
int rd_exec_cmd(struct rd *rd, const struct rd_cmd *c, const char *str);
/*
* Device manipulation
*/
void rd_free_devmap(struct rd *rd);
+struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index);
+struct dev_map *_dev_map_lookup(struct rd *rd, const char *dev_name);
/*
* Netlink
diff --git a/rdma/utils.c b/rdma/utils.c
index 9bd7418f..0e32eefe 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -16,7 +16,7 @@ static int rd_argc(struct rd *rd)
return rd->argc;
}
-static char *rd_argv(struct rd *rd)
+char *rd_argv(struct rd *rd)
{
if (!rd_argc(rd))
return NULL;
@@ -50,6 +50,23 @@ bool rd_no_arg(struct rd *rd)
return rd_argc(rd) == 0;
}
+uint32_t get_port_from_argv(struct rd *rd)
+{
+ char *slash;
+
+ slash = strchr(rd_argv(rd), '/');
+ /* if no port found, return 0 */
+ return slash ? atoi(slash + 1) : 0;
+}
+
+void rd_print_u64(char *name, uint64_t val)
+{
+ uint16_t vp[4];
+
+ memcpy(vp, &val, sizeof(uint64_t));
+ pr_out("%s %04x:%04x:%04x:%04x ", name, vp[3], vp[2], vp[1], vp[0]);
+}
+
static struct dev_map *dev_map_alloc(const char *dev_name)
{
struct dev_map *dev_map;
@@ -83,8 +100,14 @@ static void dev_map_cleanup(struct rd *rd)
}
static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
+ [RDMA_NLDEV_ATTR_DEV_INDEX] = MNL_TYPE_U32,
[RDMA_NLDEV_ATTR_DEV_NAME] = MNL_TYPE_NUL_STRING,
[RDMA_NLDEV_ATTR_PORT_INDEX] = MNL_TYPE_U32,
+ [RDMA_NLDEV_ATTR_CAP_FLAGS] = MNL_TYPE_U64,
+ [RDMA_NLDEV_ATTR_FW_VERSION] = MNL_TYPE_NUL_STRING,
+ [RDMA_NLDEV_ATTR_NODE_GUID] = MNL_TYPE_U64,
+ [RDMA_NLDEV_ATTR_SYS_IMAGE_GUID] = MNL_TYPE_U64,
+ [RDMA_NLDEV_ATTR_DEV_NODE_TYPE] = MNL_TYPE_U8,
};
int rd_attr_cb(const struct nlattr *attr, void *data)
@@ -215,3 +238,32 @@ int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, unsigned int seq)
mnl_socket_close(rd->nl);
return ret;
}
+
+struct dev_map *_dev_map_lookup(struct rd *rd, const char *dev_name)
+{
+ struct dev_map *dev_map;
+
+ list_for_each_entry(dev_map, &rd->dev_map_list, list)
+ if (strcmp(dev_name, dev_map->dev_name) == 0)
+ return dev_map;
+
+ return NULL;
+}
+
+struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index)
+{
+ struct dev_map *dev_map;
+ char *dev_name;
+ char *slash;
+
+ dev_name = strdup(rd_argv(rd));
+ if (allow_port_index) {
+ slash = strrchr(dev_name, '/');
+ if (slash)
+ *slash = '\0';
+ }
+
+ dev_map = _dev_map_lookup(rd, dev_name);
+ free(dev_name);
+ return dev_map;
+}
--
2.14.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v4 iproute2 0/7] RDMAtool
From: Leon Romanovsky @ 2017-08-15 13:00 UTC (permalink / raw)
To: Doug Ledford, Stephen Hemminger
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Leon Romanovsky,
Dennis Dalessandro, Jason Gunthorpe, Jiri Pirko, Ariel Almog,
Linux Netdev
Hi,
This is fourth revision of series implementing the RDAMtool - the tool
to configure RDMA devices. The initial proposal was sent as RFC [1] and
was based on sysfs entries as POC.
The current series was rewritten completely to work with RDMA netlinks as
a source of user<->kernel communications. In order to achieve that, the
RDMA netlinks were extensively refactored and modernized [2, 3, 4 and 5].
The Doug's for-next tag includes most of the needed patches for this
tool and I posted to the ML the last batch [6] which exports various
device and port properties.
The following is an example of various runs on my machine with 5 devices
(4 in IB mode and one in Ethernet mode).
### Without parameters
$ rdma
Usage: rdma [ OPTIONS ] OBJECT { COMMAND | help }
where OBJECT := { dev | link | help }
OPTIONS := { -V[ersion] | -d[etails] | -j[son] | -p[retty]}
### With unspecified device name
$ rdma dev
1: mlx5_0: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:3457 sys_image_guid 5254:00c0:fe12:3457
2: mlx5_1: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:3458 sys_image_guid 5254:00c0:fe12:3458
3: mlx5_2: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:3459 sys_image_guid 5254:00c0:fe12:3459
4: mlx5_3: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:345a sys_image_guid 5254:00c0:fe12:345a
5: mlx5_4: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:345b sys_image_guid 5254:00c0:fe12:345b
### Detailed mode
$ rdma -d dev
1: mlx5_0: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:3457 sys_image_guid 5254:00c0:fe12:3457
caps: <BAD_PKEY_CNTR, BAD_QKEY_CNTR, CHANGE_PHY_POR, PORT_ACTIVE_EVENT, SYS_IMAGE_GUID, RC_RNR_NAK_GEN, MEM_WINDOW, UD_IP_CSUM, UD_TSO, XRC, MEM_MGT_EXTENSIONS, BLOCK_MULTICAST_LOOPBACK, MEM_WINDOW_TYPE_2B, RAW_IP_CSUM, MANAGED_FLOW_STEERING, RESIZE_MAX_WR>
2: mlx5_1: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:3458 sys_image_guid 5254:00c0:fe12:3458
caps: <BAD_PKEY_CNTR, BAD_QKEY_CNTR, CHANGE_PHY_POR, PORT_ACTIVE_EVENT, SYS_IMAGE_GUID, RC_RNR_NAK_GEN, MEM_WINDOW, UD_IP_CSUM, UD_TSO, XRC, MEM_MGT_EXTENSIONS, BLOCK_MULTICAST_LOOPBACK, MEM_WINDOW_TYPE_2B, RAW_IP_CSUM, MANAGED_FLOW_STEERING, RESIZE_MAX_WR>
3: mlx5_2: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:3459 sys_image_guid 5254:00c0:fe12:3459
caps: <BAD_PKEY_CNTR, BAD_QKEY_CNTR, CHANGE_PHY_POR, PORT_ACTIVE_EVENT, SYS_IMAGE_GUID, RC_RNR_NAK_GEN, MEM_WINDOW, UD_IP_CSUM, UD_TSO, XRC, MEM_MGT_EXTENSIONS, BLOCK_MULTICAST_LOOPBACK, MEM_WINDOW_TYPE_2B, RAW_IP_CSUM, MANAGED_FLOW_STEERING, RESIZE_MAX_WR>
4: mlx5_3: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:345a sys_image_guid 5254:00c0:fe12:345a
caps: <BAD_PKEY_CNTR, BAD_QKEY_CNTR, CHANGE_PHY_POR, PORT_ACTIVE_EVENT, SYS_IMAGE_GUID, RC_RNR_NAK_GEN, MEM_WINDOW, UD_IP_CSUM, UD_TSO, XRC, MEM_MGT_EXTENSIONS, BLOCK_MULTICAST_LOOPBACK, MEM_WINDOW_TYPE_2B, RAW_IP_CSUM, MANAGED_FLOW_STEERING, RESIZE_MAX_WR>
5: mlx5_4: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:345b sys_image_guid 5254:00c0:fe12:345b
caps: <BAD_PKEY_CNTR, BAD_QKEY_CNTR, CHANGE_PHY_POR, PORT_ACTIVE_EVENT, SYS_IMAGE_GUID, RC_RNR_NAK_GEN, MEM_WINDOW, UD_IP_CSUM, UD_TSO, XRC, MEM_MGT_EXTENSIONS, BLOCK_MULTICAST_LOOPBACK, MEM_WINDOW_TYPE_2B, RAW_IP_CSUM, MANAGED_FLOW_STEERING, RESIZE_MAX_WR>
### Specific device
$ rdma dev show mlx5_4
5: mlx5_4: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:345b sys_image_guid 5254:00c0:fe12:345b
### Specific device in detailed mode
$ rdma dev show mlx5_4 -d
5: mlx5_4: node_type ca fw 2.8.9999 node_guid 5254:00c0:fe12:345b sys_image_guid 5254:00c0:fe12:345b
caps: <BAD_PKEY_CNTR, BAD_QKEY_CNTR, CHANGE_PHY_POR, PORT_ACTIVE_EVENT, SYS_IMAGE_GUID, RC_RNR_NAK_GEN, MEM_WINDOW, UD_IP_CSUM, UD_TSO, XRC, MEM_MGT_EXTENSIONS, BLOCK_MULTICAST_LOOPBACK, MEM_WINDOW_TYPE_2B, RAW_IP_CSUM, MANAGED_FLOW_STEERING, RESIZE_MAX_WR>
### Unknown command (caps)
$ rdma dev show mlx5_4 caps
Unknown parameter 'caps'.
### Link properties without device name
$ rdma link
1/1: mlx5_0/1: subnet_prefix fe80:0000:0000:0000 lid 13399 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
2/1: mlx5_1/1: subnet_prefix fe80:0000:0000:0000 lid 13400 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
3/1: mlx5_2/1: subnet_prefix fe80:0000:0000:0000 lid 13401 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
4/1: mlx5_3/1: state DOWN physical_state DISABLED
5/1: mlx5_4/1: subnet_prefix fe80:0000:0000:0000 lid 13403 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
### Link properties in detailed mode
$ rdma link -d
1/1: mlx5_0/1: subnet_prefix fe80:0000:0000:0000 lid 13399 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
caps: <AUTO_MIGR>
2/1: mlx5_1/1: subnet_prefix fe80:0000:0000:0000 lid 13400 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
caps: <AUTO_MIGR>
3/1: mlx5_2/1: subnet_prefix fe80:0000:0000:0000 lid 13401 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
caps: <AUTO_MIGR>
4/1: mlx5_3/1: state DOWN physical_state DISABLED
caps: <CM, IP_BASED_GIDS>
5/1: mlx5_4/1: subnet_prefix fe80:0000:0000:0000 lid 13403 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
caps: <AUTO_MIGR>
### All links for specific device
$ rdma link show mlx5_3
1/1: mlx5_0/1: subnet_prefix fe80:0000:0000:0000 lid 13399 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
### Detailed link properties for specific device
$ rdma link -d show mlx5_3
1/1: mlx5_0/1: subnet_prefix fe80:0000:0000:0000 lid 13399 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
caps: <AUTO_MIGR>
### Specific port for specific device
$ rdma link show mlx5_4/1
1/1: mlx5_0/1: subnet_prefix fe80:0000:0000:0000 lid 13399 sm_lid 49151 lmc 0 state ACTIVE physical_state LINK_UP
### Unknown parameter
$ rdma link show mlx5_4/1 caps
Unknown parameter 'caps'.
Thanks
Changelog:
v2->v4:
* Rebased on latest net-next branch
* Added JSON output -j (json) and -p (pretty output)
* Exported and reused kernel UAPIs and defines instead of hard coded
version.
v2->v3:
* Removed MAX()
* Reduced scope of rd_argv_match
* Removed return from rdma_free_devmap
* Added extra break at rdma_send_msg
v1->v2:
* Squashed multiple (and similar) patches to be one patch for dev object
and one patch for link object.
* Removed port_map struct
* Removed global netlink dump during initialization, it removed the need to store
the intermediate variables and reuse ability of netlink to signal if variable
exists or doesn't.
* Added "-d" --details option and put all CAPs under it.
v0->v1:
* Moved hunk with changes in man/Makefile from first patch to the last patch
* Removed the "unknown command" from the examples in commit messages
* Removed special "caps" parsing command and put it to be part of general "show" command
* Changed parsed capability format to be similar to iproute2 suite
* Added FW version as an output of show command.
* Added forgotten CAP_FLAGS to the nla_policy list
RFC->v0:
* Removed everything that is not implemented yet.
* Abandoned sysfs interfaces in favor of netlink.
Available in the "topic/rdmatool-netlink-v4" topic branch of this git repo:
git://git.kernel.org/pub/scm/linux/kernel/git/leon/iproute2.git
Or for browsing:
https://git.kernel.org/cgit/linux/kernel/git/leon/iproute2.git/log/?h=topic/rdmatool-netlink-v4
Thanks
[1] https://www.spinics.net/lists/linux-rdma/msg49575.html
[2] https://patchwork.kernel.org/patch/9752865/
[3] https://www.spinics.net/lists/linux-rdma/msg50827.html
[4] https://www.spinics.net/lists/linux-rdma/msg51210.html
[5] https://patchwork.kernel.org/patch/9811729/ and https://patchwork.kernel.org/patch/9811731/]
[6] http://marc.info/?l=linux-rdma&m=150278847820844&w=2
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Dennis Dalessandro <dennis.dalessandro-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Jiri Pirko <jiri-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Ariel Almog <ariela-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Linux RDMA <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: Linux Netdev <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Leon Romanovsky (7):
rdma: Add basic infrastructure for RDMA tool
rdma: Add dev object
rdma: Add link object
rdma: Add initial manual for the tool
rdma: Add json and pretty outputs
rdma: Implement json output for dev object
rdma: Add json output to link object
Makefile | 2 +-
man/man8/rdma-dev.8 | 55 +++++++++
man/man8/rdma-link.8 | 55 +++++++++
man/man8/rdma.8 | 102 ++++++++++++++++
rdma/.gitignore | 1 +
rdma/Makefile | 22 ++++
rdma/dev.c | 281 ++++++++++++++++++++++++++++++++++++++++++
rdma/link.c | 340 +++++++++++++++++++++++++++++++++++++++++++++++++++
rdma/rdma.c | 143 ++++++++++++++++++++++
rdma/rdma.h | 90 ++++++++++++++
rdma/utils.c | 266 ++++++++++++++++++++++++++++++++++++++++
11 files changed, 1356 insertions(+), 1 deletion(-)
create mode 100644 man/man8/rdma-dev.8
create mode 100644 man/man8/rdma-link.8
create mode 100644 man/man8/rdma.8
create mode 100644 rdma/.gitignore
create mode 100644 rdma/Makefile
create mode 100644 rdma/dev.c
create mode 100644 rdma/link.c
create mode 100644 rdma/rdma.c
create mode 100644 rdma/rdma.h
create mode 100644 rdma/utils.c
--
2.14.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH net-next] bpf/verifier: track liveness for pruning
From: Edward Cree @ 2017-08-15 12:53 UTC (permalink / raw)
To: Daniel Borkmann, davem, Alexei Starovoitov, Alexei Starovoitov
Cc: netdev, linux-kernel, iovisor-dev
In-Reply-To: <5992E090.5040103@iogearbox.net>
On 15/08/17 12:52, Daniel Borkmann wrote:
> On 08/14/2017 07:55 PM, Edward Cree wrote:
>> if (arg_type == ARG_ANYTHING) {
>> if (is_pointer_value(env, regno)) {
>> @@ -1639,10 +1675,13 @@ static int check_call(struct bpf_verifier_env *env, int func_id, int insn_idx)
>> }
>>
>> /* reset caller saved regs */
>> - for (i = 0; i < CALLER_SAVED_REGS; i++)
>> + for (i = 0; i < CALLER_SAVED_REGS; i++) {
>> mark_reg_not_init(regs, caller_saved[i]);
>> + check_reg_arg(env, i, DST_OP_NO_MARK);
>
> Don't we need the same in check_ld_abs() since we treat it similar
> to a function call?
Yes, I forgot about LD_ABS. I'll fix it and spin a v2.
-Ed
^ permalink raw reply
* RE: [net-next 08/15] i40e/i40evf: organize and re-number feature flags
From: David Laight @ 2017-08-15 12:42 UTC (permalink / raw)
To: 'Keller, Jacob E', David Miller, Kirsher, Jeffrey T
Cc: netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
jogreene@redhat.com
In-Reply-To: <02874ECE860811409154E81DA85FBB5882A55079@ORSMSX115.amr.corp.intel.com>
From: Keller, Jacob E
> Sent: 14 August 2017 23:11
> > From: David Miller [mailto:davem@davemloft.net]
> > Sent: Saturday, August 12, 2017 1:04 PM
> > From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> > Date: Sat, 12 Aug 2017 04:08:41 -0700
> >
> > > Also ensure that the flags variable is actually a u64 to guarantee
> > > 64bits of space on all architectures.
> >
> > Why? You don't need 64-bits, you only need 27.
> >
> > This will be unnecessarily expensive on 32-bit platforms.
> >
> > Please don't do this.
>
> I suppose a better method would be to switch to using a declare_bitmap instead, so that it
> automatically sizes based on the number of flags we have. The reason we chose 64bits is because we
> will add flags in the future, as we originally had more than 32 flags prior to this patch until we
> moved some into a separate field.
>
> But now that I think about it, using DECLARE_BITMAP makes more sense, though it's a bit more invasive
> of the code.
And horribly stupid unless you really need dynamic indexes.
David
^ permalink raw reply
* RE: [iproute PATCH 51/51] lib/bpf: Check return value of write()
From: David Laight @ 2017-08-15 12:31 UTC (permalink / raw)
To: 'Phil Sutter', Stephen Hemminger; +Cc: netdev@vger.kernel.org
In-Reply-To: <20170812120510.28750-52-phil@nwl.cc>
From: Phil Sutter
> Sent: 12 August 2017 13:05
> This is merely to silence the compiler warning. If write to stderr
> failed, assume that printing an error message will fail as well so don't
> even try.
>
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> lib/bpf.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/bpf.c b/lib/bpf.c
> index 1dcb261dc915f..825e071cea572 100644
> --- a/lib/bpf.c
> +++ b/lib/bpf.c
> @@ -591,7 +591,8 @@ int bpf_trace_pipe(void)
>
> ret = read(fd, buff, sizeof(buff) - 1);
> if (ret > 0) {
> - write(2, buff, ret);
> + if (write(STDERR_FILENO, buff, ret) != ret)
> + return -1;
> fflush(stderr);
> }
WTF is this code doing anyway?
write() is a system call, fflush() writes out any data buffered in the
stdio stream.
If there was anything buffered you'd want to output it earlier.
Otherwise if it is going to use fflush() it should be using fwrite().
I presume the function is allowed to write to stderr - since in general
library functions shouldn't assume fd 0/1/2 or stdin/out/err are valid.
There is a lot of code out there that does close(0); close(1); close(2);
but leaves stdout/err valid. Call printf() instead of sprint() and eventually
10k of data gets written somewhere rather unexpected.
If it is a copy loop, what is wrong with the last byte of buff[].
It is valid for write() to return a partial length - the code should
probably loop until all the data is accepted (or error).
David
^ permalink raw reply
* [PATCH net] ipv4: fix NULL dereference in free_fib_info_rcu()
From: Eric Dumazet @ 2017-08-15 12:26 UTC (permalink / raw)
To: David Miller; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
If fi->fib_metrics could not be allocated in fib_create_info()
we attempt to dereference a NULL pointer in free_fib_info_rcu() :
m = fi->fib_metrics;
if (m != &dst_default_metrics && atomic_dec_and_test(&m->refcnt))
kfree(m);
Before my recent patch, we used to call kfree(NULL) and nothing wrong
happened.
Instead of using RCU to defer freeing while we are under memory stress,
it seems better to take immediate action.
This was reported by syzkaller team.
Fixes: 3fb07daff8e9 ("ipv4: add reference counting to metrics")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
net/ipv4/fib_semantics.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index b8d18171cca3..ec3a9ce281a6 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1083,15 +1083,17 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
if (!fi)
goto failure;
- fib_info_cnt++;
if (cfg->fc_mx) {
fi->fib_metrics = kzalloc(sizeof(*fi->fib_metrics), GFP_KERNEL);
- if (!fi->fib_metrics)
- goto failure;
+ if (unlikely(!fi->fib_metrics)) {
+ kfree(fi);
+ return ERR_PTR(err);
+ }
atomic_set(&fi->fib_metrics->refcnt, 1);
- } else
+ } else {
fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics;
-
+ }
+ fib_info_cnt++;
fi->fib_net = net;
fi->fib_protocol = cfg->fc_protocol;
fi->fib_scope = cfg->fc_scope;
^ permalink raw reply related
* Mellanox driver / cant access /prox/irq/XX/smp_affinity after upgrade from linux-4.13-rc4-next-20170811 to 4.13.0-rc5-next-20170815
From: Paweł Staszewski @ 2017-08-15 12:21 UTC (permalink / raw)
To: Linux Kernel Network Developers
Hi
After upgrading kernel to latest next there is problem with accessing
smp_affinity to write for mellanox driver
For example - MEllanox:
cat /proc/interrupts | grep ml
217: 3 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 PCI-MSI
91750400-edge mlx5_pages_eq@pci:0000:af:00.0
218: 12237 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 PCI-MSI
91750401-edge mlx5_cmd_eq@pci:0000:af:00.0
cat /proc/irq/218/smp_affinity
ffffff,ffffffff
echo "ffffff,ffffffff " > /proc/irq/218/smp_affinity
-su: echo: write error: Input/output error
For intel ixgbe:
90: 1 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 PCI-MSI
12589056-edge enp24s0f3
cat /proc/irq/90/smp_affinity
0003ff,f0003fff
echo "0003ff,f0003fff" > /proc/irq/90/smp_affinity
Without errors.
BR
Pawel
^ permalink raw reply
* Re: general protection fault in fib_dump_info
From: Florian Westphal @ 2017-08-15 12:05 UTC (permalink / raw)
To: idaifish; +Cc: davem, kuznet, yoshfuji, netdev, syzkaller, roopa
In-Reply-To: <CADUsjNkM2KuAJj6xc=Xj3he8z3B5XYv5m8H5x-FCHwdGjW_AYg@mail.gmail.com>
idaifish <idaifish@gmail.com> wrote:
> Syzkaller hit 'general protection fault in fib_dump_info' bug on
> commit 4.13-rc5..
CC Roopa
> Guilty file: net/ipv4/fib_semantics.c
>
> kasan: GPF could be caused by NULL-ptr deref or user memory access
> general protection fault: 0000 [#1] SMP KASAN
> Modules linked in:
> CPU: 0 PID: 2808 Comm: syz-executor0 Not tainted 4.13.0-rc5 #1
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> Ubuntu-1.8.2-1ubuntu1 04/01/2014
> task: ffff880078562700 task.stack: ffff880078110000
> RIP: 0010:fib_dump_info+0x388/0x1170 net/ipv4/fib_semantics.c:1314
> RSP: 0018:ffff880078117010 EFLAGS: 00010206
> RAX: dffffc0000000000 RBX: 00000000000000fe RCX: 0000000000000002
> RDX: 0000000000000006 RSI: ffff880078117084 RDI: 0000000000000030
> RBP: ffff880078117268 R08: 000000000000000c R09: ffff8800780d80c8
> R10: 0000000058d629b4 R11: 0000000067fce681 R12: 0000000000000000
> R13: ffff8800784bd540 R14: ffff8800780d80b5 R15: ffff8800780d80a4
> FS: 00000000022fa940(0000) GS:ffff88007fc00000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00000000004387d0 CR3: 0000000079135000 CR4: 00000000000006f0
> Call Trace:
> inet_rtm_getroute+0xc89/0x1f50 net/ipv4/route.c:2766
> rtnetlink_rcv_msg+0x288/0x680 net/core/rtnetlink.c:4217
Seems like this is from
b61798130f1be5bff08712308126c2d7ebe390ef
Roopa, it seems to assume res.fi != NULL, but afaics there
is no guarantee, f.e. in ip_route_input_rcu() in the multicast
branch res isn't changed at all.
If thats true, we might need this fix?
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 7effa62beed3..fc0708f7792d 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2763,7 +2763,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE)
table_id = rt->rt_table_id;
- if (rtm->rtm_flags & RTM_F_FIB_MATCH)
+ if ((rtm->rtm_flags & RTM_F_FIB_MATCH) && res.fi)
err = fib_dump_info(skb, NETLINK_CB(in_skb).portid,
nlh->nlmsg_seq, RTM_NEWROUTE, table_id,
rt->rt_type, res.prefix, res.prefixlen,
fl4.flowi4_tos, res.fi, 0);
^ permalink raw reply related
* [PATCH 5/5] net/9p: Delete an unnecessary variable initialisation in p9_client_attach()
From: SF Markus Elfring @ 2017-08-15 12:03 UTC (permalink / raw)
To: v9fs-developer, netdev, David S. Miller, Eric Van Hensbergen,
Latchesar Ionkov, Ron Minnich
Cc: LKML, kernel-janitors
In-Reply-To: <22a44d7c-cdb9-e206-4b2c-56e38cbf0de1@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 11:25:31 +0200
The local variable "err" will eventually be set to an appropriate value
a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/9p/client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index 38c08171acc6..1d59db9aafb3 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -1124,7 +1124,7 @@ EXPORT_SYMBOL(p9_client_begin_disconnect);
struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
const char *uname, kuid_t n_uname, const char *aname)
{
- int err = 0;
+ int err;
struct p9_req_t *req;
struct p9_fid *fid;
struct p9_qid qid;
--
2.14.0
^ permalink raw reply related
* [PATCH 4/5] net/9p: Adjust a jump target in p9_client_attach()
From: SF Markus Elfring @ 2017-08-15 12:02 UTC (permalink / raw)
To: v9fs-developer, netdev, David S. Miller, Eric Van Hensbergen,
Latchesar Ionkov, Ron Minnich
Cc: LKML, kernel-janitors
In-Reply-To: <22a44d7c-cdb9-e206-4b2c-56e38cbf0de1@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 11:17:23 +0200
Adjust jump labels so that the function implementation becomes smaller.
Delete an extra variable assignment and a check (at the end of
this function).
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/9p/client.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index 6c2fc796edfb..38c08171acc6 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -1133,25 +1133,23 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
p9_debug(P9_DEBUG_9P, ">>> TATTACH afid %d uname %s aname %s\n",
afid ? afid->fid : -1, uname, aname);
fid = p9_fid_create(clnt);
- if (IS_ERR(fid)) {
- err = PTR_ERR(fid);
- fid = NULL;
- goto error;
- }
+ if (IS_ERR(fid))
+ return fid;
+
fid->uid = n_uname;
req = p9_client_rpc(clnt, P9_TATTACH, "ddss?u", fid->fid,
afid ? afid->fid : P9_NOFID, uname, aname, n_uname);
if (IS_ERR(req)) {
err = PTR_ERR(req);
- goto error;
+ goto destroy_fid;
}
err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
if (err) {
trace_9p_protocol_dump(clnt, req->rc);
p9_free_req(clnt, req);
- goto error;
+ goto destroy_fid;
}
p9_debug(P9_DEBUG_9P, "<<< RATTACH qid %x.%llx.%x\n",
@@ -1161,10 +1159,8 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
p9_free_req(clnt, req);
return fid;
-
-error:
- if (fid)
- p9_fid_destroy(fid);
+destroy_fid:
+ p9_fid_destroy(fid);
return ERR_PTR(err);
}
EXPORT_SYMBOL(p9_client_attach);
--
2.14.0
^ permalink raw reply related
* [PATCH 3/5] net/9p: Add a jump target in p9_client_walk()
From: SF Markus Elfring @ 2017-08-15 12:01 UTC (permalink / raw)
To: v9fs-developer, netdev, David S. Miller, Eric Van Hensbergen,
Latchesar Ionkov, Ron Minnich
Cc: LKML, kernel-janitors
In-Reply-To: <22a44d7c-cdb9-e206-4b2c-56e38cbf0de1@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 10:07:22 +0200
Replace a variable assignment by a goto statement so that an extra check
will be avoided at the end of this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/9p/client.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index 2ca55d4b0b7d..6c2fc796edfb 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -1237,12 +1237,11 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
clunk_fid:
kfree(wqids);
p9_client_clunk(fid);
- fid = NULL;
-
+ goto exit;
error:
if (fid && (fid != oldfid))
p9_fid_destroy(fid);
-
+exit:
return ERR_PTR(err);
}
EXPORT_SYMBOL(p9_client_walk);
--
2.14.0
^ permalink raw reply related
* [PATCH 2/5] net/9p: Improve 19 size determinations
From: SF Markus Elfring @ 2017-08-15 12:00 UTC (permalink / raw)
To: v9fs-developer, netdev, David S. Miller, Eric Van Hensbergen,
Latchesar Ionkov, Ron Minnich
Cc: LKML, kernel-janitors
In-Reply-To: <22a44d7c-cdb9-e206-4b2c-56e38cbf0de1@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 09:36:20 +0200
Replace the specification of data structures by variable references
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/9p/client.c | 19 +++++++++----------
net/9p/protocol.c | 6 +++---
net/9p/trans_fd.c | 10 +++++-----
net/9p/trans_rdma.c | 2 +-
net/9p/trans_virtio.c | 5 ++---
net/9p/util.c | 2 +-
6 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index 2273181e9ba9..2ca55d4b0b7d 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -272,8 +272,8 @@ p9_tag_alloc(struct p9_client *c, u16 tag, unsigned int max_size)
while (tag >= c->max_tag) {
row = (tag / P9_ROW_MAXTAG);
c->reqs[row] = kcalloc(P9_ROW_MAXTAG,
- sizeof(struct p9_req_t), GFP_ATOMIC);
-
+ sizeof(*c->reqs[row]),
+ GFP_ATOMIC);
if (!c->reqs[row]) {
spin_unlock_irqrestore(&c->lock, flags);
return ERR_PTR(-ENOMEM);
@@ -907,7 +907,7 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
unsigned long flags;
p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt);
- fid = kmalloc(sizeof(struct p9_fid), GFP_KERNEL);
+ fid = kmalloc(sizeof(*fid), GFP_KERNEL);
if (!fid)
return ERR_PTR(-ENOMEM);
@@ -918,7 +918,7 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
}
fid->fid = ret;
- memset(&fid->qid, 0, sizeof(struct p9_qid));
+ memset(&fid->qid, 0, sizeof(fid->qid));
fid->mode = -1;
fid->uid = current_fsuid();
fid->clnt = clnt;
@@ -1015,7 +1015,7 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
char *client_id;
err = 0;
- clnt = kmalloc(sizeof(struct p9_client), GFP_KERNEL);
+ clnt = kmalloc(sizeof(*clnt), GFP_KERNEL);
if (!clnt)
return ERR_PTR(-ENOMEM);
@@ -1157,7 +1157,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
p9_debug(P9_DEBUG_9P, "<<< RATTACH qid %x.%llx.%x\n",
qid.type, (unsigned long long)qid.path, qid.version);
- memmove(&fid->qid, &qid, sizeof(struct p9_qid));
+ memmove(&fid->qid, &qid, sizeof(qid));
p9_free_req(clnt, req);
return fid;
@@ -1227,7 +1227,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
wqids[count].version);
if (nwname)
- memmove(&fid->qid, &wqids[nwqids - 1], sizeof(struct p9_qid));
+ memmove(&fid->qid, &wqids[nwqids - 1], sizeof(fid->qid));
else
fid->qid = oldfid->qid;
@@ -1697,7 +1697,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
{
int err;
struct p9_client *clnt;
- struct p9_wstat *ret = kmalloc(sizeof(struct p9_wstat), GFP_KERNEL);
+ struct p9_wstat *ret = kmalloc(sizeof(*ret), GFP_KERNEL);
struct p9_req_t *req;
u16 ignored;
@@ -1749,8 +1749,7 @@ struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
{
int err;
struct p9_client *clnt;
- struct p9_stat_dotl *ret = kmalloc(sizeof(struct p9_stat_dotl),
- GFP_KERNEL);
+ struct p9_stat_dotl *ret = kmalloc(sizeof(*ret), GFP_KERNEL);
struct p9_req_t *req;
p9_debug(P9_DEBUG_9P, ">>> TGETATTR fid %d, request_mask %lld\n",
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index 16e10680518c..b8dc30f7de07 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -200,7 +200,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
struct p9_wstat *stbuf =
va_arg(ap, struct p9_wstat *);
- memset(stbuf, 0, sizeof(struct p9_wstat));
+ memset(stbuf, 0, sizeof(*stbuf));
stbuf->n_uid = stbuf->n_muid = INVALID_UID;
stbuf->n_gid = INVALID_GID;
@@ -286,7 +286,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
if (!errcode) {
*wqids =
kmalloc(*nwqid *
- sizeof(struct p9_qid),
+ sizeof(**wqids),
GFP_NOFS);
if (*wqids == NULL)
errcode = -ENOMEM;
@@ -316,7 +316,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
struct p9_stat_dotl *stbuf =
va_arg(ap, struct p9_stat_dotl *);
- memset(stbuf, 0, sizeof(struct p9_stat_dotl));
+ memset(stbuf, 0, sizeof(*stbuf));
errcode =
p9pdu_readf(pdu, proto_version,
"qQdugqqqqqqqqqqqqqqq",
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 3c272e5bc9ea..4a709146ae24 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -805,8 +805,8 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
static int p9_fd_open(struct p9_client *client, int rfd, int wfd)
{
- struct p9_trans_fd *ts = kzalloc(sizeof(struct p9_trans_fd),
- GFP_KERNEL);
+ struct p9_trans_fd *ts = kzalloc(sizeof(*ts), GFP_KERNEL);
+
if (!ts)
return -ENOMEM;
@@ -832,7 +832,7 @@ static int p9_socket_open(struct p9_client *client, struct socket *csocket)
struct p9_trans_fd *p;
struct file *file;
- p = kzalloc(sizeof(struct p9_trans_fd), GFP_KERNEL);
+ p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -983,7 +983,7 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
err = csocket->ops->connect(csocket,
(struct sockaddr *)&sin_server,
- sizeof(struct sockaddr_in), 0);
+ sizeof(sin_server), 0);
if (err < 0) {
pr_err("%s (%d): problem connecting socket to %s\n",
__func__, task_pid_nr(current), addr);
@@ -1020,7 +1020,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args)
return err;
}
err = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server,
- sizeof(struct sockaddr_un) - 1, 0);
+ sizeof(sun_server) - 1, 0);
if (err < 0) {
pr_err("%s (%d): problem connecting socket: %s: %d\n",
__func__, task_pid_nr(current), addr, err);
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index f98b6aae308b..6422a3775ff5 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -576,7 +576,7 @@ static struct p9_trans_rdma *alloc_rdma(struct p9_rdma_opts *opts)
{
struct p9_trans_rdma *rdma;
- rdma = kzalloc(sizeof(struct p9_trans_rdma), GFP_KERNEL);
+ rdma = kzalloc(sizeof(*rdma), GFP_KERNEL);
if (!rdma)
return NULL;
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 8a2cf9748398..ac6ad9d344a6 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -359,8 +359,7 @@ static int p9_get_mapped_pages(struct virtio_chan *chan,
nr_pages = DIV_ROUND_UP((unsigned long)p + len, PAGE_SIZE) -
(unsigned long)p / PAGE_SIZE;
-
- *pages = kmalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
+ *pages = kmalloc(sizeof(**pages) * nr_pages, GFP_NOFS);
if (!*pages)
return -ENOMEM;
@@ -550,7 +549,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
return -EINVAL;
}
- chan = kmalloc(sizeof(struct virtio_chan), GFP_KERNEL);
+ chan = kmalloc(sizeof(*chan), GFP_KERNEL);
if (!chan) {
err = -ENOMEM;
goto fail;
diff --git a/net/9p/util.c b/net/9p/util.c
index 59f278e64f58..2c53173bdf1c 100644
--- a/net/9p/util.c
+++ b/net/9p/util.c
@@ -54,7 +54,7 @@ struct p9_idpool *p9_idpool_create(void)
{
struct p9_idpool *p;
- p = kmalloc(sizeof(struct p9_idpool), GFP_KERNEL);
+ p = kmalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return ERR_PTR(-ENOMEM);
--
2.14.0
^ permalink raw reply related
* Re: [PATCH v2 net-next 1/3] ipv6: Prevent unexpected sk->sk_prot changes
From: Eric Dumazet @ 2017-08-15 11:59 UTC (permalink / raw)
To: Ilya Lesokhin; +Cc: netdev, davem, davejwatson, aviadye, Boris Pismenny
In-Reply-To: <1502795320-22538-2-git-send-email-ilyal@mellanox.com>
On Tue, 2017-08-15 at 14:08 +0300, Ilya Lesokhin wrote:
> With this patch IPV6 code ensure that only sockets with the
> expected sk->sk_prot are converted to IPV4.
>
> Signed-off-by: Boris Pismenny <borisp@mellanox.com>
> ---
> net/ipv6/ipv6_sockglue.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
> index 02d795f..318cd344 100644
> --- a/net/ipv6/ipv6_sockglue.c
> +++ b/net/ipv6/ipv6_sockglue.c
> @@ -174,6 +174,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
> if (val == PF_INET) {
> struct ipv6_txoptions *opt;
> struct sk_buff *pktopt;
> + struct proto *expected_prot;
>
> if (sk->sk_type == SOCK_RAW)
> break;
> @@ -199,6 +200,17 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
> break;
> }
>
> + if (sk->sk_protocol == IPPROTO_TCP &&
> + sk->sk_prot != &tcpv6_prot)
> + break;
> +
> + expected_prot = &udpv6_prot;
> + if (sk->sk_protocol == IPPROTO_UDPLITE)
> + expected_prot = &udplitev6_prot;
> +
> + if (sk->sk_prot != expected_prot)
> + break;
> +
> fl6_free_socklist(sk);
> __ipv6_sock_mc_close(sk);
>
I am afraid I do not understand this patch at all.
Direct references to tcpv6_prot, udpv6_prot, and udplitev6_prot in
net/ipv6/ipv6_sockglue.c looks completely broken.
Please provide something cleaner, maybe by adding a new method
(implementation would then be provided in TCP / UDP code )
^ permalink raw reply
* [PATCH 1/5] net/9p: Delete an error message for a failed memory allocation in five functions
From: SF Markus Elfring @ 2017-08-15 11:58 UTC (permalink / raw)
To: v9fs-developer, netdev, David S. Miller, Eric Van Hensbergen,
Latchesar Ionkov, Ron Minnich
Cc: LKML, kernel-janitors
In-Reply-To: <22a44d7c-cdb9-e206-4b2c-56e38cbf0de1@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 08:25:41 +0200
Omit an extra message for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/9p/client.c | 7 ++-----
net/9p/trans_fd.c | 6 ++----
net/9p/trans_rdma.c | 6 ++----
net/9p/trans_virtio.c | 1 -
4 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/net/9p/client.c b/net/9p/client.c
index 4674235b0d9b..2273181e9ba9 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -160,11 +160,9 @@ static int parse_opts(char *opts, struct p9_client *clnt)
return 0;
tmp_options = kstrdup(opts, GFP_KERNEL);
- if (!tmp_options) {
- p9_debug(P9_DEBUG_ERROR,
- "failed to allocate copy of option string\n");
+ if (!tmp_options)
return -ENOMEM;
- }
+
options = tmp_options;
while ((p = strsep(&options, ",")) != NULL) {
@@ -277,7 +275,6 @@ p9_tag_alloc(struct p9_client *c, u16 tag, unsigned int max_size)
sizeof(struct p9_req_t), GFP_ATOMIC);
if (!c->reqs[row]) {
- pr_err("Couldn't grow tag array\n");
spin_unlock_irqrestore(&c->lock, flags);
return ERR_PTR(-ENOMEM);
}
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index ddfa86648f95..3c272e5bc9ea 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -762,11 +762,9 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
return 0;
tmp_options = kstrdup(params, GFP_KERNEL);
- if (!tmp_options) {
- p9_debug(P9_DEBUG_ERROR,
- "failed to allocate copy of option string\n");
+ if (!tmp_options)
return -ENOMEM;
- }
+
options = tmp_options;
while ((p = strsep(&options, ",")) != NULL) {
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 6d8e3031978f..f98b6aae308b 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -205,11 +205,9 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
return 0;
tmp_options = kstrdup(params, GFP_KERNEL);
- if (!tmp_options) {
- p9_debug(P9_DEBUG_ERROR,
- "failed to allocate copy of option string\n");
+ if (!tmp_options)
return -ENOMEM;
- }
+
options = tmp_options;
while ((p = strsep(&options, ",")) != NULL) {
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index f24b25c25106..8a2cf9748398 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -552,7 +552,6 @@ static int p9_virtio_probe(struct virtio_device *vdev)
chan = kmalloc(sizeof(struct virtio_chan), GFP_KERNEL);
if (!chan) {
- pr_err("Failed to allocate virtio 9P channel\n");
err = -ENOMEM;
goto fail;
}
--
2.14.0
^ permalink raw reply related
* [PATCH 0/5] net/9p: Fine-tuning for some function implementations
From: SF Markus Elfring @ 2017-08-15 11:56 UTC (permalink / raw)
To: v9fs-developer, netdev, David S. Miller, Eric Van Hensbergen,
Latchesar Ionkov, Ron Minnich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 15 Aug 2017 13:43:21 +0200
Some update suggestions were taken into account
from static source code analysis.
Markus Elfring (5):
Delete an error message for a failed memory allocation in five functions
Improve 19 size determinations
Add a jump target in p9_client_walk()
Adjust a jump target in p9_client_attach()
Delete an unnecessary variable initialisation in p9_client_attach()
net/9p/client.c | 51 +++++++++++++++++++++------------------------------
net/9p/protocol.c | 6 +++---
net/9p/trans_fd.c | 16 +++++++---------
net/9p/trans_rdma.c | 8 +++-----
net/9p/trans_virtio.c | 6 ++----
net/9p/util.c | 2 +-
6 files changed, 37 insertions(+), 52 deletions(-)
--
2.14.0
^ permalink raw reply
* Re: [PATCH net-next] bpf/verifier: track liveness for pruning
From: Daniel Borkmann via iovisor-dev @ 2017-08-15 11:52 UTC (permalink / raw)
To: Edward Cree, davem-fT/PcQaiUtIeIZ0/mPfg9Q, Alexei Starovoitov,
Alexei Starovoitov
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, iovisor-dev,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <262cf31a-b70d-3dca-c687-8bcc77726011-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org>
On 08/14/2017 07:55 PM, Edward Cree wrote:
> State of a register doesn't matter if it wasn't read in reaching an exit;
> a write screens off all reads downstream of it from all explored_states
> upstream of it.
> This allows us to prune many more branches; here are some processed insn
> counts for some Cilium programs:
> Program before after
> bpf_lb_opt_-DLB_L3.o 6515 3361
> bpf_lb_opt_-DLB_L4.o 8976 5176
> bpf_lb_opt_-DUNKNOWN.o 2960 1137
> bpf_lxc_opt_-DDROP_ALL.o 95412 48537
> bpf_lxc_opt_-DUNKNOWN.o 141706 79048
> bpf_netdev.o 24251 17995
> bpf_overlay.o 10999 9385
>
> The runtime is also improved; here are 'time' results in ms:
> Program before after
> bpf_lb_opt_-DLB_L3.o 24 6
> bpf_lb_opt_-DLB_L4.o 26 11
> bpf_lb_opt_-DUNKNOWN.o 11 2
> bpf_lxc_opt_-DDROP_ALL.o 1288 152
> bpf_lxc_opt_-DUNKNOWN.o 1768 257
> bpf_netdev.o 62 31
> bpf_overlay.o 15 13
>
> Signed-off-by: Edward Cree <ecree-s/n/eUQHGBpZroRs9YW3xA@public.gmane.org>
Awesome work!
[...]
> if (arg_type == ARG_ANYTHING) {
> if (is_pointer_value(env, regno)) {
> @@ -1639,10 +1675,13 @@ static int check_call(struct bpf_verifier_env *env, int func_id, int insn_idx)
> }
>
> /* reset caller saved regs */
> - for (i = 0; i < CALLER_SAVED_REGS; i++)
> + for (i = 0; i < CALLER_SAVED_REGS; i++) {
> mark_reg_not_init(regs, caller_saved[i]);
> + check_reg_arg(env, i, DST_OP_NO_MARK);
Don't we need the same in check_ld_abs() since we treat it similar
to a function call?
> + }
>
> /* update return register */
> + check_reg_arg(env, BPF_REG_0, DST_OP_NO_MARK);
[...]
^ permalink raw reply
* Re: [PATCH v2 net-next 1/3] ipv6: Prevent unexpected sk->sk_prot changes
From: Eric Dumazet @ 2017-08-15 11:39 UTC (permalink / raw)
To: Ilya Lesokhin; +Cc: netdev, davem, davejwatson, aviadye, Boris Pismenny
In-Reply-To: <1502795320-22538-2-git-send-email-ilyal@mellanox.com>
On Tue, 2017-08-15 at 14:08 +0300, Ilya Lesokhin wrote:
> With this patch IPV6 code ensure that only sockets with the
> expected sk->sk_prot are converted to IPV4.
It looks like you fix a bug added by a recent commit (in net-next, not
in net tree) ?
Please provide Fixes: tag to ease code review and maintenance.
Thanks.
^ permalink raw reply
* [PATCH net V2] openvswitch: fix skb_panic due to the incorrect actions attrlen
From: Liping Zhang @ 2017-08-15 11:29 UTC (permalink / raw)
To: pshelar, davem; +Cc: netdev, Liping Zhang, Neil McKee
From: Liping Zhang <zlpnobody@gmail.com>
For sw_flow_actions, the actions_len only represents the kernel part's
size, and when we dump the actions to the userspace, we will do the
convertions, so it's true size may become bigger than the actions_len.
But unfortunately, for OVS_PACKET_ATTR_ACTIONS, we use the actions_len
to alloc the skbuff, so the user_skb's size may become insufficient and
oops will happen like this:
skbuff: skb_over_panic: text:ffffffff8148fabf len:1749 put:157 head:
ffff881300f39000 data:ffff881300f39000 tail:0x6d5 end:0x6c0 dev:<NULL>
------------[ cut here ]------------
kernel BUG at net/core/skbuff.c:129!
[...]
Call Trace:
<IRQ>
[<ffffffff8148be82>] skb_put+0x43/0x44
[<ffffffff8148fabf>] skb_zerocopy+0x6c/0x1f4
[<ffffffffa0290d36>] queue_userspace_packet+0x3a3/0x448 [openvswitch]
[<ffffffffa0292023>] ovs_dp_upcall+0x30/0x5c [openvswitch]
[<ffffffffa028d435>] output_userspace+0x132/0x158 [openvswitch]
[<ffffffffa01e6890>] ? ip6_rcv_finish+0x74/0x77 [ipv6]
[<ffffffffa028e277>] do_execute_actions+0xcc1/0xdc8 [openvswitch]
[<ffffffffa028e3f2>] ovs_execute_actions+0x74/0x106 [openvswitch]
[<ffffffffa0292130>] ovs_dp_process_packet+0xe1/0xfd [openvswitch]
[<ffffffffa0292b77>] ? key_extract+0x63c/0x8d5 [openvswitch]
[<ffffffffa029848b>] ovs_vport_receive+0xa1/0xc3 [openvswitch]
[...]
Also we can find that the actions_len is much little than the orig_len:
crash> struct sw_flow_actions 0xffff8812f539d000
struct sw_flow_actions {
rcu = {
next = 0xffff8812f5398800,
func = 0xffffe3b00035db32
},
orig_len = 1384,
actions_len = 592,
actions = 0xffff8812f539d01c
}
So as a quick fix, use the orig_len instead of the actions_len to alloc
the user_skb.
Last, this oops happened on our system running a relative old kernel, but
the same risk still exists on the mainline, since we use the wrong
actions_len from the beginning.
Fixes: ccea74457bbd ("openvswitch: include datapath actions with sampled-packet upcall to userspace")
Cc: Neil McKee <neil.mckee@inmon.com>
Signed-off-by: Liping Zhang <zlpnobody@gmail.com>
---
V2: move actions_attrlen into ovs_skb_cb, which will make codes more
clean, suggested by Pravin Shelar.
net/openvswitch/actions.c | 2 ++
net/openvswitch/datapath.c | 2 +-
net/openvswitch/datapath.h | 3 +++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index e4610676299b..f849ef52853f 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -921,6 +921,7 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
/* Include actions. */
upcall.actions = actions;
upcall.actions_len = actions_len;
+ upcall.actions_attrlen = OVS_CB(skb)->acts_origlen;
break;
}
@@ -1337,6 +1338,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
goto out;
}
+ OVS_CB(skb)->acts_origlen = acts->orig_len;
err = do_execute_actions(dp, skb, key,
acts->actions, acts->actions_len);
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 45fe8c8a884d..66162e64e8b5 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -398,7 +398,7 @@ static size_t upcall_msg_size(const struct dp_upcall_info *upcall_info,
/* OVS_PACKET_ATTR_ACTIONS */
if (upcall_info->actions_len)
- size += nla_total_size(upcall_info->actions_len);
+ size += nla_total_size(upcall_info->actions_attrlen);
/* OVS_PACKET_ATTR_MRU */
if (upcall_info->mru)
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index 5d8dcd88815f..8fd902c946ff 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -99,11 +99,13 @@ struct datapath {
* when a packet is received by OVS.
* @mru: The maximum received fragement size; 0 if the packet is not
* fragmented.
+ * @acts_origlen: The netlink size of the flow actions applied to this skb.
* @cutlen: The number of bytes from the packet end to be removed.
*/
struct ovs_skb_cb {
struct vport *input_vport;
u16 mru;
+ u16 acts_origlen;
u32 cutlen;
};
#define OVS_CB(skb) ((struct ovs_skb_cb *)(skb)->cb)
@@ -124,6 +126,7 @@ struct dp_upcall_info {
const struct nlattr *userdata;
const struct nlattr *actions;
int actions_len;
+ int actions_attrlen;
u32 portid;
u8 cmd;
u16 mru;
--
2.13.4
^ permalink raw reply related
* pull-request: wireless-drivers 2017-08-15
From: Kalle Valo @ 2017-08-15 11:30 UTC (permalink / raw)
To: David Miller; +Cc: linux-wireless, netdev, linux-kernel
Hi Dave,
more fixes to net tree for 4.13. More info in the signed tag below,
please let me know if there are any problems.
Kalle
The following changes since commit 5f5d03143de5e0c593da4ab18fc6393c2815e108:
brcmfmac: fix memleak due to calling brcmf_sdiod_sgtable_alloc() twice (2017-07-27 14:03:14 +0300)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers.git tags/wireless-drivers-for-davem-2017-08-15
for you to fetch changes up to e9bf53ab1ee34bb05c104bbfd2b77c844773f8e6:
brcmfmac: feature check for multi-scheduled scan fails on bcm4343x devices (2017-08-14 11:09:30 +0300)
----------------------------------------------------------------
wireless-drivers fixes for 4.13
This time quite a few fixes for iwlwifi and one major regression fix
for brcmfmac. For the iwlwifi aggregation bug a small change was
needed for mac80211, but as Johannes is still away the mac80211 patch
is taken via wireless-drivers tree.
brcmfmac
* fix firmware crash (a recent regression in bcm4343{0,1,8}
iwlwifi
* Some simple PCI HW ID fix-ups and additions for family 9000
* Remove a bogus warning message with new FWs (bug #196915)
* Don't allow illegal channel options to be used (bug #195299)
* A fix for checksum offload in family 9000
* A fix serious throughput degradation in 11ac with multiple streams
* An old bug in SMPS where the firmware was not aware of SMPS changes
* Fix a memory leak in the SAR code
* Fix a stuck queue case in AP mode;
* Convert a WARN to a simple debug in a legitimate race case (from
which we can recover)
* Fix a severe throughput aggregation on 9000-family devices due to
aggregation issues, needed a small change in mac80211
----------------------------------------------------------------
Arend Van Spriel (1):
brcmfmac: feature check for multi-scheduled scan fails on bcm4343x devices
Avraham Stern (1):
iwlwifi: mvm: start mac queues when deferred tx frames are purged
Christophe Jaillet (1):
iwlwifi: mvm: Fix a memory leak in an error handling path in 'iwl_mvm_sar_get_wgds_table()'
Emmanuel Grumbach (4):
iwlwifi: mvm: fix TCP CSUM offload with WEP and A000 series
iwlwifi: add TLV for MLME offload firmware capability
iwlwifi: split the regulatory rules when the bandwidth flags require it
iwlwifi: mvm: don't WARN when a legit race happens in A-MPDU
Gregory Greenman (2):
iwlwifi: mvm: set A-MPDU bit upon empty BA notification from FW
iwlwifi: mvm: rs: fix TLC statistics collection
Haim Dreyfuss (1):
iwlwifi: fix fw_pre_next_step to apply also for C step
Kalle Valo (2):
Merge tag 'iwlwifi-for-kalle-2017-08-02' of git://git.kernel.org/.../iwlwifi/iwlwifi-fixes
Merge tag 'iwlwifi-for-kalle-2018-08-09' of git://git.kernel.org/.../iwlwifi/iwlwifi-fixes
Naftali Goldstein (3):
iwlwifi: mvm: set the RTS_MIMO_PROT bit in flag mask when sending sta to fw
mac80211: add api to start ba session timer expired flow
iwlwifi: mvm: send delba upon rx ba session timeout
Tzipi Peres (1):
iwlwifi: add the new 9000 series PCI IDs
.../wireless/broadcom/brcm80211/brcmfmac/feature.c | 6 ++++--
drivers/net/wireless/intel/iwlwifi/cfg/9000.c | 14 +++++++-------
drivers/net/wireless/intel/iwlwifi/fw/file.h | 2 ++
drivers/net/wireless/intel/iwlwifi/iwl-config.h | 8 ++++----
drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 5 +++--
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 19 +++++++++++--------
drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 6 ++++--
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 12 +++++++++++-
drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 8 ++++----
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 10 ++++++----
drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 7 ++++---
drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 12 ++++++++++--
drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 20 ++++++++++++++++++++
include/net/mac80211.h | 15 +++++++++++++++
net/mac80211/agg-rx.c | 22 +++++++++++++++++++++-
15 files changed, 126 insertions(+), 40 deletions(-)
^ permalink raw reply
* [PATCH] net: Fix a typo in comment about sock flags.
From: Tonghao Zhang @ 2017-08-15 11:28 UTC (permalink / raw)
To: netdev; +Cc: Tonghao Zhang
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
include/linux/net.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/net.h b/include/linux/net.h
index b5c15b3..d97d80d 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -37,7 +37,7 @@
/* Historically, SOCKWQ_ASYNC_NOSPACE & SOCKWQ_ASYNC_WAITDATA were located
* in sock->flags, but moved into sk->sk_wq->flags to be RCU protected.
- * Eventually all flags will be in sk->sk_wq_flags.
+ * Eventually all flags will be in sk->sk_wq->flags.
*/
#define SOCKWQ_ASYNC_NOSPACE 0
#define SOCKWQ_ASYNC_WAITDATA 1
--
1.8.3.1
^ permalink raw reply related
* RE: [PATCH] of_mdio: merge branch tails in of_phy_register_fixed_link()
From: David Laight @ 2017-08-15 11:18 UTC (permalink / raw)
To: 'David Miller',
sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org
Cc: andrew-g2DYL2Zd6BY@public.gmane.org,
f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <20170813.200908.1426365653542179792.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
From: David Miller
> Sent: 14 August 2017 04:09
> From: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
> Date: Sun, 13 Aug 2017 00:03:06 +0300
>
> > Looks like gcc isn't always able to figure out that 3 *if* branches in
> > of_phy_register_fixed_link() calling fixed_phy_register() at their ends
> > are similar enough and thus can be merged. The "manual" merge saves 40
> > bytes of the object code (AArch64 gcc 4.8.5), and still saves 12 bytes
> > even if gcc was able to merge the branch tails (ARM gcc 4.8.5)...
> >
> > Signed-off-by: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
>
> Applied, but if two instances of the "same" compiler just with
> different targets changes the optimization, it could be because of a
> tradeoff which is specific to parameters expressed in that target's
> backend.
>
> So in the future we should probably back away from trying to "help"
> the compiler in this way.
Probably a trade off between code size and execution speed.
I've had 'fun' trying to stop gcc merging tail code paths
in order to avoid the cost of the branch instruction.
David
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH net] ipv6: fix NULL dereference in ip6_route_dev_notify()
From: Eric Dumazet @ 2017-08-15 11:09 UTC (permalink / raw)
To: David Miller; +Cc: netdev
From: Eric Dumazet <edumazet@google.com>
Based on a syzkaller report [1], I found that a per cpu allocation
failure in snmp6_alloc_dev() would then lead to NULL dereference in
ip6_route_dev_notify().
It seems this is a very old bug, thus no Fixes tag in this submission.
Let's add in6_dev_put_clear() helper, as we will probably use
it elsewhere (once available/present in net-next)
[1]
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 17294 Comm: syz-executor6 Not tainted 4.13.0-rc2+ #10
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
task: ffff88019f456680 task.stack: ffff8801c6e58000
RIP: 0010:__read_once_size include/linux/compiler.h:250 [inline]
RIP: 0010:atomic_read arch/x86/include/asm/atomic.h:26 [inline]
RIP: 0010:refcount_sub_and_test+0x7d/0x1b0 lib/refcount.c:178
RSP: 0018:ffff8801c6e5f1b0 EFLAGS: 00010202
RAX: 0000000000000037 RBX: dffffc0000000000 RCX: ffffc90005d25000
RDX: ffff8801c6e5f218 RSI: ffffffff82342bbf RDI: 0000000000000001
RBP: ffff8801c6e5f240 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff10038dcbe37
R13: 0000000000000006 R14: 0000000000000001 R15: 00000000000001b8
FS: 00007f21e0429700(0000) GS:ffff8801dc100000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001ddbc22000 CR3: 00000001d632b000 CR4: 00000000001426e0
DR0: 0000000020000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
Call Trace:
refcount_dec_and_test+0x1a/0x20 lib/refcount.c:211
in6_dev_put include/net/addrconf.h:335 [inline]
ip6_route_dev_notify+0x1c9/0x4a0 net/ipv6/route.c:3732
notifier_call_chain+0x136/0x2c0 kernel/notifier.c:93
__raw_notifier_call_chain kernel/notifier.c:394 [inline]
raw_notifier_call_chain+0x2d/0x40 kernel/notifier.c:401
call_netdevice_notifiers_info+0x51/0x90 net/core/dev.c:1678
call_netdevice_notifiers net/core/dev.c:1694 [inline]
rollback_registered_many+0x91c/0xe80 net/core/dev.c:7107
rollback_registered+0x1be/0x3c0 net/core/dev.c:7149
register_netdevice+0xbcd/0xee0 net/core/dev.c:7587
register_netdev+0x1a/0x30 net/core/dev.c:7669
loopback_net_init+0x76/0x160 drivers/net/loopback.c:214
ops_init+0x10a/0x570 net/core/net_namespace.c:118
setup_net+0x313/0x710 net/core/net_namespace.c:294
copy_net_ns+0x27c/0x580 net/core/net_namespace.c:418
create_new_namespaces+0x425/0x880 kernel/nsproxy.c:107
unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:206
SYSC_unshare kernel/fork.c:2347 [inline]
SyS_unshare+0x653/0xfa0 kernel/fork.c:2297
entry_SYSCALL_64_fastpath+0x1f/0xbe
RIP: 0033:0x4512c9
RSP: 002b:00007f21e0428c08 EFLAGS: 00000216 ORIG_RAX: 0000000000000110
RAX: ffffffffffffffda RBX: 0000000000718150 RCX: 00000000004512c9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000062020200
RBP: 0000000000000086 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000216 R12: 00000000004b973d
R13: 00000000ffffffff R14: 000000002001d000 R15: 00000000000002dd
Code: 50 2b 34 82 c7 00 f1 f1 f1 f1 c7 40 04 04 f2 f2 f2 c7 40 08 f3 f3
f3 f3 e8 a1 43 39 ff 4c 89 f8 48 8b 95 70 ff ff ff 48 c1 e8 03 <0f> b6
0c 18 4c 89 f8 83 e0 07 83 c0 03 38 c8 7c 08 84 c9 0f 85
RIP: __read_once_size include/linux/compiler.h:250 [inline] RSP:
ffff8801c6e5f1b0
RIP: atomic_read arch/x86/include/asm/atomic.h:26 [inline] RSP:
ffff8801c6e5f1b0
RIP: refcount_sub_and_test+0x7d/0x1b0 lib/refcount.c:178 RSP:
ffff8801c6e5f1b0
---[ end trace e441d046c6410d31 ]---
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
---
include/net/addrconf.h | 10 ++++++++++
net/ipv6/route.c | 6 +++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 6df79e96a780..f44ff2476758 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -336,6 +336,16 @@ static inline void in6_dev_put(struct inet6_dev *idev)
in6_dev_finish_destroy(idev);
}
+static inline void in6_dev_put_clear(struct inet6_dev **pidev)
+{
+ struct inet6_dev *idev = *pidev;
+
+ if (idev) {
+ in6_dev_put(idev);
+ *pidev = NULL;
+ }
+}
+
static inline void __in6_dev_put(struct inet6_dev *idev)
{
refcount_dec(&idev->refcnt);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 99d4727f2b18..94d6a13d47f0 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3721,10 +3721,10 @@ static int ip6_route_dev_notify(struct notifier_block *this,
/* NETDEV_UNREGISTER could be fired for multiple times by
* netdev_wait_allrefs(). Make sure we only call this once.
*/
- in6_dev_put(net->ipv6.ip6_null_entry->rt6i_idev);
+ in6_dev_put_clear(&net->ipv6.ip6_null_entry->rt6i_idev);
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
- in6_dev_put(net->ipv6.ip6_prohibit_entry->rt6i_idev);
- in6_dev_put(net->ipv6.ip6_blk_hole_entry->rt6i_idev);
+ in6_dev_put_clear(&net->ipv6.ip6_prohibit_entry->rt6i_idev);
+ in6_dev_put_clear(&net->ipv6.ip6_blk_hole_entry->rt6i_idev);
#endif
}
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox