Merge branch 'main' into next

Signed-off-by: David Ahern <dsahern@kernel.org>
This commit is contained in:
David Ahern 2021-04-28 15:48:28 +00:00
commit e1e089d1f2
15 changed files with 166 additions and 41 deletions

View File

@ -917,7 +917,13 @@ static int strtobool(const char *str, bool *p_val)
static int __dl_argv_handle(char *str, char **p_bus_name, char **p_dev_name)
{
str_split_by_char(str, p_bus_name, p_dev_name, '/');
int err;
err = str_split_by_char(str, p_bus_name, p_dev_name, '/');
if (err) {
pr_err("Devlink identification (\"bus_name/dev_name\") \"%s\" is invalid\n", str);
return err;
}
return 0;
}

40
include/uapi/linux/vdpa.h Normal file
View File

@ -0,0 +1,40 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* vdpa device management interface
* Copyright (c) 2020 Mellanox Technologies Ltd. All rights reserved.
*/
#ifndef _LINUX_VDPA_H_
#define _LINUX_VDPA_H_
#define VDPA_GENL_NAME "vdpa"
#define VDPA_GENL_VERSION 0x1
enum vdpa_command {
VDPA_CMD_UNSPEC,
VDPA_CMD_MGMTDEV_NEW,
VDPA_CMD_MGMTDEV_GET, /* can dump */
VDPA_CMD_DEV_NEW,
VDPA_CMD_DEV_DEL,
VDPA_CMD_DEV_GET, /* can dump */
};
enum vdpa_attr {
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 */
VDPA_ATTR_MGMTDEV_SUPPORTED_CLASSES, /* u64 */
VDPA_ATTR_DEV_NAME, /* string */
VDPA_ATTR_DEV_ID, /* u32 */
VDPA_ATTR_DEV_VENDOR_ID, /* u32 */
VDPA_ATTR_DEV_MAX_VQS, /* u32 */
VDPA_ATTR_DEV_MAX_VQ_SIZE, /* u16 */
/* new attributes must be added above here */
VDPA_ATTR_MAX,
};
#endif

View File

@ -0,0 +1,58 @@
#ifndef _LINUX_VIRTIO_IDS_H
#define _LINUX_VIRTIO_IDS_H
/*
* Virtio IDs
*
* This header is BSD licensed so anyone can use the definitions to implement
* compatible drivers/servers.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of IBM nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. */
#define VIRTIO_ID_NET 1 /* virtio net */
#define VIRTIO_ID_BLOCK 2 /* virtio block */
#define VIRTIO_ID_CONSOLE 3 /* virtio console */
#define VIRTIO_ID_RNG 4 /* virtio rng */
#define VIRTIO_ID_BALLOON 5 /* virtio balloon */
#define VIRTIO_ID_IOMEM 6 /* virtio ioMemory */
#define VIRTIO_ID_RPMSG 7 /* virtio remote processor messaging */
#define VIRTIO_ID_SCSI 8 /* virtio scsi */
#define VIRTIO_ID_9P 9 /* 9p virtio console */
#define VIRTIO_ID_MAC80211_WLAN 10 /* virtio WLAN MAC */
#define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */
#define VIRTIO_ID_CAIF 12 /* Virtio caif */
#define VIRTIO_ID_MEMORY_BALLOON 13 /* virtio memory balloon */
#define VIRTIO_ID_GPU 16 /* virtio GPU */
#define VIRTIO_ID_CLOCK 17 /* virtio clock/timer */
#define VIRTIO_ID_INPUT 18 /* virtio input */
#define VIRTIO_ID_VSOCK 19 /* virtio vsock transport */
#define VIRTIO_ID_CRYPTO 20 /* virtio crypto */
#define VIRTIO_ID_SIGNAL_DIST 21 /* virtio signal distribution device */
#define VIRTIO_ID_PSTORE 22 /* virtio pstore device */
#define VIRTIO_ID_IOMMU 23 /* virtio IOMMU */
#define VIRTIO_ID_MEM 24 /* virtio mem */
#define VIRTIO_ID_FS 26 /* virtio filesystem */
#define VIRTIO_ID_PMEM 27 /* virtio pmem */
#define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */
#endif /* _LINUX_VIRTIO_IDS_H */

View File

@ -1 +1 @@
static const char version[] = "5.11.0";
static const char version[] = "5.12.0";

View File

