aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@kernel.org>2022-03-12 08:58:37 -0700
committerDavid Ahern <dsahern@kernel.org>2022-03-12 08:58:37 -0700
commitcd37d6037f64b52033a9f5ae5c97c40d5bfeadee (patch)
tree03dac1eb09122a5be6d32115fc791638aa9db11f
parent8acb5247e3907762441875f6519b2a60b35c04f7 (diff)
parentac0a54b2d5db0298baab935f555fd092c4b6cb69 (diff)
downloadiproute2-cd37d6037f64b52033a9f5ae5c97c40d5bfeadee.tar.gz
Merge branch 'main' into next
Signed-off-by: David Ahern <dsahern@kernel.org>
-rw-r--r--include/uapi/linux/magic.h1
-rw-r--r--include/utils.h2
-rw-r--r--ip/ipaddress.c16
-rw-r--r--ip/iptuntap.c14
-rw-r--r--lib/fs.c23
-rw-r--r--man/man8/ip-address.8.in3
-rw-r--r--rdma/res-cmid.c24
-rw-r--r--rdma/res-cq.c27
-rw-r--r--rdma/res-ctx.c20
-rw-r--r--rdma/res-mr.c23
-rw-r--r--rdma/res-pd.c25
-rw-r--r--rdma/res-qp.c24
-rw-r--r--rdma/res-srq.c25
-rw-r--r--rdma/res.c15
-rw-r--r--rdma/res.h4
-rw-r--r--rdma/stat-mr.c2
-rw-r--r--rdma/stat.c18
-rw-r--r--vdpa/include/uapi/linux/vdpa.h6
18 files changed, 142 insertions, 130 deletions
diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h
index 0425cd79a..f724129c0 100644
--- a/include/uapi/linux/magic.h
+++ b/include/uapi/linux/magic.h
@@ -36,6 +36,7 @@
#define EFIVARFS_MAGIC 0xde5e81e4
#define HOSTFS_SUPER_MAGIC 0x00c0ffee
#define OVERLAYFS_SUPER_MAGIC 0x794c7630
+#define FUSE_SUPER_MAGIC 0x65735546
#define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */
#define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */
diff --git a/include/utils.h b/include/utils.h
index d644202cc..9765fdd23 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -309,7 +309,7 @@ char *find_cgroup2_mount(bool do_mount);
__u64 get_cgroup2_id(const char *path);
char *get_cgroup2_path(__u64 id, bool full);
int get_command_name(const char *pid, char *comm, size_t len);
-char *get_task_name(pid_t pid);
+int get_task_name(pid_t pid, char *name, size_t len);
int get_rtnl_link_stats_rta(struct rtnl_link_stats64 *stats64,
struct rtattr *tb[]);
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 739b0b9c9..a80996efd 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -2349,16 +2349,6 @@ static bool ipaddr_is_multicast(inet_prefix *a)
return false;
}
-static bool is_valid_label(const char *dev, const char *label)
-{
- size_t len = strlen(dev);
-
- if (strncmp(label, dev, len) != 0)
- return false;
-
- return label[len] == '\0' || label[len] == ':';
-}
-
static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
{
struct {
@@ -2501,12 +2491,6 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
fprintf(stderr, "Not enough information: \"dev\" argument is required.\n");
return -1;
}
- if (l && !is_valid_label(d, l)) {
- fprintf(stderr,
- "\"label\" (%s) must match \"dev\" (%s) or be prefixed by \"dev\" with a colon.\n",
- l, d);
- return -1;
- }
if (peer_len == 0 && local_len) {
if (cmd == RTM_DELADDR && lcl.family == AF_INET && !(lcl.flags & PREFIXLEN_SPECIFIED)) {
diff --git a/ip/iptuntap.c b/ip/iptuntap.c
index 385d2bd80..8e4e09bff 100644
--- a/ip/iptuntap.c
+++ b/ip/iptuntap.c
@@ -321,14 +321,16 @@ static void show_processes(const char *name)
} else if (err == 2 &&
!strcmp("iff", key) &&
!strcmp(name, value)) {
- char *pname = get_task_name(pid);
+ SPRINT_BUF(pname);
- print_string(PRINT_ANY, "name",
- "%s", pname ? : "<NULL>");
+ if (get_task_name(pid, pname, sizeof(pname)))
+ print_string(PRINT_ANY, "name",
+ "%s", "<NULL>");
+ else
+ print_string(PRINT_ANY, "name",
+ "%s", pname);
- print_uint(PRINT_ANY, "pid",
- "(%d)", pid);
- free(pname);
+ print_uint(PRINT_ANY, "pid", "(%d)", pid);
}
free(key);
diff --git a/lib/fs.c b/lib/fs.c
index f6f5f8a0b..3752931cf 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -342,25 +342,28 @@ int get_command_name(const char *pid, char *comm, size_t len)
return 0;
}
-char *get_task_name(pid_t pid)
+int get_task_name(pid_t pid, char *name, size_t len)
{
- char *comm;
+ char path[PATH_MAX];
FILE *f;
if (!pid)
- return NULL;
+ return -1;
- if (asprintf(&comm, "/proc/%d/comm", pid) < 0)
- return NULL;
+ if (snprintf(path, sizeof(path), "/proc/%d/comm", pid) >= sizeof(path))
+ return -1;
- f = fopen(comm, "r");
+ f = fopen(path, "r");
if (!f)
- return NULL;
+ return -1;
- if (fscanf(f, "%ms\n", &comm) != 1)
- comm = NULL;
+ if (!fgets(name, len, f))
+ return -1;
+
+ /* comm ends in \n, get rid of it */
+ name[strcspn(name, "\n")] = '\0';
fclose(f);
- return comm;
+ return 0;
}
diff --git a/man/man8/ip-address.8.in b/man/man8/ip-address.8.in
index a614ac64d..1846252df 100644
--- a/man/man8/ip-address.8.in
+++ b/man/man8/ip-address.8.in
@@ -195,9 +195,6 @@ is derived by setting/resetting the host bits of the interface prefix.
.TP
.BI label " LABEL"
Each address may be tagged with a label string.
-In order to preserve compatibility with Linux-2.0 net aliases,
-this string must coincide with the name of the device or must be prefixed
-with the device name followed by colon.
The maximum allowed total length of label is 15 characters.
.TP
diff --git a/rdma/res-cmid.c b/rdma/res-cmid.c
index bfaa47b5a..7371c3a68 100644
--- a/rdma/res-cmid.c
+++ b/rdma/res-cmid.c
@@ -159,8 +159,15 @@ static int res_cm_id_line(struct rd *rd, const char *name, int idx,
goto out;
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+ SPRINT_BUF(b);
+
pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
- comm = get_task_name(pid);
+ if (!get_task_name(pid, b, sizeof(b)))
+ comm = b;
+ } else if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+ /* discard const from mnl_attr_get_str */
+ comm = (char *)mnl_attr_get_str(
+ nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
}
if (rd_is_filtered_attr(rd, "pid", pid,
@@ -173,22 +180,16 @@ static int res_cm_id_line(struct rd *rd, const char *name, int idx,
nla_line[RDMA_NLDEV_ATTR_RES_CM_IDN]))
goto out;
- if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
- /* discard const from mnl_attr_get_str */
- comm = (char *)mnl_attr_get_str(
- nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
- }
-
open_json_object(NULL);
print_link(rd, idx, name, port, nla_line);
- res_print_uint(rd, "cm-idn", cm_idn,
+ res_print_u32(rd, "cm-idn", cm_idn,
nla_line[RDMA_NLDEV_ATTR_RES_CM_IDN]);
- res_print_uint(rd, "lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
+ res_print_u32(rd, "lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
if (nla_line[RDMA_NLDEV_ATTR_RES_TYPE])
print_qp_type(rd, type);
print_cm_id_state(rd, state);
print_ps(rd, ps);
- res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+ res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
print_comm(rd, comm, nla_line);
if (nla_line[RDMA_NLDEV_ATTR_RES_SRC_ADDR])
@@ -199,8 +200,7 @@ static int res_cm_id_line(struct rd *rd, const char *name, int idx,
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
-out: if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
- free(comm);
+out:
return MNL_CB_OK;
}
diff --git a/rdma/res-cq.c b/rdma/res-cq.c
index 9e7c4f512..2cfa4994e 100644
--- a/rdma/res-cq.c
+++ b/rdma/res-cq.c
@@ -84,8 +84,15 @@ static int res_cq_line(struct rd *rd, const char *name, int idx,
goto out;
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+ SPRINT_BUF(b);
+
pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
- comm = get_task_name(pid);
+ if (!get_task_name(pid, b, sizeof(b)))
+ comm = b;
+ } else if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+ /* discard const from mnl_attr_get_str */
+ comm = (char *)mnl_attr_get_str(
+ nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
}
if (rd_is_filtered_attr(rd, "pid", pid,
@@ -103,28 +110,22 @@ static int res_cq_line(struct rd *rd, const char *name, int idx,
nla_line[RDMA_NLDEV_ATTR_RES_CTXN]))
goto out;
- if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
- /* discard const from mnl_attr_get_str */
- comm = (char *)mnl_attr_get_str(
- nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
-
open_json_object(NULL);
print_dev(rd, idx, name);
- res_print_uint(rd, "cqn", cqn, nla_line[RDMA_NLDEV_ATTR_RES_CQN]);
- res_print_uint(rd, "cqe", cqe, nla_line[RDMA_NLDEV_ATTR_RES_CQE]);
- res_print_uint(rd, "users", users,
+ res_print_u32(rd, "cqn", cqn, nla_line[RDMA_NLDEV_ATTR_RES_CQN]);
+ res_print_u32(rd, "cqe", cqe, nla_line[RDMA_NLDEV_ATTR_RES_CQE]);
+ res_print_u64(rd, "users", users,
nla_line[RDMA_NLDEV_ATTR_RES_USECNT]);
print_poll_ctx(rd, poll_ctx, nla_line[RDMA_NLDEV_ATTR_RES_POLL_CTX]);
print_cq_dim_setting(rd, nla_line[RDMA_NLDEV_ATTR_DEV_DIM]);
- res_print_uint(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]);
- res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+ res_print_u32(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]);
+ res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
print_comm(rd, comm, nla_line);
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
-out: if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
- free(comm);
+out:
return MNL_CB_OK;
}
diff --git a/rdma/res-ctx.c b/rdma/res-ctx.c
index 30afe97ac..500186d9f 100644
--- a/rdma/res-ctx.c
+++ b/rdma/res-ctx.c
@@ -18,8 +18,15 @@ static int res_ctx_line(struct rd *rd, const char *name, int idx,
return MNL_CB_ERROR;
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+ SPRINT_BUF(b);
+
pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
- comm = get_task_name(pid);
+ if (!get_task_name(pid, b, sizeof(b)))
+ comm = b;
+ } else if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+ /* discard const from mnl_attr_get_str */
+ comm = (char *)mnl_attr_get_str(
+ nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
}
if (rd_is_filtered_attr(rd, "pid", pid,
@@ -33,23 +40,16 @@ static int res_ctx_line(struct rd *rd, const char *name, int idx,
nla_line[RDMA_NLDEV_ATTR_RES_CTXN]))
goto out;
- if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
- /* discard const from mnl_attr_get_str */
- comm = (char *)mnl_attr_get_str(
- nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
-
open_json_object(NULL);
print_dev(rd, idx, name);
- res_print_uint(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]);
- res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+ res_print_u32(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]);
+ res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
print_comm(rd, comm, nla_line);
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
out:
- if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
- free(comm);
return MNL_CB_OK;
}
diff --git a/rdma/res-mr.c b/rdma/res-mr.c
index 1bf73f3a8..fb48d5df6 100644
--- a/rdma/res-mr.c
+++ b/rdma/res-mr.c
@@ -47,8 +47,15 @@ static int res_mr_line(struct rd *rd, const char *name, int idx,
goto out;
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+ SPRINT_BUF(b);
+
pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
- comm = get_task_name(pid);
+ if (!get_task_name(pid, b, sizeof(b)))
+ comm = b;
+ } else if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+ /* discard const from mnl_attr_get_str */
+ comm = (char *)mnl_attr_get_str(
+ nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
}
if (rd_is_filtered_attr(rd, "pid", pid,
@@ -67,19 +74,15 @@ static int res_mr_line(struct rd *rd, const char *name, int idx,
nla_line[RDMA_NLDEV_ATTR_RES_PDN]))
goto out;
- if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
- /* discard const from mnl_attr_get_str */
- comm = (char *)mnl_attr_get_str(
- nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
open_json_object(NULL);
print_dev(rd, idx, name);
- res_print_uint(rd, "mrn", mrn, nla_line[RDMA_NLDEV_ATTR_RES_MRN]);
+ res_print_u32(rd, "mrn", mrn, nla_line[RDMA_NLDEV_ATTR_RES_MRN]);
print_key(rd, "rkey", rkey, nla_line[RDMA_NLDEV_ATTR_RES_RKEY]);
print_key(rd, "lkey", lkey, nla_line[RDMA_NLDEV_ATTR_RES_LKEY]);
print_key(rd, "iova", iova, nla_line[RDMA_NLDEV_ATTR_RES_IOVA]);
- res_print_uint(rd, "mrlen", mrlen, nla_line[RDMA_NLDEV_ATTR_RES_MRLEN]);
- res_print_uint(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
- res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+ res_print_u64(rd, "mrlen", mrlen, nla_line[RDMA_NLDEV_ATTR_RES_MRLEN]);
+ res_print_u32(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
+ res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
print_comm(rd, comm, nla_line);
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
@@ -87,8 +90,6 @@ static int res_mr_line(struct rd *rd, const char *name, int idx,
newline(rd);
out:
- if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
- free(comm);
return MNL_CB_OK;
}
diff --git a/rdma/res-pd.c b/rdma/res-pd.c
index df5380103..66f91f428 100644
--- a/rdma/res-pd.c
+++ b/rdma/res-pd.c
@@ -34,8 +34,15 @@ static int res_pd_line(struct rd *rd, const char *name, int idx,
nla_line[RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY]);
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+ SPRINT_BUF(b);
+
pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
- comm = get_task_name(pid);
+ if (!get_task_name(pid, b, sizeof(b)))
+ comm = b;
+ } else if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+ /* discard const from mnl_attr_get_str */
+ comm = (char *)mnl_attr_get_str(
+ nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
}
if (rd_is_filtered_attr(rd, "pid", pid,
@@ -55,29 +62,23 @@ static int res_pd_line(struct rd *rd, const char *name, int idx,
nla_line[RDMA_NLDEV_ATTR_RES_PDN]))
goto out;
- if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
- /* discard const from mnl_attr_get_str */
- comm = (char *)mnl_attr_get_str(
- nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
-
open_json_object(NULL);
print_dev(rd, idx, name);
- res_print_uint(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
+ res_print_u32(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
print_key(rd, "local_dma_lkey", local_dma_lkey,
nla_line[RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY]);
- res_print_uint(rd, "users", users,
+ res_print_u64(rd, "users", users,
nla_line[RDMA_NLDEV_ATTR_RES_USECNT]);
print_key(rd, "unsafe_global_rkey", unsafe_global_rkey,
nla_line[RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY]);
- res_print_uint(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]);
- res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+ res_print_u32(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]);
+ res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
print_comm(rd, comm, nla_line);
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
-out: if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
- free(comm);
+out:
return MNL_CB_OK;
}
diff --git a/rdma/res-qp.c b/rdma/res-qp.c
index a38be3995..c180a97e3 100644
--- a/rdma/res-qp.c
+++ b/rdma/res-qp.c
@@ -146,41 +146,41 @@ static int res_qp_line(struct rd *rd, const char *name, int idx,
goto out;
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+ SPRINT_BUF(b);
+
pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
- comm = get_task_name(pid);
+ if (!get_task_name(pid, b, sizeof(b)))
+ comm = b;
+ } else if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+ /* discard const from mnl_attr_get_str */
+ comm = (char *)mnl_attr_get_str(
+ nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
}
if (rd_is_filtered_attr(rd, "pid", pid,
nla_line[RDMA_NLDEV_ATTR_RES_PID]))
goto out;
- if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
- /* discard const from mnl_attr_get_str */
- comm = (char *)mnl_attr_get_str(
- nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
-
open_json_object(NULL);
print_link(rd, idx, name, port, nla_line);
- res_print_uint(rd, "lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
+ res_print_u32(rd, "lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]);
print_rqpn(rd, rqpn, nla_line);
print_type(rd, type);
print_state(rd, state);
print_rqpsn(rd, rq_psn, nla_line);
- res_print_uint(rd, "sq-psn", sq_psn,
+ res_print_u32(rd, "sq-psn", sq_psn,
nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN]);
print_pathmig(rd, path_mig_state, nla_line);
- res_print_uint(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
- res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+ res_print_u32(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
+ res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
print_comm(rd, comm, nla_line);
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
out:
- if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
- free(comm);
return MNL_CB_OK;
}
diff --git a/rdma/res-srq.c b/rdma/res-srq.c
index 3038c3522..186ae281d 100644
--- a/rdma/res-srq.c
+++ b/rdma/res-srq.c
@@ -174,9 +174,17 @@ static int res_srq_line(struct rd *rd, const char *name, int idx,
return MNL_CB_ERROR;
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+ SPRINT_BUF(b);
+
pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
- comm = get_task_name(pid);
+ if (!get_task_name(pid, b, sizeof(b)))
+ comm = b;
+ } else if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+ /* discard const from mnl_attr_get_str */
+ comm = (char *)mnl_attr_get_str(
+ nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
}
+
if (rd_is_filtered_attr(rd, "pid", pid,
nla_line[RDMA_NLDEV_ATTR_RES_PID]))
goto out;
@@ -209,27 +217,20 @@ static int res_srq_line(struct rd *rd, const char *name, int idx,
MNL_CB_OK)
goto out;
- if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
- /* discard const from mnl_attr_get_str */
- comm = (char *)mnl_attr_get_str(
- nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
-
open_json_object(NULL);
print_dev(rd, idx, name);
- res_print_uint(rd, "srqn", srqn, nla_line[RDMA_NLDEV_ATTR_RES_SRQN]);
+ res_print_u32(rd, "srqn", srqn, nla_line[RDMA_NLDEV_ATTR_RES_SRQN]);
print_type(rd, type);
print_qps(qp_str);
- res_print_uint(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
- res_print_uint(rd, "cqn", cqn, nla_line[RDMA_NLDEV_ATTR_RES_CQN]);
- res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+ res_print_u32(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]);
+ res_print_u32(rd, "cqn", cqn, nla_line[RDMA_NLDEV_ATTR_RES_CQN]);
+ res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
print_comm(rd, comm, nla_line);
print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]);
newline(rd);
out:
- if (nla_line[RDMA_NLDEV_ATTR_RES_PID])
- free(comm);
return MNL_CB_OK;
}
diff --git a/rdma/res.c b/rdma/res.c
index 21fef9bdd..854f21c7c 100644
--- a/rdma/res.c
+++ b/rdma/res.c
@@ -51,7 +51,7 @@ static int res_print_summary(struct rd *rd, struct nlattr **tb)
name = mnl_attr_get_str(nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME]);
curr = mnl_attr_get_u64(nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]);
- res_print_uint(
+ res_print_u64(
rd, name, curr,
nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]);
}
@@ -208,13 +208,22 @@ void print_key(struct rd *rd, const char *name, uint64_t val,
print_color_hex(PRINT_ANY, COLOR_NONE, name, " 0x%" PRIx64 " ", val);
}
-void res_print_uint(struct rd *rd, const char *name, uint64_t val,
+void res_print_u32(struct rd *rd, const char *name, uint32_t val,
struct nlattr *nlattr)
{
if (!nlattr)
return;
print_color_uint(PRINT_ANY, COLOR_NONE, name, name, val);
- print_color_uint(PRINT_FP, COLOR_NONE, NULL, " %d ", val);
+ print_color_uint(PRINT_FP, COLOR_NONE, NULL, " %" PRIu32 " ", val);
+}
+
+void res_print_u64(struct rd *rd, const char *name, uint64_t val,
+ struct nlattr *nlattr)
+{
+ if (!nlattr)
+ return;
+ print_color_u64(PRINT_ANY, COLOR_NONE, name, name, val);
+ print_color_u64(PRINT_FP, COLOR_NONE, NULL, " %" PRIu64 " ", val);
}
RES_FUNC(res_no_args, RDMA_NLDEV_CMD_RES_GET, NULL, true, 0);
diff --git a/rdma/res.h b/rdma/res.h
index 58fa6ad1c..70e51acd0 100644
--- a/rdma/res.h
+++ b/rdma/res.h
@@ -188,7 +188,9 @@ void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port,
struct nlattr **nla_line);
void print_key(struct rd *rd, const char *name, uint64_t val,
struct nlattr *nlattr);
-void res_print_uint(struct rd *rd, const char *name, uint64_t val,
+void res_print_u32(struct rd *rd, const char *name, uint32_t val,
+ struct nlattr *nlattr);
+void res_print_u64(struct rd *rd, const char *name, uint64_t val,
struct nlattr *nlattr);
void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line);
const char *qp_types_to_str(uint8_t idx);
diff --git a/rdma/stat-mr.c b/rdma/stat-mr.c
index f39526b48..2ba6cb076 100644
--- a/rdma/stat-mr.c
+++ b/rdma/stat-mr.c
@@ -22,7 +22,7 @@ static int stat_mr_line(struct rd *rd, const char *name, int idx,
open_json_object(NULL);
print_dev(rd, idx, name);
- res_print_uint(rd, "mrn", mrn, nla_line[RDMA_NLDEV_ATTR_RES_MRN]);
+ res_print_u32(rd, "mrn", mrn, nla_line[RDMA_NLDEV_ATTR_RES_MRN]);
if (nla_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS]) {
ret = res_get_hwcounters(
diff --git a/rdma/stat.c b/rdma/stat.c
index adfcd34af..aad8815ce 100644
--- a/rdma/stat.c
+++ b/rdma/stat.c
@@ -210,7 +210,7 @@ int res_get_hwcounters(struct rd *rd, struct nlattr *hwc_table, bool print)
v = mnl_attr_get_u64(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE]);
if (rd->pretty_output && !rd->json_output)
newline_indent(rd);
- res_print_uint(rd, nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]);
+ res_print_u64(rd, nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]);
}
return MNL_CB_OK;
@@ -248,17 +248,21 @@ static int res_counter_line(struct rd *rd, const char *name, int index,
return MNL_CB_OK;
if (nla_line[RDMA_NLDEV_ATTR_RES_PID]) {
+ SPRINT_BUF(b);
+
pid = mnl_attr_get_u32(nla_line[RDMA_NLDEV_ATTR_RES_PID]);
- comm = get_task_name(pid);
+ if (!get_task_name(pid, b, sizeof(b)))
+ comm = b;
+ } else if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]) {
+ /* discard const from mnl_attr_get_str */
+ comm = (char *)mnl_attr_get_str(
+ nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
}
+
if (rd_is_filtered_attr(rd, "pid", pid,
nla_line[RDMA_NLDEV_ATTR_RES_PID]))
return MNL_CB_OK;
- if (nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME])
- comm = (char *)mnl_attr_get_str(
- nla_line[RDMA_NLDEV_ATTR_RES_KERN_NAME]);
-
mnl_attr_for_each_nested(nla_entry, qp_table) {
struct nlattr *qp_line[RDMA_NLDEV_ATTR_MAX] = {};
@@ -283,7 +287,7 @@ static int res_counter_line(struct rd *rd, const char *name, int index,
print_color_uint(PRINT_ANY, COLOR_NONE, "cntn", "cntn %u ", cntn);
if (nla_line[RDMA_NLDEV_ATTR_RES_TYPE])
print_qp_type(rd, qp_type);
- res_print_uint(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
+ res_print_u64(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]);
print_comm(rd, comm, nla_line);
res_get_hwcounters(rd, hwc_table, true);
isfirst = true;
diff --git a/vdpa/include/uapi/linux/vdpa.h b/vdpa/include/uapi/linux/vdpa.h
index b7eab0699..cc575a825 100644
--- a/vdpa/include/uapi/linux/vdpa.h
+++ b/vdpa/include/uapi/linux/vdpa.h
@@ -23,6 +23,9 @@ enum vdpa_command {
enum vdpa_attr {
VDPA_ATTR_UNSPEC,
+ /* Pad attribute for 64b alignment */
+ VDPA_ATTR_PAD = VDPA_ATTR_UNSPEC,
+
/* bus name (optional) + dev name together make the parent device handle */
VDPA_ATTR_MGMTDEV_BUS_NAME, /* string */
VDPA_ATTR_MGMTDEV_DEV_NAME, /* string */
@@ -40,6 +43,9 @@ enum vdpa_attr {
VDPA_ATTR_DEV_NET_CFG_MAX_VQP, /* u16 */
VDPA_ATTR_DEV_NET_CFG_MTU, /* u16 */
+ VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */
+ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS, /* u32 */
+ VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */
/* new attributes must be added above here */
VDPA_ATTR_MAX,
};