From d3740fdc2671dd4039779cd7562c7f09cc1c6a48 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 17 May 2021 07:10:10 +0200 Subject: [PATCH 01/10] libgenl: make genl_add_mcast_grp set errno on error genl_add_mcast_grp doesn't set errno in all cases. On kernels that support mptcp but lack event support (all kernels <= 5.11) MPTCP_PM_EV_GRP_NAME won't be found and ip will exit with "can't subscribe to mptcp events: Success" Set errno to a meaningful value (ENOENT) when the group name isn't found and also cover other spots where it returns nonzero with errno unset. Fixes: ff619e4fd370 ("mptcp: add support for event monitoring") Signed-off-by: Florian Westphal Reviewed-by: David Ahern Signed-off-by: Stephen Hemminger --- lib/libgenl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/libgenl.c b/lib/libgenl.c index 4c51d47a..fca07f9f 100644 --- a/lib/libgenl.c +++ b/lib/libgenl.c @@ -3,6 +3,7 @@ * libgenl.c GENL library */ +#include #include #include #include @@ -84,6 +85,7 @@ static int genl_parse_grps(struct rtattr *attr, const char *name, unsigned int * } } + errno = ENOENT; return -1; } @@ -108,17 +110,22 @@ int genl_add_mcast_grp(struct rtnl_handle *grth, __u16 fnum, const char *group) ghdr = NLMSG_DATA(answer); len = answer->nlmsg_len; - if (answer->nlmsg_type != GENL_ID_CTRL) + if (answer->nlmsg_type != GENL_ID_CTRL) { + errno = EINVAL; goto err_free; + } len -= NLMSG_LENGTH(GENL_HDRLEN); - if (len < 0) + if (len < 0) { + errno = EINVAL; goto err_free; + } attrs = (struct rtattr *) ((char *) ghdr + GENL_HDRLEN); parse_rtattr(tb, CTRL_ATTR_MAX, attrs, len); if (tb[CTRL_ATTR_MCAST_GROUPS] == NULL) { + errno = ENOENT; fprintf(stderr, "Missing mcast groups TLV\n"); goto err_free; } From 9d9b1a84a5a4f92c9f99ac3e0c10be6d30bfbef1 Mon Sep 17 00:00:00 2001 From: Roman Mashak Date: Fri, 28 May 2021 16:05:21 -0400 Subject: [PATCH 02/10] ss: update ss man page '-b' option allows to request BPF filter opcodes, however currently the kernel returns only classic BPF filter, so reflect this in man page. Signed-off-by: Roman Mashak Signed-off-by: Stephen Hemminger --- man/man8/ss.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/man8/ss.8 b/man/man8/ss.8 index 42aac6de..d399381d 100644 --- a/man/man8/ss.8 +++ b/man/man8/ss.8 @@ -343,7 +343,7 @@ and is therefore a useful reference. Switch to the specified network namespace name. .TP .B \-b, \-\-bpf -Show socket BPF filters (only administrators are allowed to get these +Show socket classic BPF filters (only administrators are allowed to get these information). .TP .B \-4, \-\-ipv4 From e1d3ac755d37fd7b899c176f168e05fd826a7233 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 17 Jun 2021 15:54:05 -0700 Subject: [PATCH 03/10] uapi: update kernel headers to 5.13-rc6 Signed-off-by: Stephen Hemminger --- include/uapi/linux/bpf.h | 67 +++++++++++++++++++++++++++++++++ include/uapi/linux/if_bonding.h | 11 ------ include/uapi/linux/if_link.h | 1 + include/uapi/linux/seg6_local.h | 30 +++++++++++++++ include/uapi/linux/virtio_ids.h | 2 + 5 files changed, 100 insertions(+), 11 deletions(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 793655ed..33abd855 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -312,6 +312,27 @@ union bpf_iter_link_info { * *ctx_out*, *data_out* (for example, packet data), result of the * execution *retval*, and *duration* of the test run. * + * The sizes of the buffers provided as input and output + * parameters *ctx_in*, *ctx_out*, *data_in*, and *data_out* must + * be provided in the corresponding variables *ctx_size_in*, + * *ctx_size_out*, *data_size_in*, and/or *data_size_out*. If any + * of these parameters are not provided (ie set to NULL), the + * corresponding size field must be zero. + * + * Some program types have particular requirements: + * + * **BPF_PROG_TYPE_SK_LOOKUP** + * *data_in* and *data_out* must be NULL. + * + * **BPF_PROG_TYPE_XDP** + * *ctx_in* and *ctx_out* must be NULL. + * + * **BPF_PROG_TYPE_RAW_TRACEPOINT**, + * **BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE** + * + * *ctx_out*, *data_in* and *data_out* must be NULL. + * *repeat* must be zero. + * * Return * Returns zero on success. On error, -1 is returned and *errno* * is set appropriately. @@ -4061,12 +4082,20 @@ union bpf_attr { * of new data availability is sent. * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification * of new data availability is sent unconditionally. + * If **0** is specified in *flags*, an adaptive notification + * of new data availability is sent. + * + * An adaptive notification is a notification sent whenever the user-space + * process has caught up and consumed all available payloads. In case the user-space + * process is still processing a previous payload, then no notification is needed + * as it will process the newly added payload automatically. * Return * 0 on success, or a negative error in case of failure. * * void *bpf_ringbuf_reserve(void *ringbuf, u64 size, u64 flags) * Description * Reserve *size* bytes of payload in a ring buffer *ringbuf*. + * *flags* must be 0. * Return * Valid pointer with *size* bytes of memory available; NULL, * otherwise. @@ -4078,6 +4107,10 @@ union bpf_attr { * of new data availability is sent. * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification * of new data availability is sent unconditionally. + * If **0** is specified in *flags*, an adaptive notification + * of new data availability is sent. + * + * See 'bpf_ringbuf_output()' for the definition of adaptive notification. * Return * Nothing. Always succeeds. * @@ -4088,6 +4121,10 @@ union bpf_attr { * of new data availability is sent. * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification * of new data availability is sent unconditionally. + * If **0** is specified in *flags*, an adaptive notification + * of new data availability is sent. + * + * See 'bpf_ringbuf_output()' for the definition of adaptive notification. * Return * Nothing. Always succeeds. * @@ -4671,6 +4708,33 @@ union bpf_attr { * Return * The number of traversed map elements for success, **-EINVAL** for * invalid **flags**. + * + * long bpf_snprintf(char *str, u32 str_size, const char *fmt, u64 *data, u32 data_len) + * Description + * Outputs a string into the **str** buffer of size **str_size** + * based on a format string stored in a read-only map pointed by + * **fmt**. + * + * Each format specifier in **fmt** corresponds to one u64 element + * in the **data** array. For strings and pointers where pointees + * are accessed, only the pointer values are stored in the *data* + * array. The *data_len* is the size of *data* in bytes. + * + * Formats **%s** and **%p{i,I}{4,6}** require to read kernel + * memory. Reading kernel memory may fail due to either invalid + * address or valid address but requiring a major memory fault. If + * reading kernel memory fails, the string for **%s** will be an + * empty string, and the ip address for **%p{i,I}{4,6}** will be 0. + * Not returning error to bpf program is consistent with what + * **bpf_trace_printk**\ () does for now. + * + * Return + * The strictly positive length of the formatted string, including + * the trailing zero character. If the return value is greater than + * **str_size**, **str** contains a truncated string, guaranteed to + * be zero-terminated except when **str_size** is 0. + * + * Or **-EBUSY** if the per-CPU memory copy buffer is busy. */ #define __BPF_FUNC_MAPPER(FN) \ FN(unspec), \ @@ -4838,6 +4902,7 @@ union bpf_attr { FN(sock_from_file), \ FN(check_mtu), \ FN(for_each_map_elem), \ + FN(snprintf), \ /* */ /* integer value in 'imm' field of BPF_CALL instruction selects which helper @@ -5379,6 +5444,8 @@ struct bpf_link_info { } raw_tracepoint; struct { __u32 attach_type; + __u32 target_obj_id; /* prog_id for PROG_EXT, otherwise btf object id */ + __u32 target_btf_id; /* BTF type id inside the object */ } tracing; struct { __u64 cgroup_id; diff --git a/include/uapi/linux/if_bonding.h b/include/uapi/linux/if_bonding.h index e8eb4ad0..d174914a 100644 --- a/include/uapi/linux/if_bonding.h +++ b/include/uapi/linux/if_bonding.h @@ -153,14 +153,3 @@ enum { #define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1) #endif /* _LINUX_IF_BONDING_H */ - -/* - * Local variables: - * version-control: t - * kept-new-versions: 5 - * c-indent-level: 8 - * c-basic-offset: 8 - * tab-width: 8 - * End: - */ - diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 50193377..0e81707a 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -612,6 +612,7 @@ enum macvlan_macaddr_mode { }; #define MACVLAN_FLAG_NOPROMISC 1 +#define MACVLAN_FLAG_NODST 2 /* skip dst macvlan if matching src macvlan */ /* VRF section */ enum { diff --git a/include/uapi/linux/seg6_local.h b/include/uapi/linux/seg6_local.h index bb5c8ddf..85955514 100644 --- a/include/uapi/linux/seg6_local.h +++ b/include/uapi/linux/seg6_local.h @@ -27,6 +27,7 @@ enum { SEG6_LOCAL_OIF, SEG6_LOCAL_BPF, SEG6_LOCAL_VRFTABLE, + SEG6_LOCAL_COUNTERS, __SEG6_LOCAL_MAX, }; #define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1) @@ -78,4 +79,33 @@ enum { #define SEG6_LOCAL_BPF_PROG_MAX (__SEG6_LOCAL_BPF_PROG_MAX - 1) +/* SRv6 Behavior counters are encoded as netlink attributes guaranteeing the + * correct alignment. + * Each counter is identified by a different attribute type (i.e. + * SEG6_LOCAL_CNT_PACKETS). + * + * - SEG6_LOCAL_CNT_PACKETS: identifies a counter that counts the number of + * packets that have been CORRECTLY processed by an SRv6 Behavior instance + * (i.e., packets that generate errors or are dropped are NOT counted). + * + * - SEG6_LOCAL_CNT_BYTES: identifies a counter that counts the total amount + * of traffic in bytes of all packets that have been CORRECTLY processed by + * an SRv6 Behavior instance (i.e., packets that generate errors or are + * dropped are NOT counted). + * + * - SEG6_LOCAL_CNT_ERRORS: identifies a counter that counts the number of + * packets that have NOT been properly processed by an SRv6 Behavior instance + * (i.e., packets that generate errors or are dropped). + */ +enum { + SEG6_LOCAL_CNT_UNSPEC, + SEG6_LOCAL_CNT_PAD, /* pad for 64 bits values */ + SEG6_LOCAL_CNT_PACKETS, + SEG6_LOCAL_CNT_BYTES, + SEG6_LOCAL_CNT_ERRORS, + __SEG6_LOCAL_CNT_MAX, +}; + +#define SEG6_LOCAL_CNT_MAX (__SEG6_LOCAL_CNT_MAX - 1) + #endif diff --git a/include/uapi/linux/virtio_ids.h b/include/uapi/linux/virtio_ids.h index bc1c0621..4fe842c3 100644 --- a/include/uapi/linux/virtio_ids.h +++ b/include/uapi/linux/virtio_ids.h @@ -51,8 +51,10 @@ #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_SOUND 25 /* virtio sound */ #define VIRTIO_ID_FS 26 /* virtio filesystem */ #define VIRTIO_ID_PMEM 27 /* virtio pmem */ #define VIRTIO_ID_MAC80211_HWSIM 29 /* virtio mac80211-hwsim */ +#define VIRTIO_ID_BT 40 /* virtio bluetooth */ #endif /* _LINUX_VIRTIO_IDS_H */ From 8316825a52398ff8509107f7819a6e7ee820e0b4 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 24 Jun 2021 11:51:15 -0700 Subject: [PATCH 04/10] man: fix syntax for ip link property The ip link property add/delete requires a device; but the device argument was not show on the man page. It is correct in the usage message. Fixes: 3aa0e51be64b ("ip: add support for alternative name addition/deletion/list") Signed-off-by: Stephen Hemminger --- man/man8/ip-link.8.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index fd67e611..76d40b72 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -251,12 +251,12 @@ ip-link \- network device configuration .in -8 .ti -8 -.BI "ip link property add" +.BI "ip link property add dev " DEVICE .RB "[ " altname .IR NAME " .. ]" .ti -8 -.BI "ip link property del" +.BI "ip link property del dev " DEVICE .RB "[ " altname .IR NAME " .. ]" From 6f15c217198c4137f8a5cb329955543d30e4ee23 Mon Sep 17 00:00:00 2001 From: Roi Dayan Date: Tue, 22 Jun 2021 08:42:50 +0300 Subject: [PATCH 05/10] devlink: Fix link errors on some systems On some systems we fail to link because of missing math lib. add -lm to devlink. LINK devlink ../lib/libutil.a(utils_math.o): In function `get_rate': utils_math.c:(.text+0xcc): undefined reference to `floor' ../lib/libutil.a(utils_math.o): In function `get_size': utils_math.c:(.text+0x384): undefined reference to `floor' collect2: error: ld returned 1 exit status make[1]: *** [Makefile:16: devlink] Error 1 make: *** [Makefile:64: all] Error 2 Fixes: 6c70aca76ef2 ("devlink: Add port func rate support") Signed-off-by: Roi Dayan Signed-off-by: Stephen Hemminger --- devlink/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/devlink/Makefile b/devlink/Makefile index d540feb3..d37a4b4d 100644 --- a/devlink/Makefile +++ b/devlink/Makefile @@ -7,6 +7,7 @@ ifeq ($(HAVE_MNL),y) DEVLINKOBJ = devlink.o mnlg.o TARGETS += devlink +LDLIBS += -lm endif From c73fb6607025b7806c636fd52c6b2954388beb41 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 28 Jun 2021 10:19:08 -0700 Subject: [PATCH 06/10] uapi: update headers to 5.13 Final 5.13 header update Signed-off-by: Stephen Hemminger --- include/uapi/linux/in.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h index 32cf55c8..5b15419d 100644 --- a/include/uapi/linux/in.h +++ b/include/uapi/linux/in.h @@ -289,6 +289,9 @@ struct sockaddr_in { /* Address indicating an error return. */ #define INADDR_NONE ((unsigned long int) 0xffffffff) +/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ +#define INADDR_DUMMY ((unsigned long int) 0xc0000008) + /* Network number for local host loopback. */ #define IN_LOOPBACKNET 127 From 4ac0383a598d4bddf13cbd8272f0ea7711614b79 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 29 Jun 2021 01:24:46 +0200 Subject: [PATCH 07/10] utils: Fix BIT() to support up to 64 bits on all architectures devlink and vdpa use BIT() together with 64-bit flag fields. devlink is already using bit numbers greater than 31 and so does not work correctly on 32-bit architectures. Fix this by making BIT() use uint64_t instead of unsigned long. Signed-off-by: Ben Hutchings Signed-off-by: Stephen Hemminger --- include/utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/utils.h b/include/utils.h index 187444d5..70db9f60 100644 --- a/include/utils.h +++ b/include/utils.h @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef HAVE_LIBBSD #include @@ -264,7 +265,7 @@ void print_nlmsg_timestamp(FILE *fp, const struct nlmsghdr *n); unsigned int print_name_and_link(const char *fmt, const char *name, struct rtattr *tb[]); -#define BIT(nr) (1UL << (nr)) +#define BIT(nr) (UINT64_C(1) << (nr)) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) From 33cf9306c824c29c57879fd5182f7a09696af750 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 29 Jun 2021 01:25:59 +0200 Subject: [PATCH 08/10] devlink: Fix printf() type mismatches on 32-bit architectures devlink currently uses "%lu" to format values of type uint64_t, but on 32-bit architectures uint64_t is defined as unsigned long long and this does not work correctly. Fix this by using the standard macro PRIu64 instead. Signed-off-by: Ben Hutchings Signed-off-by: Stephen Hemminger --- devlink/devlink.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 0b5548fb..5db709cc 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -3546,7 +3546,7 @@ static int cmd_dev_flash_status_cb(const struct nlmsghdr *nlh, void *data) } } if (total) { - pr_out_tty(" %3lu%%", (done * 100) / total); + pr_out_tty(" %3"PRIu64"%%", (done * 100) / total); ctx->last_pc = 1; } else { ctx->last_pc = 0; @@ -3601,7 +3601,7 @@ static void cmd_dev_flash_time_elapsed(struct cmd_dev_flash_status_ctx *ctx) */ if (!ctx->status_msg_timeout) { len = snprintf(msg, sizeof(msg), - " ( %lum %lus )", elapsed_m, elapsed_s); + " ( %"PRIu64"m %"PRIu64"s )", elapsed_m, elapsed_s); } else if (res.tv_sec <= ctx->status_msg_timeout) { uint64_t timeout_m, timeout_s; @@ -3609,11 +3609,11 @@ static void cmd_dev_flash_time_elapsed(struct cmd_dev_flash_status_ctx *ctx) timeout_s = ctx->status_msg_timeout % 60; len = snprintf(msg, sizeof(msg), - " ( %lum %lus : %lum %lus )", + " ( %"PRIu64"m %"PRIu64"s : %"PRIu64"m %"PRIu64"s )", elapsed_m, elapsed_s, timeout_m, timeout_s); } else { len = snprintf(msg, sizeof(msg), - " ( %lum %lus : timeout reached )", elapsed_m, elapsed_s); + " ( %"PRIu64"m %"PRIu64"s : timeout reached )", elapsed_m, elapsed_s); } ctx->elapsed_time_msg_len = len; From 0e7ea3e8fe4004afd1d0896980f8e55ec5aba059 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 29 Jun 2021 11:24:17 -0700 Subject: [PATCH 09/10] v5.13.0 --- include/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/version.h b/include/version.h index b5113411..bbf1d1cc 100644 --- a/include/version.h +++ b/include/version.h @@ -1 +1 @@ -static const char version[] = "5.12.0"; +static const char version[] = "5.13.0"; From fc3511962d21fe75e6823e1eaa6de2e32d6fbfea Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 29 Jun 2021 13:20:44 -0700 Subject: [PATCH 10/10] lib: remove blank line at eof Signed-off-by: Stephen Hemminger --- lib/fs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/fs.c b/lib/fs.c index f161d888..1efc3686 100644 --- a/lib/fs.c +++ b/lib/fs.c @@ -339,4 +339,3 @@ char *get_task_name(pid_t pid) return comm; } -