@ -157,6 +157,7 @@ static int batch(const char *name)
return EXIT_FAILURE;
}
batch_mode = 1;
ret = do_batch(name, force, ip_batch_cmd, &orig_family);
rtnl_close(&rth);

View File

@ -579,18 +579,18 @@ static int netns_pids(int argc, char **argv)
{
const char *name;
char net_path[PATH_MAX];
int netns;
int netns = -1, ret = -1;
struct stat netst;
DIR *dir;
struct dirent *entry;
if (argc < 1) {
fprintf(stderr, "No netns name specified\n");
return -1;
goto out;
}
if (argc > 1) {
fprintf(stderr, "extra arguments specified\n");
return -1;
goto out;
}
name = argv[0];
@ -599,18 +599,18 @@ static int netns_pids(int argc, char **argv)
if (netns < 0) {
fprintf(stderr, "Cannot open network namespace: %s\n",
strerror(errno));
return -1;
goto out;
}
if (fstat(netns, &netst) < 0) {
fprintf(stderr, "Stat of netns failed: %s\n",
strerror(errno));
return -1;
goto out;
}
dir = opendir("/proc/");
if (!dir) {
fprintf(stderr, "Open of /proc failed: %s\n",
strerror(errno));
return -1;
goto out;
}
while ((entry = readdir(dir))) {
char pid_net_path[PATH_MAX];
@ -627,15 +627,19 @@ static int netns_pids(int argc, char **argv)
printf("%s\n", entry->d_name);
}
}
ret = 0;
closedir(dir);
return 0;
out:
if (netns >= 0)
close(netns);
return ret;
}
int netns_identify_pid(const char *pidstr, char *name, int len)
{
char net_path[PATH_MAX];
int netns;
int netns = -1, ret = -1;
struct stat netst;
DIR *dir;
struct dirent *entry;
@ -647,22 +651,24 @@ int netns_identify_pid(const char *pidstr, char *name, int len)
if (netns < 0) {
fprintf(stderr, "Cannot open network namespace: %s\n",
strerror(errno));
return -1;
goto out;
}
if (fstat(netns, &netst) < 0) {
fprintf(stderr, "Stat of netns failed: %s\n",
strerror(errno));
return -1;
goto out;
}
dir = opendir(NETNS_RUN_DIR);
if (!dir) {
/* Succeed treat a missing directory as an empty directory */
if (errno == ENOENT)
return 0;
if (errno == ENOENT) {
ret = 0;
goto out;
}
fprintf(stderr, "Failed to open directory %s:%s\n",
NETNS_RUN_DIR, strerror(errno));
return -1;
goto out;
}
while ((entry = readdir(dir))) {
@ -685,8 +691,12 @@ int netns_identify_pid(const char *pidstr, char *name, int len)
strlcpy(name, entry->d_name, len);
}
}
ret = 0;
closedir(dir);
return 0;
out:
if (netns >= 0)
close(netns);
return ret;
}

View File

@ -454,8 +454,9 @@ int print_nexthop_bucket(struct nlmsghdr *n, void *arg)
static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
{
struct nexthop_grp *grps;
struct nexthop_grp *grps = NULL;
int count = 0, i;
int err = -1;
char *sep, *wsep;
if (*argv != '\0')
@ -469,11 +470,11 @@ static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
}
if (count == 0)
return -1;
goto out;
grps = calloc(count, sizeof(*grps));
if (!grps)
return -1;
goto out;
for (i = 0; i < count; ++i) {
sep = strchr(argv, '/');
@ -485,7 +486,7 @@ static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
*wsep = '\0';
if (get_unsigned(&grps[i].id, argv, 0))
return -1;
goto out;
if (wsep) {
unsigned int w;
@ -501,7 +502,10 @@ static int add_nh_group_attr(struct nlmsghdr *n, int maxlen, char *argv)
argv = sep + 1;
}
return addattr_l(n, maxlen, NHA_GROUP, grps, count * sizeof(*grps));
err = addattr_l(n, maxlen, NHA_GROUP, grps, count * sizeof(*grps));
out:
free(grps);
return err;
}
static int read_nh_group_type(const char *name)

View File

@ -536,10 +536,10 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (erspan_dir == 0)
print_string(PRINT_ANY, "erspan_dir",
"erspan_dir ingress ", NULL);
"erspan_dir %s ", "ingress");
else
print_string(PRINT_ANY, "erspan_dir",
"erspan_dir egress ", NULL);
"erspan_dir %s ", "egress");
}
if (tb[IFLA_GRE_ERSPAN_HWID]) {

View File

@ -594,10 +594,10 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
if (erspan_dir == 0)
print_string(PRINT_ANY, "erspan_dir",
"erspan_dir ingress ", NULL);
"erspan_dir %s ", "ingress");
else
print_string(PRINT_ANY, "erspan_dir",
"erspan_dir egress ", NULL);
"erspan_dir %s ", "egress");
}
if (tb[IFLA_GRE_ERSPAN_HWID]) {

View File

@ -2832,7 +2832,7 @@ static void bpf_get_cfg(struct bpf_elf_ctx *ctx)
int fd;
fd = open(path_jit, O_RDONLY);
if (fd > 0) {
if (fd >= 0) {
char tmp[16] = {};
if (read(fd, tmp, sizeof(tmp)) > 0)
@ -3092,13 +3092,13 @@ int bpf_send_map_fds(const char *path, const char *obj)
.st = &ctx->stat,
.obj = obj,
};
int fd, ret;
int fd, ret = -1;
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
fprintf(stderr, "Cannot open socket: %s\n",
strerror(errno));
return -1;
goto out;
}
strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
@ -3107,7 +3107,7 @@ int bpf_send_map_fds(const char *path, const char *obj)
if (ret < 0) {
fprintf(stderr, "Cannot connect to %s: %s\n",
path, strerror(errno));
return -1;
goto out;
}
ret = bpf_map_set_send(fd, &addr, sizeof(addr), &bpf_aux,
@ -3117,6 +3117,8 @@ int bpf_send_map_fds(const char *path, const char *obj)
path, strerror(errno));
bpf_maps_teardown(ctx);
out:
if (fd >= 0)
close(fd);
return ret;
}
@ -3125,13 +3127,13 @@ int bpf_recv_map_fds(const char *path, int *fds, struct bpf_map_aux *aux,
unsigned int entries)
{
struct sockaddr_un addr = { .sun_family = AF_UNIX };
int fd, ret;
int fd, ret = -1;
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
if (fd < 0) {
fprintf(stderr, "Cannot open socket: %s\n",
strerror(errno));
return -1;
goto out;
}
strlcpy(addr.sun_path, path, sizeof(addr.sun_path));
@ -3140,7 +3142,7 @@ int bpf_recv_map_fds(const char *path, int *fds, struct bpf_map_aux *aux,
if (ret < 0) {
fprintf(stderr, "Cannot bind to socket: %s\n",
strerror(errno));
return -1;
goto out;
}
ret = bpf_map_set_recv(fd, fds, aux, entries);
@ -3149,6 +3151,9 @@ int bpf_recv_map_fds(const char *path, int *fds, struct bpf_map_aux *aux,
path, strerror(errno));
unlink(addr.sun_path);
out:
if (fd >= 0)
close(fd);
return ret;
}

View File

@ -307,7 +307,7 @@ static int stat_qp_show_parse_cb(const struct nlmsghdr *nlh, void *data)
struct rd *rd = data;
const char *name;
uint32_t idx;
int ret;
int ret = MNL_CB_OK;
mnl_attr_parse(nlh, 0, rd_attr_cb, tb);
if (!tb[RDMA_NLDEV_ATTR_DEV_INDEX] || !tb[RDMA_NLDEV_ATTR_DEV_NAME] ||

View File

@ -159,7 +159,9 @@ static int parse_bpf(struct exec_util *eu, int argc, char **argv)
envp_run[env_num - 1] = NULL;
out:
return execvpe(argv_run[0], argv_run, envp_run);
ret = execvpe(argv_run[0], argv_run, envp_run);
free(envp_run);
return ret;
err_free_env:
for (--i; i >= env_old; i--)

View File

@ -299,8 +299,7 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
NEXT_ARG();
overhead = strtol(*argv, &p, 10);
if (!p || *p || !*argv ||
overhead < -64 || overhead > 256) {
if (!p || *p || overhead < -64 || overhead > 256) {
fprintf(stderr,
"Illegal \"overhead\", valid range is -64 to 256\\n");
return -1;
@ -312,7 +311,7 @@ static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
NEXT_ARG();
mpu = strtol(*argv, &p, 10);
if (!p || *p || !*argv || mpu < 0 || mpu > 256) {
if (!p || *p || mpu < 0 || mpu > 256) {
fprintf(stderr,
"Illegal \"mpu\", valid range is 0 to 256\\n");
return -1;