* [PATCH bpf 2/2] selftests/bpf: tunnel: add sanity test for checksums
From: Jakub Kicinski @ 2022-12-20 0:47 UTC (permalink / raw)
To: daniel; +Cc: bpf, netdev, Jakub Kicinski
In-Reply-To: <20221220004701.402165-1-kuba@kernel.org>
Simple netdevsim based test. Netdevsim will validate xmit'ed
packets, in particular we care about checksum sanity (along
the lines of checks inside skb_checksum_help()). Triggering
skb_checksum_help() directly would require the right HW device
or a crypto device setup, netdevsim is much simpler.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/netdevsim/netdev.c | 5 ++++
tools/testing/selftests/bpf/test_tc_tunnel.sh | 27 +++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c
index 6db6a75ff9b9..e4808a6d37a4 100644
--- a/drivers/net/netdevsim/netdev.c
+++ b/drivers/net/netdevsim/netdev.c
@@ -33,6 +33,11 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (!nsim_ipsec_tx(ns, skb))
goto out;
+ /* Validate the packet */
+ if (skb->ip_summed == CHECKSUM_PARTIAL)
+ WARN_ON_ONCE((unsigned int)skb_checksum_start_offset(skb) >=
+ skb_headlen(skb));
+
u64_stats_update_begin(&ns->syncp);
ns->tx_packets++;
ns->tx_bytes += skb->len;
diff --git a/tools/testing/selftests/bpf/test_tc_tunnel.sh b/tools/testing/selftests/bpf/test_tc_tunnel.sh
index 334bdfeab940..4dac87f6a6fa 100755
--- a/tools/testing/selftests/bpf/test_tc_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tc_tunnel.sh
@@ -15,6 +15,7 @@ readonly ns1_v4=192.168.1.1
readonly ns2_v4=192.168.1.2
readonly ns1_v6=fd::1
readonly ns2_v6=fd::2
+readonly nsim_v4=192.168.2.1
# Must match port used by bpf program
readonly udpport=5555
@@ -67,6 +68,10 @@ cleanup() {
if [[ -n $server_pid ]]; then
kill $server_pid 2> /dev/null
fi
+
+ if [ -e /sys/bus/netdevsim/devices/netdevsim1 ]; then
+ echo 1 > /sys/bus/netdevsim/del_device
+ fi
}
server_listen() {
@@ -93,6 +98,25 @@ verify_data() {
fi
}
+decap_sanity() {
+ echo "test decap sanity"
+ modprobe netdevsim
+ echo 1 1 > /sys/bus/netdevsim/new_device
+ udevadm settle
+ nsim=$(ls /sys/bus/netdevsim/devices/netdevsim1/net/)
+ ip link set dev $nsim up
+ ip addr add dev $nsim $nsim_v4/24
+
+ tc qdisc add dev $nsim clsact
+ tc filter add dev $nsim egress \
+ bpf direct-action object-file ${BPF_FILE} section decap
+
+ echo abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz | \
+ nc -u 192.168.2.2 7777
+
+ echo 1 > /sys/bus/netdevsim/del_device
+}
+
set -e
# no arguments: automated test, run all
@@ -138,6 +162,9 @@ if [[ "$#" -eq "0" ]]; then
$0 ipv6 ip6udp $mac 2000
done
+ echo "decap sanity check"
+ decap_sanity
+
echo "OK. All tests passed"
exit 0
fi
--
2.38.1
^ permalink raw reply related
* [PATCH bpf 1/2] bpf: pull before calling skb_postpull_rcsum()
From: Jakub Kicinski @ 2022-12-20 0:47 UTC (permalink / raw)
To: daniel
Cc: bpf, netdev, Jakub Kicinski, Anand Parthasarathy, martin.lau,
song, john.fastabend, sdf
Anand hit a BUG() when pulling off headers on egress to a SW tunnel.
We get to skb_checksum_help() with an invalid checksum offset
(commit d7ea0d9df2a6 ("net: remove two BUG() from skb_checksum_help()")
converted those BUGs to WARN_ONs()).
He points out oddness in how skb_postpull_rcsum() gets used.
Indeed looks like we should pull before "postpull", otherwise
the CHECKSUM_PARTIAL fixup from skb_postpull_rcsum() will not
be able to do its job:
if (skb->ip_summed == CHECKSUM_PARTIAL &&
skb_checksum_start_offset(skb) < 0)
skb->ip_summed = CHECKSUM_NONE;
Reported-by: Anand Parthasarathy <anpartha@meta.com>
Fixes: 6578171a7ff0 ("bpf: add bpf_skb_change_proto helper")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: daniel@iogearbox.net
CC: martin.lau@linux.dev
CC: song@kernel.org
CC: john.fastabend@gmail.com
CC: sdf@google.com
CC: bpf@vger.kernel.org
---
net/core/filter.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index 929358677183..43cc1fe58a2c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3180,15 +3180,18 @@ static int bpf_skb_generic_push(struct sk_buff *skb, u32 off, u32 len)
static int bpf_skb_generic_pop(struct sk_buff *skb, u32 off, u32 len)
{
+ void *old_data;
+
/* skb_ensure_writable() is not needed here, as we're
* already working on an uncloned skb.
*/
if (unlikely(!pskb_may_pull(skb, off + len)))
return -ENOMEM;
- skb_postpull_rcsum(skb, skb->data + off, len);
- memmove(skb->data + len, skb->data, off);
+ old_data = skb->data;
__skb_pull(skb, len);
+ skb_postpull_rcsum(skb, old_data + off, len);
+ memmove(skb->data, old_data, off);
return 0;
}
--
2.38.1
^ permalink raw reply related
* Re: [RFC bpf-next 2/8] net: introduce XDP features flag
From: Stanislav Fomichev @ 2022-12-20 0:20 UTC (permalink / raw)
To: Marek Majtyka
Cc: Lorenzo Bianconi, bpf, netdev, ast, daniel, andrii, davem, kuba,
hawk, pabeni, edumazet, toke, memxor, saeedm, anthony.l.nguyen,
gospo, vladimir.oltean, nbd, john, leon, simon.horman, aelior,
christophe.jaillet, ecree.xilinx, grygorii.strashko, mst, bjorn,
magnus.karlsson, maciej.fijalkowski, intel-wired-lan,
lorenzo.bianconi
In-Reply-To: <CAAOQfrFGArAYPyBX_kw4ZvFrTjKXf-jG-2F2y69nOs-oQ8Onwg@mail.gmail.com>
On Mon, Dec 19, 2022 at 3:51 PM Marek Majtyka <alardam@gmail.com> wrote:
>
> At the time of writing, I wanted to be able to read additional information about the XDP capabilities of each network interface using ethtool. This change was intended for Linux users/admins, and not for XDP experts who mostly don't need it and prefer tasting XDP with netlink and bpf rather than reading network interface features with ethtool.
Anything preventing ethtool from doing probing similar to 'bpftool
feature probe'?
The problem with these feature bits is that they might diverge and/or
not work at all for the backported patches (where the fix/feature has
been backported, but the part that exports the bit hasn't) :-(
OTOH, I'm not sure we can probe everything from your list, but we
might try and see what's missing..
> On Mon, Dec 19, 2022 at 9:03 PM <sdf@google.com> wrote:
>>
>> On 12/19, Lorenzo Bianconi wrote:
>> > From: Marek Majtyka <alardam@gmail.com>
>>
>> > Implement support for checking what kind of XDP features a netdev
>> > supports. Previously, there was no way to do this other than to try to
>> > create an AF_XDP socket on the interface or load an XDP program and see
>> > if it worked. This commit changes this by adding a new variable which
>> > describes all xdp supported functions on pretty detailed level:
>>
>> > - aborted
>> > - drop
>> > - pass
>> > - tx
>> > - redirect
>> > - sock_zerocopy
>> > - hw_offload
>> > - redirect_target
>> > - tx_lock
>> > - frag_rx
>> > - frag_target
>>
>> > Zerocopy mode requires that redirect XDP operation is implemented in a
>> > driver and the driver supports also zero copy mode. Full mode requires
>> > that all XDP operation are implemented in the driver. Basic mode is just
>> > full mode without redirect operation. Frag target requires
>> > redirect_target one is supported by the driver.
>>
>> Can you share more about _why_ is it needed? If we can already obtain
>> most of these signals via probing, why export the flags?
>>
>> > Initially, these new flags are disabled for all drivers by default.
>>
>> > Co-developed-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
>> > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
>> > Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
>> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
>> > Signed-off-by: Marek Majtyka <alardam@gmail.com>
>> > ---
>> > .../networking/netdev-xdp-features.rst | 60 +++++++++++++++++
>> > include/linux/netdevice.h | 2 +
>> > include/linux/xdp_features.h | 64 +++++++++++++++++++
>> > include/uapi/linux/if_link.h | 7 ++
>> > include/uapi/linux/xdp_features.h | 34 ++++++++++
>> > net/core/rtnetlink.c | 34 ++++++++++
>> > tools/include/uapi/linux/if_link.h | 7 ++
>> > tools/include/uapi/linux/xdp_features.h | 34 ++++++++++
>> > 8 files changed, 242 insertions(+)
>> > create mode 100644 Documentation/networking/netdev-xdp-features.rst
>> > create mode 100644 include/linux/xdp_features.h
>> > create mode 100644 include/uapi/linux/xdp_features.h
>> > create mode 100644 tools/include/uapi/linux/xdp_features.h
>>
>> > diff --git a/Documentation/networking/netdev-xdp-features.rst
>> > b/Documentation/networking/netdev-xdp-features.rst
>> > new file mode 100644
>> > index 000000000000..1dc803fe72dd
>> > --- /dev/null
>> > +++ b/Documentation/networking/netdev-xdp-features.rst
>> > @@ -0,0 +1,60 @@
>> > +.. SPDX-License-Identifier: GPL-2.0
>> > +
>> > +=====================
>> > +Netdev XDP features
>> > +=====================
>> > +
>> > + * XDP FEATURES FLAGS
>> > +
>> > +Following netdev xdp features flags can be retrieved over route netlink
>> > +interface (compact form) - the same way as netdev feature flags.
>> > +These features flags are read only and cannot be change at runtime.
>> > +
>> > +* XDP_ABORTED
>> > +
>> > +This feature informs if netdev supports xdp aborted action.
>> > +
>> > +* XDP_DROP
>> > +
>> > +This feature informs if netdev supports xdp drop action.
>> > +
>> > +* XDP_PASS
>> > +
>> > +This feature informs if netdev supports xdp pass action.
>> > +
>> > +* XDP_TX
>> > +
>> > +This feature informs if netdev supports xdp tx action.
>> > +
>> > +* XDP_REDIRECT
>> > +
>> > +This feature informs if netdev supports xdp redirect action.
>> > +It assumes the all beforehand mentioned flags are enabled.
>> > +
>> > +* XDP_SOCK_ZEROCOPY
>> > +
>> > +This feature informs if netdev driver supports xdp zero copy.
>> > +It assumes the all beforehand mentioned flags are enabled.
>> > +
>> > +* XDP_HW_OFFLOAD
>> > +
>> > +This feature informs if netdev driver supports xdp hw oflloading.
>> > +
>> > +* XDP_TX_LOCK
>> > +
>> > +This feature informs if netdev ndo_xdp_xmit function requires locking.
>> > +
>> > +* XDP_REDIRECT_TARGET
>> > +
>> > +This feature informs if netdev implements ndo_xdp_xmit callback.
>> > +
>> > +* XDP_FRAG_RX
>> > +
>> > +This feature informs if netdev implements non-linear xdp buff support in
>> > +the driver napi callback.
>> > +
>> > +* XDP_FRAG_TARGET
>> > +
>> > +This feature informs if netdev implements non-linear xdp buff support in
>> > +ndo_xdp_xmit callback. XDP_FRAG_TARGET requires XDP_REDIRECT_TARGET is
>> > properly
>> > +supported.
>> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> > index aad12a179e54..ae5a8564383b 100644
>> > --- a/include/linux/netdevice.h
>> > +++ b/include/linux/netdevice.h
>> > @@ -43,6 +43,7 @@
>> > #include <net/xdp.h>
>>
>> > #include <linux/netdev_features.h>
>> > +#include <linux/xdp_features.h>
>> > #include <linux/neighbour.h>
>> > #include <uapi/linux/netdevice.h>
>> > #include <uapi/linux/if_bonding.h>
>> > @@ -2362,6 +2363,7 @@ struct net_device {
>> > struct rtnl_hw_stats64 *offload_xstats_l3;
>>
>> > struct devlink_port *devlink_port;
>> > + xdp_features_t xdp_features;
>> > };
>> > #define to_net_dev(d) container_of(d, struct net_device, dev)
>>
>> > diff --git a/include/linux/xdp_features.h b/include/linux/xdp_features.h
>> > new file mode 100644
>> > index 000000000000..4e72a86ef329
>> > --- /dev/null
>> > +++ b/include/linux/xdp_features.h
>> > @@ -0,0 +1,64 @@
>> > +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> > +/*
>> > + * Network device xdp features.
>> > + */
>> > +#ifndef _LINUX_XDP_FEATURES_H
>> > +#define _LINUX_XDP_FEATURES_H
>> > +
>> > +#include <linux/types.h>
>> > +#include <linux/bitops.h>
>> > +#include <asm/byteorder.h>
>> > +#include <uapi/linux/xdp_features.h>
>> > +
>> > +typedef u32 xdp_features_t;
>> > +
>> > +#define __XDP_F_BIT(bit) ((xdp_features_t)1 << (bit))
>> > +#define __XDP_F(name) __XDP_F_BIT(XDP_F_##name##_BIT)
>> > +
>> > +#define XDP_F_ABORTED __XDP_F(ABORTED)
>> > +#define XDP_F_DROP __XDP_F(DROP)
>> > +#define XDP_F_PASS __XDP_F(PASS)
>> > +#define XDP_F_TX __XDP_F(TX)
>> > +#define XDP_F_REDIRECT __XDP_F(REDIRECT)
>> > +#define XDP_F_REDIRECT_TARGET __XDP_F(REDIRECT_TARGET)
>> > +#define XDP_F_SOCK_ZEROCOPY __XDP_F(SOCK_ZEROCOPY)
>> > +#define XDP_F_HW_OFFLOAD __XDP_F(HW_OFFLOAD)
>> > +#define XDP_F_TX_LOCK __XDP_F(TX_LOCK)
>> > +#define XDP_F_FRAG_RX __XDP_F(FRAG_RX)
>> > +#define XDP_F_FRAG_TARGET __XDP_F(FRAG_TARGET)
>> > +
>> > +#define XDP_F_BASIC (XDP_F_ABORTED | XDP_F_DROP | \
>> > + XDP_F_PASS | XDP_F_TX)
>> > +
>> > +#define XDP_F_FULL (XDP_F_BASIC | XDP_F_REDIRECT)
>> > +
>> > +#define XDP_F_FULL_ZC (XDP_F_FULL | XDP_F_SOCK_ZEROCOPY)
>> > +
>> > +#define XDP_FEATURES_ABORTED_STR "xdp-aborted"
>> > +#define XDP_FEATURES_DROP_STR "xdp-drop"
>> > +#define XDP_FEATURES_PASS_STR "xdp-pass"
>> > +#define XDP_FEATURES_TX_STR "xdp-tx"
>> > +#define XDP_FEATURES_REDIRECT_STR "xdp-redirect"
>> > +#define XDP_FEATURES_REDIRECT_TARGET_STR "xdp-redirect-target"
>> > +#define XDP_FEATURES_SOCK_ZEROCOPY_STR "xdp-sock-zerocopy"
>> > +#define XDP_FEATURES_HW_OFFLOAD_STR "xdp-hw-offload"
>> > +#define XDP_FEATURES_TX_LOCK_STR "xdp-tx-lock"
>> > +#define XDP_FEATURES_FRAG_RX_STR "xdp-frag-rx"
>> > +#define XDP_FEATURES_FRAG_TARGET_STR "xdp-frag-target"
>> > +
>> > +#define DECLARE_XDP_FEATURES_TABLE(name, length) \
>> > + const char name[][length] = { \
>> > + [XDP_F_ABORTED_BIT] = XDP_FEATURES_ABORTED_STR, \
>> > + [XDP_F_DROP_BIT] = XDP_FEATURES_DROP_STR, \
>> > + [XDP_F_PASS_BIT] = XDP_FEATURES_PASS_STR, \
>> > + [XDP_F_TX_BIT] = XDP_FEATURES_TX_STR, \
>> > + [XDP_F_REDIRECT_BIT] = XDP_FEATURES_REDIRECT_STR, \
>> > + [XDP_F_REDIRECT_TARGET_BIT] = XDP_FEATURES_REDIRECT_TARGET_STR, \
>> > + [XDP_F_SOCK_ZEROCOPY_BIT] = XDP_FEATURES_SOCK_ZEROCOPY_STR, \
>> > + [XDP_F_HW_OFFLOAD_BIT] = XDP_FEATURES_HW_OFFLOAD_STR, \
>> > + [XDP_F_TX_LOCK_BIT] = XDP_FEATURES_TX_LOCK_STR, \
>> > + [XDP_F_FRAG_RX_BIT] = XDP_FEATURES_FRAG_RX_STR, \
>> > + [XDP_F_FRAG_TARGET_BIT] = XDP_FEATURES_FRAG_TARGET_STR, \
>> > + }
>> > +
>> > +#endif /* _LINUX_XDP_FEATURES_H */
>> > diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
>> > index 1021a7e47a86..971c658ceaea 100644
>> > --- a/include/uapi/linux/if_link.h
>> > +++ b/include/uapi/linux/if_link.h
>> > @@ -374,6 +374,8 @@ enum {
>>
>> > IFLA_DEVLINK_PORT,
>>
>> > + IFLA_XDP_FEATURES,
>> > +
>> > __IFLA_MAX
>> > };
>>
>> > @@ -1318,6 +1320,11 @@ enum {
>>
>> > #define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1)
>>
>> > +enum {
>> > + IFLA_XDP_FEATURES_WORD_UNSPEC = 0,
>> > + IFLA_XDP_FEATURES_BITS_WORD,
>> > +};
>> > +
>> > enum {
>> > IFLA_EVENT_NONE,
>> > IFLA_EVENT_REBOOT, /* internal reset / reboot */
>> > diff --git a/include/uapi/linux/xdp_features.h
>> > b/include/uapi/linux/xdp_features.h
>> > new file mode 100644
>> > index 000000000000..48eb42069bcd
>> > --- /dev/null
>> > +++ b/include/uapi/linux/xdp_features.h
>> > @@ -0,0 +1,34 @@
>> > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>> > +/*
>> > + * Copyright (c) 2020 Intel
>> > + */
>> > +
>> > +#ifndef __UAPI_LINUX_XDP_FEATURES__
>> > +#define __UAPI_LINUX_XDP_FEATURES__
>> > +
>> > +enum {
>> > + XDP_F_ABORTED_BIT,
>> > + XDP_F_DROP_BIT,
>> > + XDP_F_PASS_BIT,
>> > + XDP_F_TX_BIT,
>> > + XDP_F_REDIRECT_BIT,
>> > + XDP_F_REDIRECT_TARGET_BIT,
>> > + XDP_F_SOCK_ZEROCOPY_BIT,
>> > + XDP_F_HW_OFFLOAD_BIT,
>> > + XDP_F_TX_LOCK_BIT,
>> > + XDP_F_FRAG_RX_BIT,
>> > + XDP_F_FRAG_TARGET_BIT,
>> > + /*
>> > + * Add your fresh new property above and remember to update
>> > + * documentation.
>> > + */
>> > + XDP_FEATURES_COUNT,
>> > +};
>> > +
>> > +#define XDP_FEATURES_WORDS ((XDP_FEATURES_COUNT + 32 - 1) / 32)
>> > +#define XDP_FEATURES_WORD(blocks, index) ((blocks)[(index) / 32U])
>> > +#define XDP_FEATURES_FIELD_FLAG(index) (1U << (index) % 32U)
>> > +#define XDP_FEATURES_BIT_IS_SET(blocks, index) \
>> > + (XDP_FEATURES_WORD(blocks, index) & XDP_FEATURES_FIELD_FLAG(index))
>> > +
>> > +#endif /* __UAPI_LINUX_XDP_FEATURES__ */
>> > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>> > index 64289bc98887..1c299746b614 100644
>> > --- a/net/core/rtnetlink.c
>> > +++ b/net/core/rtnetlink.c
>> > @@ -1016,6 +1016,14 @@ static size_t rtnl_xdp_size(void)
>> > return xdp_size;
>> > }
>>
>> > +static size_t rtnl_xdp_features_size(void)
>> > +{
>> > + size_t xdp_size = nla_total_size(0) + /* nest IFLA_XDP_FEATURES */
>> > + XDP_FEATURES_WORDS * nla_total_size(4);
>> > +
>> > + return xdp_size;
>> > +}
>> > +
>> > static size_t rtnl_prop_list_size(const struct net_device *dev)
>> > {
>> > struct netdev_name_node *name_node;
>> > @@ -1103,6 +1111,7 @@ static noinline size_t if_nlmsg_size(const struct
>> > net_device *dev,
>> > + rtnl_prop_list_size(dev)
>> > + nla_total_size(MAX_ADDR_LEN) /* IFLA_PERM_ADDRESS */
>> > + rtnl_devlink_port_size(dev)
>> > + + rtnl_xdp_features_size() /* IFLA_XDP_FEATURES */
>> > + 0;
>> > }
>>
>> > @@ -1546,6 +1555,27 @@ static int rtnl_xdp_fill(struct sk_buff *skb,
>> > struct net_device *dev)
>> > return err;
>> > }
>>
>> > +static int rtnl_xdp_features_fill(struct sk_buff *skb, struct net_device
>> > *dev)
>> > +{
>> > + struct nlattr *attr;
>> > +
>> > + attr = nla_nest_start_noflag(skb, IFLA_XDP_FEATURES);
>> > + if (!attr)
>> > + return -EMSGSIZE;
>> > +
>> > + BUILD_BUG_ON(XDP_FEATURES_WORDS != 1);
>> > + if (nla_put_u32(skb, IFLA_XDP_FEATURES_BITS_WORD, dev->xdp_features))
>> > + goto err_cancel;
>> > +
>> > + nla_nest_end(skb, attr);
>> > +
>> > + return 0;
>> > +
>> > +err_cancel:
>> > + nla_nest_cancel(skb, attr);
>> > + return -EMSGSIZE;
>> > +}
>> > +
>> > static u32 rtnl_get_event(unsigned long event)
>> > {
>> > u32 rtnl_event_type = IFLA_EVENT_NONE;
>> > @@ -1904,6 +1934,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
>> > if (rtnl_fill_devlink_port(skb, dev))
>> > goto nla_put_failure;
>>
>> > + if (rtnl_xdp_features_fill(skb, dev))
>> > + goto nla_put_failure;
>> > +
>> > nlmsg_end(skb, nlh);
>> > return 0;
>>
>> > @@ -1968,6 +2001,7 @@ static const struct nla_policy
>> > ifla_policy[IFLA_MAX+1] = {
>> > [IFLA_TSO_MAX_SIZE] = { .type = NLA_REJECT },
>> > [IFLA_TSO_MAX_SEGS] = { .type = NLA_REJECT },
>> > [IFLA_ALLMULTI] = { .type = NLA_REJECT },
>> > + [IFLA_XDP_FEATURES] = { .type = NLA_NESTED },
>> > };
>>
>> > static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
>> > diff --git a/tools/include/uapi/linux/if_link.h
>> > b/tools/include/uapi/linux/if_link.h
>> > index 82fe18f26db5..994228e9909a 100644
>> > --- a/tools/include/uapi/linux/if_link.h
>> > +++ b/tools/include/uapi/linux/if_link.h
>> > @@ -354,6 +354,8 @@ enum {
>>
>> > IFLA_DEVLINK_PORT,
>>
>> > + IFLA_XDP_FEATURES,
>> > +
>> > __IFLA_MAX
>> > };
>>
>> > @@ -1222,6 +1224,11 @@ enum {
>>
>> > #define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1)
>>
>> > +enum {
>> > + IFLA_XDP_FEATURES_WORD_UNSPEC = 0,
>> > + IFLA_XDP_FEATURES_BITS_WORD,
>> > +};
>> > +
>> > enum {
>> > IFLA_EVENT_NONE,
>> > IFLA_EVENT_REBOOT, /* internal reset / reboot */
>> > diff --git a/tools/include/uapi/linux/xdp_features.h
>> > b/tools/include/uapi/linux/xdp_features.h
>> > new file mode 100644
>> > index 000000000000..48eb42069bcd
>> > --- /dev/null
>> > +++ b/tools/include/uapi/linux/xdp_features.h
>> > @@ -0,0 +1,34 @@
>> > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>> > +/*
>> > + * Copyright (c) 2020 Intel
>> > + */
>> > +
>> > +#ifndef __UAPI_LINUX_XDP_FEATURES__
>> > +#define __UAPI_LINUX_XDP_FEATURES__
>> > +
>> > +enum {
>> > + XDP_F_ABORTED_BIT,
>> > + XDP_F_DROP_BIT,
>> > + XDP_F_PASS_BIT,
>> > + XDP_F_TX_BIT,
>> > + XDP_F_REDIRECT_BIT,
>> > + XDP_F_REDIRECT_TARGET_BIT,
>> > + XDP_F_SOCK_ZEROCOPY_BIT,
>> > + XDP_F_HW_OFFLOAD_BIT,
>> > + XDP_F_TX_LOCK_BIT,
>> > + XDP_F_FRAG_RX_BIT,
>> > + XDP_F_FRAG_TARGET_BIT,
>> > + /*
>> > + * Add your fresh new property above and remember to update
>> > + * documentation.
>> > + */
>> > + XDP_FEATURES_COUNT,
>> > +};
>> > +
>> > +#define XDP_FEATURES_WORDS ((XDP_FEATURES_COUNT + 32 - 1) / 32)
>> > +#define XDP_FEATURES_WORD(blocks, index) ((blocks)[(index) / 32U])
>> > +#define XDP_FEATURES_FIELD_FLAG(index) (1U << (index) % 32U)
>> > +#define XDP_FEATURES_BIT_IS_SET(blocks, index) \
>> > + (XDP_FEATURES_WORD(blocks, index) & XDP_FEATURES_FIELD_FLAG(index))
>> > +
>> > +#endif /* __UAPI_LINUX_XDP_FEATURES__ */
>> > --
>> > 2.38.1
>>
^ permalink raw reply
* [PATCH v8 18/28] firmware: qcom_scm: Use fixed width src vm bitmap
From: Elliot Berman @ 2022-12-19 22:58 UTC (permalink / raw)
To: Bjorn Andersson, Andy Gross, Bjorn Andersson, Konrad Dybcio,
Srinivas Kandagatla, Amol Maheshwari, Arnd Bergmann,
Greg Kroah-Hartman, Kalle Valo, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Mathieu Poirier
Cc: Elliot Berman, Murali Nalajala, Trilok Soni, Srivatsa Vaddagiri,
Carl van Schaik, Prakruthi Deepak Heragu, Rob Herring,
Krzysztof Kozlowski, Jonathan Corbet, Bagas Sanjaya,
Catalin Marinas, Will Deacon, Jassi Brar, Sudeep Holla,
Mark Rutland, Lorenzo Pieralisi, Dmitry Baryshkov, linux-arm-msm,
devicetree, linux-kernel, linux-doc, linux-arm-kernel, linux-acpi,
ath10k, linux-wireless, netdev, linux-remoteproc
In-Reply-To: <20221219225850.2397345-1-quic_eberman@quicinc.com>
The maximum VMID for assign_mem is 63. Use a u64 to represent this
bitmap instead of architecture-dependent "unsigned int" which varies in
size on 32-bit and 64-bit platforms.
Acked-by: Kalle Valo <kvalo@kernel.org> [ath10k]
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
drivers/firmware/qcom_scm.c | 12 +++++++-----
drivers/misc/fastrpc.c | 6 ++++--
drivers/net/wireless/ath/ath10k/qmi.c | 4 ++--
drivers/remoteproc/qcom_q6v5_mss.c | 8 ++++----
drivers/soc/qcom/rmtfs_mem.c | 2 +-
include/linux/qcom_scm.h | 2 +-
6 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index cdbfe54c8146..92763dce6477 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -898,7 +898,7 @@ static int __qcom_scm_assign_mem(struct device *dev, phys_addr_t mem_region,
* Return negative errno on failure or 0 on success with @srcvm updated.
*/
int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
- unsigned int *srcvm,
+ u64 *srcvm,
const struct qcom_scm_vmperm *newvm,
unsigned int dest_cnt)
{
@@ -915,9 +915,9 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
__le32 *src;
void *ptr;
int ret, i, b;
- unsigned long srcvm_bits = *srcvm;
+ u64 srcvm_bits = *srcvm;
- src_sz = hweight_long(srcvm_bits) * sizeof(*src);
+ src_sz = hweight64(srcvm_bits) * sizeof(*src);
mem_to_map_sz = sizeof(*mem_to_map);
dest_sz = dest_cnt * sizeof(*destvm);
ptr_sz = ALIGN(src_sz, SZ_64) + ALIGN(mem_to_map_sz, SZ_64) +
@@ -930,8 +930,10 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
/* Fill source vmid detail */
src = ptr;
i = 0;
- for_each_set_bit(b, &srcvm_bits, BITS_PER_LONG)
- src[i++] = cpu_to_le32(b);
+ for (b = 0; b < BITS_PER_TYPE(u64); b++) {
+ if (srcvm_bits & BIT(b))
+ src[i++] = cpu_to_le32(b);
+ }
/* Fill details of mem buff to map */
mem_to_map = ptr + ALIGN(src_sz, SZ_64);
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 7ff0b63c25e3..2ad388f99fe1 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -299,11 +299,13 @@ static void fastrpc_free_map(struct kref *ref)
if (map->attr & FASTRPC_ATTR_SECUREMAP) {
struct qcom_scm_vmperm perm;
int err = 0;
+ u64 src;
+ src = BIT(map->fl->cctx->vmperms[0].vmid);
perm.vmid = QCOM_SCM_VMID_HLOS;
perm.perm = QCOM_SCM_PERM_RWX;
err = qcom_scm_assign_mem(map->phys, map->size,
- &(map->fl->cctx->vmperms[0].vmid), &perm, 1);
+ &src, &perm, 1);
if (err) {
dev_err(map->fl->sctx->dev, "Failed to assign memory phys 0x%llx size 0x%llx err %d",
map->phys, map->size, err);
@@ -744,7 +746,7 @@ static int fastrpc_map_create(struct fastrpc_user *fl, int fd,
* If subsystem VMIDs are defined in DTSI, then do
* hyp_assign from HLOS to those VM(s)
*/
- unsigned int perms = BIT(QCOM_SCM_VMID_HLOS);
+ u64 perms = BIT(QCOM_SCM_VMID_HLOS);
map->attr = attr;
err = qcom_scm_assign_mem(map->phys, (u64)map->size, &perms,
diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
index 66cb7a1e628a..6d1d87e1cdde 100644
--- a/drivers/net/wireless/ath/ath10k/qmi.c
+++ b/drivers/net/wireless/ath/ath10k/qmi.c
@@ -28,7 +28,7 @@ static int ath10k_qmi_map_msa_permission(struct ath10k_qmi *qmi,
{
struct qcom_scm_vmperm dst_perms[3];
struct ath10k *ar = qmi->ar;
- unsigned int src_perms;
+ u64 src_perms;
u32 perm_count;
int ret;
@@ -60,7 +60,7 @@ static int ath10k_qmi_unmap_msa_permission(struct ath10k_qmi *qmi,
{
struct qcom_scm_vmperm dst_perms;
struct ath10k *ar = qmi->ar;
- unsigned int src_perms;
+ u64 src_perms;
int ret;
src_perms = BIT(QCOM_SCM_VMID_MSS_MSA) | BIT(QCOM_SCM_VMID_WLAN);
diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
index fddb63cffee0..9e8bde7a7ec4 100644
--- a/drivers/remoteproc/qcom_q6v5_mss.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -227,8 +227,8 @@ struct q6v5 {
bool has_qaccept_regs;
bool has_ext_cntl_regs;
bool has_vq6;
- int mpss_perm;
- int mba_perm;
+ u64 mpss_perm;
+ u64 mba_perm;
const char *hexagon_mdt_image;
int version;
};
@@ -404,7 +404,7 @@ static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds,
}
}
-static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm,
+static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, u64 *current_perm,
bool local, bool remote, phys_addr_t addr,
size_t size)
{
@@ -939,7 +939,7 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw,
struct page *page;
dma_addr_t phys;
void *metadata;
- int mdata_perm;
+ u64 mdata_perm;
int xferop_ret;
size_t size;
void *vaddr;
diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
index 0feaae357821..69991e47aa23 100644
--- a/drivers/soc/qcom/rmtfs_mem.c
+++ b/drivers/soc/qcom/rmtfs_mem.c
@@ -30,7 +30,7 @@ struct qcom_rmtfs_mem {
unsigned int client_id;
- unsigned int perms;
+ u64 perms;
};
static ssize_t qcom_rmtfs_mem_show(struct device *dev,
diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h
index f8335644a01a..77f7b5837216 100644
--- a/include/linux/qcom_scm.h
+++ b/include/linux/qcom_scm.h
@@ -96,7 +96,7 @@ extern int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,
u32 cp_nonpixel_start,
u32 cp_nonpixel_size);
extern int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
- unsigned int *src,
+ u64 *src,
const struct qcom_scm_vmperm *newvm,
unsigned int dest_cnt);
--
2.25.1
^ permalink raw reply related
* Re: [PATCH bpf-next 1/2] bpf: Add flag BPF_F_NO_TUNNEL_KEY to bpf_skb_set_tunnel_key()
From: patchwork-bot+netdevbpf @ 2022-12-19 23:00 UTC (permalink / raw)
To: Christian Ehrig
Cc: bpf, ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
kpsingh, sdf, haoluo, jolsa, davem, edumazet, kuba, pabeni,
mykolal, shuah, joannelkoong, kuifeng, maximmi, fankaixi.li,
shmulik, paul, linux-kernel, netdev, linux-kselftest
In-Reply-To: <20221218051734.31411-1-cehrig@cloudflare.com>
Hello:
This series was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:
On Sun, 18 Dec 2022 06:17:31 +0100 you wrote:
> This patch allows to remove TUNNEL_KEY from the tunnel flags bitmap
> when using bpf_skb_set_tunnel_key by providing a BPF_F_NO_TUNNEL_KEY
> flag. On egress, the resulting tunnel header will not contain a tunnel
> key if the protocol and implementation supports it.
>
> At the moment bpf_tunnel_key wants a user to specify a numeric tunnel
> key. This will wrap the inner packet into a tunnel header with the key
> bit and value set accordingly. This is problematic when using a tunnel
> protocol that supports optional tunnel keys and a receiving tunnel
> device that is not expecting packets with the key bit set. The receiver
> won't decapsulate and drop the packet.
>
> [...]
Here is the summary with links:
- [bpf-next,1/2] bpf: Add flag BPF_F_NO_TUNNEL_KEY to bpf_skb_set_tunnel_key()
https://git.kernel.org/bpf/bpf-next/c/e26aa600ba6a
- [bpf-next,2/2] selftests/bpf: Add BPF_F_NO_TUNNEL_KEY test
https://git.kernel.org/bpf/bpf-next/c/ac6e45e05857
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply
* ethtool 6.1 released
From: Michal Kubecek @ 2022-12-19 22:56 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 462 bytes --]
Hello,
ethtool 6.1 has been released.
Home page: https://www.kernel.org/pub/software/network/ethtool/
Download link:
https://www.kernel.org/pub/software/network/ethtool/ethtool-6.1.tar.xz
Release notes:
* Feature: update link mode tables
* Feature: register dump for NXP ENETC driver (-d)
* Feature: report TCP header-data split (-g)
* Feature: support new message types in pretty print
* Fix: fix compiler warnings
* Fix: man page syntax fixes
Michal
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [RFC net-next 05/10] devlink: remove the registration guarantee of references
From: Jakub Kicinski @ 2022-12-19 22:31 UTC (permalink / raw)
To: Jacob Keller; +Cc: jiri, leon, netdev
In-Reply-To: <1aa72500-79cd-810e-947c-172bbc4db513@intel.com>
On Mon, 19 Dec 2022 14:14:18 -0800 Jacob Keller wrote:
> On 12/19/2022 2:02 PM, Jakub Kicinski wrote:
> > I was wondering if anyone would notice :)
>
> I'm fine with it, but I would expect that devlink_register would want to
> report it at least?
New code should not use devlink_* functions, so probably not worth it.
> > Returning errors from the registration helper seems natural,
> > and if we don't have this ability it may impact our ability
> > to extend the core in the long run.
> > I was against making core functions void in the first place.
> > It's a good opportunity to change back.
>
> Sure. I think its better to be able to report an error but wanted to
> make sure its actually caught or at least logged if it occurs.
>
> We can ofcourse change the function templates again since we don't
> really guarantee API stability across versions, but it is more work for
> backporting in the future.
^ permalink raw reply
* Re: [syzbot] KASAN: use-after-free Read in put_pmu_ctx
From: syzbot @ 2022-12-19 22:24 UTC (permalink / raw)
To: acme, alexander.shishkin, bpf, jolsa, linux-kernel,
linux-perf-users, mark.rutland, mingo, namhyung, netdev, peterz,
sdf, syzkaller-bugs
In-Reply-To: <Y6DYsN+G3mdKP/Bb@google.com>
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
failed to apply patch:
checking file kernel/events/core.c
patch: **** unexpected end of file in patch
Tested on:
commit: 13e3c779 Merge tag 'for-netdev' of https://git.kernel...
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
dashboard link: https://syzkaller.appspot.com/bug?extid=b8e8c01c8ade4fe6e48f
compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=1451cef0480000
^ permalink raw reply
* Re: [RFC net-next 00/10] devlink: remove the wait-for-references on unregister
From: Jacob Keller @ 2022-12-19 22:16 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: jiri, leon, netdev
In-Reply-To: <20221219141000.32c94617@kernel.org>
On 12/19/2022 2:10 PM, Jakub Kicinski wrote:
> On Mon, 19 Dec 2022 09:38:09 -0800 Jacob Keller wrote:
>> On 12/16/2022 5:19 PM, Jakub Kicinski wrote:
>>> This set is on top of the previous RFC.
>>>
>>> Move the registration and unregistration of the devlink instances
>>> under their instance locks. Don't perform the netdev-style wait
>>> for all references when unregistering the instance.
>>
>> Could you explain the reasoning/benefits here? I'm sure some of this is
>> explained in each commit message as well but it would help to understand
>> the overall series.
>
> Fair point, I'll add this:
>
> Yang Yingliang reported [1] a use-after-free in devlink because netdev
> paths are able to acquire a reference on the devlink instances before
> they are registered.
>
> [1]
> https://lore.kernel.org/all/20221122121048.776643-1-yangyingliang@huawei.com/
Great. I also think its better to allow some of the sub objects to be
setup either before or after registering, as some things might be
dynamic. This series lets us get there safely which is good.
^ permalink raw reply
* Re: [RFC net-next 05/10] devlink: remove the registration guarantee of references
From: Jacob Keller @ 2022-12-19 22:14 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: jiri, leon, netdev
In-Reply-To: <20221219140210.241146ea@kernel.org>
On 12/19/2022 2:02 PM, Jakub Kicinski wrote:
> On Mon, 19 Dec 2022 09:56:26 -0800 Jacob Keller wrote:
>>> -void devlink_register(struct devlink *devlink)
>>> +int devl_register(struct devlink *devlink)
>>> {
>>> ASSERT_DEVLINK_NOT_REGISTERED(devlink);
>>> - /* Make sure that we are in .probe() routine */
>>> + devl_assert_locked(devlink);
>>>
>>> xa_set_mark(&devlinks, devlink->index, DEVLINK_REGISTERED);
>>> devlink_notify_register(devlink);
>>> +
>>> + return 0;
>>
>> Any particular reason to change this to int when it doesn't have a
>> failure case yet? Future patches I assume? You don't check the
>> devl_register return value.
>
> I was wondering if anyone would notice :)
>
I'm fine with it, but I would expect that devlink_register would want to
report it at least?
> Returning errors from the registration helper seems natural,
> and if we don't have this ability it may impact our ability
> to extend the core in the long run.
> I was against making core functions void in the first place.
> It's a good opportunity to change back.
Sure. I think its better to be able to report an error but wanted to
make sure its actually caught or at least logged if it occurs.
We can ofcourse change the function templates again since we don't
really guarantee API stability across versions, but it is more work for
backporting in the future.
^ permalink raw reply
* Re: [RFC net-next 00/10] devlink: remove the wait-for-references on unregister
From: Jakub Kicinski @ 2022-12-19 22:10 UTC (permalink / raw)
To: Jacob Keller; +Cc: jiri, leon, netdev
In-Reply-To: <3d169051-e095-6a2a-d5d8-409a5ad8af4b@intel.com>
On Mon, 19 Dec 2022 09:38:09 -0800 Jacob Keller wrote:
> On 12/16/2022 5:19 PM, Jakub Kicinski wrote:
> > This set is on top of the previous RFC.
> >
> > Move the registration and unregistration of the devlink instances
> > under their instance locks. Don't perform the netdev-style wait
> > for all references when unregistering the instance.
>
> Could you explain the reasoning/benefits here? I'm sure some of this is
> explained in each commit message as well but it would help to understand
> the overall series.
Fair point, I'll add this:
Yang Yingliang reported [1] a use-after-free in devlink because netdev
paths are able to acquire a reference on the devlink instances before
they are registered.
[1]
https://lore.kernel.org/all/20221122121048.776643-1-yangyingliang@huawei.com/
^ permalink raw reply
* Re: [RFC net-next 04/10] devlink: always check if the devlink instance is registered
From: Jacob Keller @ 2022-12-19 22:08 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: jiri, leon, netdev
In-Reply-To: <20221219135541.6e0a7cfd@kernel.org>
On 12/19/2022 1:55 PM, Jakub Kicinski wrote:
> On Mon, 19 Dec 2022 09:48:54 -0800 Jacob Keller wrote:
>> On 12/16/2022 5:19 PM, Jakub Kicinski wrote:
>>> Always check under the instance lock whether the devlink instance
>>> is still / already registered.
>>
>> Ok. So now the reference ensures less about whats valid. It guarantees a
>> lock but doesn't ensure that the devlink remains registered unless you
>> acquire the lock and check that the devlink is alive under lock now?
>
> Correct.
>
>>> This is a no-op for the most part, as the unregistration path currently
>>> waits for all references. On the init path, however, we may temporarily
>>> open up a race with netdev code, if netdevs are registered before the
>>> devlink instance. This is temporary, the next change fixes it, and this
>>> commit has been split out for the ease of review.
>>>
>>
>> This means you're adding the problem here, but its fixed in next commit..?
>
> Yes, I can squash when posting for applying, but TBH I think the clarity
> of the changes outweighs the tiny and transient race.
I would agree. The only reason I could think it to be a problem is if a
bisect lands precisely on this commit and you happen to hit this... what
are the side effects of the race here? If the side effects don't include
significant issues I think its fine.
^ permalink raw reply
* Re: [Patch net-next v4 01/13] net: dsa: microchip: ptp: add the posix clock support
From: Jacob Keller @ 2022-12-19 22:08 UTC (permalink / raw)
To: Arun Ramadoss, linux-kernel, netdev
Cc: woojung.huh, UNGLinuxDriver, andrew, vivien.didelot, f.fainelli,
olteanv, davem, edumazet, kuba, pabeni, linux, Tristram.Ha,
richardcochran, ceggers
In-Reply-To: <20221212102639.24415-2-arun.ramadoss@microchip.com>
On 12/12/2022 2:26 AM, Arun Ramadoss wrote:
> +static int ksz_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
> +{
> + struct ksz_ptp_data *ptp_data = ptp_caps_to_data(ptp);
> + struct ksz_device *dev = ptp_data_to_ksz_dev(ptp_data);
> + int ret;
> +
> + mutex_lock(&ptp_data->lock);
> +
> + if (scaled_ppm) {
> + s64 ppb, adj;
> + u32 data32;
> +
> + /* see scaled_ppm_to_ppb() in ptp_clock.c for details */
> + ppb = 1 + scaled_ppm;
> + ppb *= 125;
> + ppb *= KSZ_PTP_INC_NS;
> + ppb <<= KSZ_PTP_SUBNS_BITS - 13;
> + adj = div_s64(ppb, NSEC_PER_SEC);
> +
> + data32 = abs(adj);
> + data32 &= PTP_SUBNANOSEC_M;
> + if (adj >= 0)
> + data32 |= PTP_RATE_DIR;
> +
Can you use adjust_by_scaled_ppm or diff_by_scalled_ppm? These work by
defining the base increment for your device to achieve nominal
nanoseconds, and then perform the multiple+divide to calculate the
modified adjustment based on scaled_ppm. The diff_by_scaled_ppm looks
like what you want as it takes a base, the scaled adjustment factor and
then exports the diff as the 3rd argument. It returns true if the
difference is negative so ou can use that to determine if you need to
add the PTP_RATE_DIR flag.
If for some reason diff_by_scaled_ppm isn't sufficient for your
hardware, at least use scaled_ppm_to_ppb to get the ppb value instead of
open coding the conversion.
Thanks,
Jake
^ permalink raw reply
* Re: [RFC net-next 05/10] devlink: remove the registration guarantee of references
From: Jakub Kicinski @ 2022-12-19 22:02 UTC (permalink / raw)
To: Jacob Keller; +Cc: jiri, leon, netdev
In-Reply-To: <ac6f8ab5-3838-4686-fc20-b98b196f82c8@intel.com>
On Mon, 19 Dec 2022 09:56:26 -0800 Jacob Keller wrote:
> > -void devlink_register(struct devlink *devlink)
> > +int devl_register(struct devlink *devlink)
> > {
> > ASSERT_DEVLINK_NOT_REGISTERED(devlink);
> > - /* Make sure that we are in .probe() routine */
> > + devl_assert_locked(devlink);
> >
> > xa_set_mark(&devlinks, devlink->index, DEVLINK_REGISTERED);
> > devlink_notify_register(devlink);
> > +
> > + return 0;
>
> Any particular reason to change this to int when it doesn't have a
> failure case yet? Future patches I assume? You don't check the
> devl_register return value.
I was wondering if anyone would notice :)
Returning errors from the registration helper seems natural,
and if we don't have this ability it may impact our ability
to extend the core in the long run.
I was against making core functions void in the first place.
It's a good opportunity to change back.
^ permalink raw reply
* Re: [RFC net-next 04/10] devlink: always check if the devlink instance is registered
From: Jakub Kicinski @ 2022-12-19 21:55 UTC (permalink / raw)
To: Jacob Keller; +Cc: jiri, leon, netdev
In-Reply-To: <84151471-4404-d944-417f-2982569f44da@intel.com>
On Mon, 19 Dec 2022 09:48:54 -0800 Jacob Keller wrote:
> On 12/16/2022 5:19 PM, Jakub Kicinski wrote:
> > Always check under the instance lock whether the devlink instance
> > is still / already registered.
>
> Ok. So now the reference ensures less about whats valid. It guarantees a
> lock but doesn't ensure that the devlink remains registered unless you
> acquire the lock and check that the devlink is alive under lock now?
Correct.
> > This is a no-op for the most part, as the unregistration path currently
> > waits for all references. On the init path, however, we may temporarily
> > open up a race with netdev code, if netdevs are registered before the
> > devlink instance. This is temporary, the next change fixes it, and this
> > commit has been split out for the ease of review.
> >
>
> This means you're adding the problem here, but its fixed in next commit..?
Yes, I can squash when posting for applying, but TBH I think the clarity
of the changes outweighs the tiny and transient race.
^ permalink raw reply
* Re: [syzbot] KASAN: use-after-free Read in put_pmu_ctx
From: sdf @ 2022-12-19 21:33 UTC (permalink / raw)
To: syzbot
Cc: acme, alexander.shishkin, bpf, jolsa, linux-kernel,
linux-perf-users, mark.rutland, mingo, namhyung, netdev, peterz,
syzkaller-bugs
In-Reply-To: <00000000000051b79a05f033b6e5@google.com>
On 12/19, syzbot wrote:
> Hello,
> syzbot tried to test the proposed patch but the build/boot failed:
> failed to apply patch:
> checking file kernel/events/core.c
> patch: **** unexpected end of file in patch
> Tested on:
> commit: 13e3c779 Merge tag 'for-netdev' of https://git.kernel...
> git tree:
> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=b8e8c01c8ade4fe6e48f
> compiler:
> patch:
> https://syzkaller.appspot.com/x/patch.diff?x=15861a9f880000
Let's try again with hopefully a better formatted patch..
#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
13e3c7793e2f
diff --git a/kernel/events/core.c b/kernel/events/core.c
index e47914ac8732..bbff551783e1 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -12689,7 +12689,8 @@ SYSCALL_DEFINE5(perf_event_open,
return event_fd;
err_context:
- /* event->pmu_ctx freed by free_event() */
+ put_pmu_ctx(event->pmu_ctx);
+ event->pmu_ctx = NULL; /* _free_event() */
err_locked:
mutex_unlock(&ctx->mutex);
perf_unpin_context(ctx);
^ permalink raw reply related
* [PATCH 2/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (2)
From: Frank Jungclaus @ 2022-12-19 21:27 UTC (permalink / raw)
To: linux-can, Marc Kleine-Budde, Wolfgang Grandegger,
Vincent Mailhol
Cc: Stefan Mätje, netdev, linux-kernel, Frank Jungclaus
Started a rework initiated by Vincents remarks "You should not report
the greatest of txerr and rxerr but the one which actually increased."
[1] and "As far as I understand, those flags should be set only when
the threshold is *reached*" [2] .
Now setting the flags for CAN_ERR_CRTL_[RT]X_WARNING and
CAN_ERR_CRTL_[RT]X_PASSIVE regarding REC and TEC, when the
appropriate threshold is reached.
Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device")
Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
Link: [1] https://lore.kernel.org/all/CAMZ6RqKGBWe15aMkf8-QLf-cOQg99GQBebSm+1wEzTqHgvmNuw@mail.gmail.com/
Link: [2] https://lore.kernel.org/all/CAMZ6Rq+QBO1yTX_o6GV0yhdBj-RzZSRGWDZBS0fs7zbSTy4hmA@mail.gmail.com/
---
drivers/net/can/usb/esd_usb.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
index 5e182fadd875..09745751f168 100644
--- a/drivers/net/can/usb/esd_usb.c
+++ b/drivers/net/can/usb/esd_usb.c
@@ -255,10 +255,18 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
can_bus_off(priv->netdev);
break;
case ESD_BUSSTATE_WARN:
+ cf->can_id |= CAN_ERR_CRTL;
+ cf->data[1] = (txerr > rxerr) ?
+ CAN_ERR_CRTL_TX_WARNING :
+ CAN_ERR_CRTL_RX_WARNING;
priv->can.state = CAN_STATE_ERROR_WARNING;
priv->can.can_stats.error_warning++;
break;
case ESD_BUSSTATE_ERRPASSIVE:
+ cf->can_id |= CAN_ERR_CRTL;
+ cf->data[1] = (txerr > rxerr) ?
+ CAN_ERR_CRTL_TX_PASSIVE :
+ CAN_ERR_CRTL_RX_PASSIVE;
priv->can.state = CAN_STATE_ERROR_PASSIVE;
priv->can.can_stats.error_passive++;
break;
@@ -296,12 +304,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
/* Bit stream position in CAN frame as the error was detected */
cf->data[3] = ecc & SJA1000_ECC_SEG;
- if (priv->can.state == CAN_STATE_ERROR_WARNING ||
- priv->can.state == CAN_STATE_ERROR_PASSIVE) {
- cf->data[1] = (txerr > rxerr) ?
- CAN_ERR_CRTL_TX_PASSIVE :
- CAN_ERR_CRTL_RX_PASSIVE;
- }
cf->data[6] = txerr;
cf->data[7] = rxerr;
}
--
2.25.1
^ permalink raw reply related
* [PATCH 3/3] can: esd_usb: Improved decoding for ESD_EV_CAN_ERROR_EXT messages
From: Frank Jungclaus @ 2022-12-19 21:27 UTC (permalink / raw)
To: linux-can, Marc Kleine-Budde, Wolfgang Grandegger,
Vincent Mailhol
Cc: Stefan Mätje, netdev, linux-kernel, Frank Jungclaus
In-Reply-To: <20221219212717.1298282-1-frank.jungclaus@esd.eu>
As suggested by Marc there now is a union plus a struct ev_can_err_ext
for easier decoding of an ESD_EV_CAN_ERROR_EXT event message (which
simply is a rx_msg with some dedicated data).
Suggested-by: Marc Kleine-Budde <mkl@pengutronix.de>
Link: https://lore.kernel.org/linux-can/20220621071152.ggyhrr5sbzvwpkpx@pengutronix.de/
Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
---
drivers/net/can/usb/esd_usb.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
index 09745751f168..f90bb2c0ba15 100644
--- a/drivers/net/can/usb/esd_usb.c
+++ b/drivers/net/can/usb/esd_usb.c
@@ -127,7 +127,15 @@ struct rx_msg {
u8 dlc;
__le32 ts;
__le32 id; /* upper 3 bits contain flags */
- u8 data[8];
+ union {
+ u8 data[8];
+ struct {
+ u8 status; /* CAN Controller Status */
+ u8 ecc; /* Error Capture Register */
+ u8 rec; /* RX Error Counter */
+ u8 tec; /* TX Error Counter */
+ } ev_can_err_ext; /* For ESD_EV_CAN_ERROR_EXT */
+ };
};
struct tx_msg {
@@ -229,10 +237,10 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
u32 id = le32_to_cpu(msg->msg.rx.id) & ESD_IDMASK;
if (id == ESD_EV_CAN_ERROR_EXT) {
- u8 state = msg->msg.rx.data[0];
- u8 ecc = msg->msg.rx.data[1];
- u8 rxerr = msg->msg.rx.data[2];
- u8 txerr = msg->msg.rx.data[3];
+ u8 state = msg->msg.rx.ev_can_err_ext.status;
+ u8 ecc = msg->msg.rx.ev_can_err_ext.ecc;
+ u8 rxerr = msg->msg.rx.ev_can_err_ext.rec;
+ u8 txerr = msg->msg.rx.ev_can_err_ext.tec;
netdev_dbg(priv->netdev,
"CAN_ERR_EV_EXT: dlc=%#02x state=%02x ecc=%02x rec=%02x tec=%02x\n",
--
2.25.1
^ permalink raw reply related
* Re: [PATCH bpf-next 2/2] selftests/bpf: Add BPF_F_NO_TUNNEL_KEY test
From: Jakub Sitnicki @ 2022-12-19 21:26 UTC (permalink / raw)
To: Christian Ehrig
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Mykola Lysenko,
Shuah Khan, Joanne Koong, Kui-Feng Lee, Kumar Kartikeya Dwivedi,
Maxim Mikityanskiy, Kaixi Fan, Paul Chaignon, Shmulik Ladkani,
linux-kernel, netdev, linux-kselftest
In-Reply-To: <20221218051734.31411-2-cehrig@cloudflare.com>
On Sun, Dec 18, 2022 at 06:17 AM +01, Christian Ehrig wrote:
> This patch adds a selftest simulating a GRE sender and receiver using
> tunnel headers without tunnel keys. It validates if packets encapsulated
> using BPF_F_NO_TUNNEL_KEY are decapsulated by a GRE receiver not
> configured with tunnel keys.
>
> Signed-off-by: Christian Ehrig <cehrig@cloudflare.com>
> ---
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
^ permalink raw reply
* Re: [PATCH bpf-next 1/2] bpf: Add flag BPF_F_NO_TUNNEL_KEY to bpf_skb_set_tunnel_key()
From: Jakub Sitnicki @ 2022-12-19 21:24 UTC (permalink / raw)
To: Christian Ehrig
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Mykola Lysenko,
Shuah Khan, Joanne Koong, Kui-Feng Lee, Maxim Mikityanskiy,
Kaixi Fan, Shmulik Ladkani, Paul Chaignon, linux-kernel, netdev,
linux-kselftest
In-Reply-To: <20221218051734.31411-1-cehrig@cloudflare.com>
On Sun, Dec 18, 2022 at 06:17 AM +01, Christian Ehrig wrote:
> This patch allows to remove TUNNEL_KEY from the tunnel flags bitmap
> when using bpf_skb_set_tunnel_key by providing a BPF_F_NO_TUNNEL_KEY
> flag. On egress, the resulting tunnel header will not contain a tunnel
> key if the protocol and implementation supports it.
>
> At the moment bpf_tunnel_key wants a user to specify a numeric tunnel
> key. This will wrap the inner packet into a tunnel header with the key
> bit and value set accordingly. This is problematic when using a tunnel
> protocol that supports optional tunnel keys and a receiving tunnel
> device that is not expecting packets with the key bit set. The receiver
> won't decapsulate and drop the packet.
>
> RFC 2890 and RFC 2784 GRE tunnels are examples where this flag is
> useful. It allows for generating packets, that can be decapsulated by
> a GRE tunnel device not operating in collect metadata mode or not
> expecting the key bit set.
>
> Signed-off-by: Christian Ehrig <cehrig@cloudflare.com>
> ---
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
^ permalink raw reply
* Re: [PATCH v1] iavfs/iavf_main: actually log ->src mask when talking about it
From: Tony Nguyen @ 2022-12-19 21:24 UTC (permalink / raw)
To: Daniil Tatianin, Jesse Brandeburg
Cc: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Harshitha Ramamurthy,
Jeff Kirsher, intel-wired-lan, netdev, linux-kernel
In-Reply-To: <20221216091326.1457454-1-d-tatianin@yandex-team.ru>
On 12/16/2022 1:13 AM, Daniil Tatianin wrote:
A couple of nits.
For the title, s/iavfs/iavf
> This fixes a copy-paste issue where dev_err would log the dst mask even
> though it is clearly talking about src.
>
> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> static analysis tool.
>
> Fixes: 0075fa0fadd0a ("i40evf: Add support to apply cloud filters")
This should just be 12 chars:
WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1>
("<title line>")' - ie: 'Fixes: 0075fa0fadd0 ("i40evf: Add support to
apply cloud filters")'
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> ---
> drivers/net/ethernet/intel/iavf/iavf_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index c4e451ef7942..adc02adef83a 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -3850,7 +3850,7 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
> field_flags |= IAVF_CLOUD_FIELD_IIP;
> } else {
> dev_err(&adapter->pdev->dev, "Bad ip src mask 0x%08x\n",
> - be32_to_cpu(match.mask->dst));
> + be32_to_cpu(match.mask->src));
> return -EINVAL;
> }
> }
^ permalink raw reply
* [PATCH 1/3] can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1)
From: Frank Jungclaus @ 2022-12-19 21:20 UTC (permalink / raw)
To: linux-can, Marc Kleine-Budde, Wolfgang Grandegger,
Vincent Mailhol
Cc: Stefan Mätje, netdev, linux-kernel, Frank Jungclaus
In-Reply-To: <20221219212013.1294820-1-frank.jungclaus@esd.eu>
Moved the supply for cf->data[3] (bit stream position of CAN error)
outside of the "switch (ecc & SJA1000_ECC_MASK){}"-statement, because
this position is independent of the error type.
Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device")
Signed-off-by: Frank Jungclaus <frank.jungclaus@esd.eu>
---
drivers/net/can/usb/esd_usb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
index 42323f5e6f3a..5e182fadd875 100644
--- a/drivers/net/can/usb/esd_usb.c
+++ b/drivers/net/can/usb/esd_usb.c
@@ -286,7 +286,6 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
cf->data[2] |= CAN_ERR_PROT_STUFF;
break;
default:
- cf->data[3] = ecc & SJA1000_ECC_SEG;
break;
}
@@ -294,6 +293,9 @@ static void esd_usb_rx_event(struct esd_usb_net_priv *priv,
if (!(ecc & SJA1000_ECC_DIR))
cf->data[2] |= CAN_ERR_PROT_TX;
+ /* Bit stream position in CAN frame as the error was detected */
+ cf->data[3] = ecc & SJA1000_ECC_SEG;
+
if (priv->can.state == CAN_STATE_ERROR_WARNING ||
priv->can.state == CAN_STATE_ERROR_PASSIVE) {
cf->data[1] = (txerr > rxerr) ?
--
2.25.1
^ permalink raw reply related
* [PATCH 0/3] can: esd_usb: Some more preparation for supporting esd CAN-USB/3
From: Frank Jungclaus @ 2022-12-19 21:20 UTC (permalink / raw)
To: linux-can, Marc Kleine-Budde, Wolfgang Grandegger,
Vincent Mailhol
Cc: Stefan Mätje, netdev, linux-kernel, Frank Jungclaus
Another small batch of patches to be seen as preparation for adding
support of the newly available esd CAN-USB/3 to esd_usb.c.
Due to some unresolved questions adding support for
CAN_CTRLMODE_BERR_REPORTING has been postponed to one of the future
patches.
Frank Jungclaus (3):
can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (1)
can: esd_usb: Improved behavior on esd CAN_ERROR_EXT event (2)
can: esd_usb: Improved decoding for ESD_EV_CAN_ERROR_EXT messages
drivers/net/can/usb/esd_usb.c | 36 +++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
base-commit: 47bf2b2393ea1aacdefbe4e9d643599e057bb3a2
--
2.25.1
^ permalink raw reply
* Re: [RFC bpf-next 2/8] net: introduce XDP features flag
From: sdf @ 2022-12-19 20:03 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: bpf, netdev, ast, daniel, andrii, davem, kuba, hawk, pabeni,
edumazet, toke, memxor, alardam, saeedm, anthony.l.nguyen, gospo,
vladimir.oltean, nbd, john, leon, simon.horman, aelior,
christophe.jaillet, ecree.xilinx, grygorii.strashko, mst, bjorn,
magnus.karlsson, maciej.fijalkowski, intel-wired-lan,
lorenzo.bianconi
In-Reply-To: <43c340d440d8a87396198b301c5ffbf5ab56f304.1671462950.git.lorenzo@kernel.org>
On 12/19, Lorenzo Bianconi wrote:
> From: Marek Majtyka <alardam@gmail.com>
> Implement support for checking what kind of XDP features a netdev
> supports. Previously, there was no way to do this other than to try to
> create an AF_XDP socket on the interface or load an XDP program and see
> if it worked. This commit changes this by adding a new variable which
> describes all xdp supported functions on pretty detailed level:
> - aborted
> - drop
> - pass
> - tx
> - redirect
> - sock_zerocopy
> - hw_offload
> - redirect_target
> - tx_lock
> - frag_rx
> - frag_target
> Zerocopy mode requires that redirect XDP operation is implemented in a
> driver and the driver supports also zero copy mode. Full mode requires
> that all XDP operation are implemented in the driver. Basic mode is just
> full mode without redirect operation. Frag target requires
> redirect_target one is supported by the driver.
Can you share more about _why_ is it needed? If we can already obtain
most of these signals via probing, why export the flags?
> Initially, these new flags are disabled for all drivers by default.
> Co-developed-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> Signed-off-by: Marek Majtyka <alardam@gmail.com>
> ---
> .../networking/netdev-xdp-features.rst | 60 +++++++++++++++++
> include/linux/netdevice.h | 2 +
> include/linux/xdp_features.h | 64 +++++++++++++++++++
> include/uapi/linux/if_link.h | 7 ++
> include/uapi/linux/xdp_features.h | 34 ++++++++++
> net/core/rtnetlink.c | 34 ++++++++++
> tools/include/uapi/linux/if_link.h | 7 ++
> tools/include/uapi/linux/xdp_features.h | 34 ++++++++++
> 8 files changed, 242 insertions(+)
> create mode 100644 Documentation/networking/netdev-xdp-features.rst
> create mode 100644 include/linux/xdp_features.h
> create mode 100644 include/uapi/linux/xdp_features.h
> create mode 100644 tools/include/uapi/linux/xdp_features.h
> diff --git a/Documentation/networking/netdev-xdp-features.rst
> b/Documentation/networking/netdev-xdp-features.rst
> new file mode 100644
> index 000000000000..1dc803fe72dd
> --- /dev/null
> +++ b/Documentation/networking/netdev-xdp-features.rst
> @@ -0,0 +1,60 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +=====================
> +Netdev XDP features
> +=====================
> +
> + * XDP FEATURES FLAGS
> +
> +Following netdev xdp features flags can be retrieved over route netlink
> +interface (compact form) - the same way as netdev feature flags.
> +These features flags are read only and cannot be change at runtime.
> +
> +* XDP_ABORTED
> +
> +This feature informs if netdev supports xdp aborted action.
> +
> +* XDP_DROP
> +
> +This feature informs if netdev supports xdp drop action.
> +
> +* XDP_PASS
> +
> +This feature informs if netdev supports xdp pass action.
> +
> +* XDP_TX
> +
> +This feature informs if netdev supports xdp tx action.
> +
> +* XDP_REDIRECT
> +
> +This feature informs if netdev supports xdp redirect action.
> +It assumes the all beforehand mentioned flags are enabled.
> +
> +* XDP_SOCK_ZEROCOPY
> +
> +This feature informs if netdev driver supports xdp zero copy.
> +It assumes the all beforehand mentioned flags are enabled.
> +
> +* XDP_HW_OFFLOAD
> +
> +This feature informs if netdev driver supports xdp hw oflloading.
> +
> +* XDP_TX_LOCK
> +
> +This feature informs if netdev ndo_xdp_xmit function requires locking.
> +
> +* XDP_REDIRECT_TARGET
> +
> +This feature informs if netdev implements ndo_xdp_xmit callback.
> +
> +* XDP_FRAG_RX
> +
> +This feature informs if netdev implements non-linear xdp buff support in
> +the driver napi callback.
> +
> +* XDP_FRAG_TARGET
> +
> +This feature informs if netdev implements non-linear xdp buff support in
> +ndo_xdp_xmit callback. XDP_FRAG_TARGET requires XDP_REDIRECT_TARGET is
> properly
> +supported.
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index aad12a179e54..ae5a8564383b 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -43,6 +43,7 @@
> #include <net/xdp.h>
> #include <linux/netdev_features.h>
> +#include <linux/xdp_features.h>
> #include <linux/neighbour.h>
> #include <uapi/linux/netdevice.h>
> #include <uapi/linux/if_bonding.h>
> @@ -2362,6 +2363,7 @@ struct net_device {
> struct rtnl_hw_stats64 *offload_xstats_l3;
> struct devlink_port *devlink_port;
> + xdp_features_t xdp_features;
> };
> #define to_net_dev(d) container_of(d, struct net_device, dev)
> diff --git a/include/linux/xdp_features.h b/include/linux/xdp_features.h
> new file mode 100644
> index 000000000000..4e72a86ef329
> --- /dev/null
> +++ b/include/linux/xdp_features.h
> @@ -0,0 +1,64 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Network device xdp features.
> + */
> +#ifndef _LINUX_XDP_FEATURES_H
> +#define _LINUX_XDP_FEATURES_H
> +
> +#include <linux/types.h>
> +#include <linux/bitops.h>
> +#include <asm/byteorder.h>
> +#include <uapi/linux/xdp_features.h>
> +
> +typedef u32 xdp_features_t;
> +
> +#define __XDP_F_BIT(bit) ((xdp_features_t)1 << (bit))
> +#define __XDP_F(name) __XDP_F_BIT(XDP_F_##name##_BIT)
> +
> +#define XDP_F_ABORTED __XDP_F(ABORTED)
> +#define XDP_F_DROP __XDP_F(DROP)
> +#define XDP_F_PASS __XDP_F(PASS)
> +#define XDP_F_TX __XDP_F(TX)
> +#define XDP_F_REDIRECT __XDP_F(REDIRECT)
> +#define XDP_F_REDIRECT_TARGET __XDP_F(REDIRECT_TARGET)
> +#define XDP_F_SOCK_ZEROCOPY __XDP_F(SOCK_ZEROCOPY)
> +#define XDP_F_HW_OFFLOAD __XDP_F(HW_OFFLOAD)
> +#define XDP_F_TX_LOCK __XDP_F(TX_LOCK)
> +#define XDP_F_FRAG_RX __XDP_F(FRAG_RX)
> +#define XDP_F_FRAG_TARGET __XDP_F(FRAG_TARGET)
> +
> +#define XDP_F_BASIC (XDP_F_ABORTED | XDP_F_DROP | \
> + XDP_F_PASS | XDP_F_TX)
> +
> +#define XDP_F_FULL (XDP_F_BASIC | XDP_F_REDIRECT)
> +
> +#define XDP_F_FULL_ZC (XDP_F_FULL | XDP_F_SOCK_ZEROCOPY)
> +
> +#define XDP_FEATURES_ABORTED_STR "xdp-aborted"
> +#define XDP_FEATURES_DROP_STR "xdp-drop"
> +#define XDP_FEATURES_PASS_STR "xdp-pass"
> +#define XDP_FEATURES_TX_STR "xdp-tx"
> +#define XDP_FEATURES_REDIRECT_STR "xdp-redirect"
> +#define XDP_FEATURES_REDIRECT_TARGET_STR "xdp-redirect-target"
> +#define XDP_FEATURES_SOCK_ZEROCOPY_STR "xdp-sock-zerocopy"
> +#define XDP_FEATURES_HW_OFFLOAD_STR "xdp-hw-offload"
> +#define XDP_FEATURES_TX_LOCK_STR "xdp-tx-lock"
> +#define XDP_FEATURES_FRAG_RX_STR "xdp-frag-rx"
> +#define XDP_FEATURES_FRAG_TARGET_STR "xdp-frag-target"
> +
> +#define DECLARE_XDP_FEATURES_TABLE(name, length) \
> + const char name[][length] = { \
> + [XDP_F_ABORTED_BIT] = XDP_FEATURES_ABORTED_STR, \
> + [XDP_F_DROP_BIT] = XDP_FEATURES_DROP_STR, \
> + [XDP_F_PASS_BIT] = XDP_FEATURES_PASS_STR, \
> + [XDP_F_TX_BIT] = XDP_FEATURES_TX_STR, \
> + [XDP_F_REDIRECT_BIT] = XDP_FEATURES_REDIRECT_STR, \
> + [XDP_F_REDIRECT_TARGET_BIT] = XDP_FEATURES_REDIRECT_TARGET_STR, \
> + [XDP_F_SOCK_ZEROCOPY_BIT] = XDP_FEATURES_SOCK_ZEROCOPY_STR, \
> + [XDP_F_HW_OFFLOAD_BIT] = XDP_FEATURES_HW_OFFLOAD_STR, \
> + [XDP_F_TX_LOCK_BIT] = XDP_FEATURES_TX_LOCK_STR, \
> + [XDP_F_FRAG_RX_BIT] = XDP_FEATURES_FRAG_RX_STR, \
> + [XDP_F_FRAG_TARGET_BIT] = XDP_FEATURES_FRAG_TARGET_STR, \
> + }
> +
> +#endif /* _LINUX_XDP_FEATURES_H */
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index 1021a7e47a86..971c658ceaea 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -374,6 +374,8 @@ enum {
> IFLA_DEVLINK_PORT,
> + IFLA_XDP_FEATURES,
> +
> __IFLA_MAX
> };
> @@ -1318,6 +1320,11 @@ enum {
> #define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1)
> +enum {
> + IFLA_XDP_FEATURES_WORD_UNSPEC = 0,
> + IFLA_XDP_FEATURES_BITS_WORD,
> +};
> +
> enum {
> IFLA_EVENT_NONE,
> IFLA_EVENT_REBOOT, /* internal reset / reboot */
> diff --git a/include/uapi/linux/xdp_features.h
> b/include/uapi/linux/xdp_features.h
> new file mode 100644
> index 000000000000..48eb42069bcd
> --- /dev/null
> +++ b/include/uapi/linux/xdp_features.h
> @@ -0,0 +1,34 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +/*
> + * Copyright (c) 2020 Intel
> + */
> +
> +#ifndef __UAPI_LINUX_XDP_FEATURES__
> +#define __UAPI_LINUX_XDP_FEATURES__
> +
> +enum {
> + XDP_F_ABORTED_BIT,
> + XDP_F_DROP_BIT,
> + XDP_F_PASS_BIT,
> + XDP_F_TX_BIT,
> + XDP_F_REDIRECT_BIT,
> + XDP_F_REDIRECT_TARGET_BIT,
> + XDP_F_SOCK_ZEROCOPY_BIT,
> + XDP_F_HW_OFFLOAD_BIT,
> + XDP_F_TX_LOCK_BIT,
> + XDP_F_FRAG_RX_BIT,
> + XDP_F_FRAG_TARGET_BIT,
> + /*
> + * Add your fresh new property above and remember to update
> + * documentation.
> + */
> + XDP_FEATURES_COUNT,
> +};
> +
> +#define XDP_FEATURES_WORDS ((XDP_FEATURES_COUNT + 32 - 1) / 32)
> +#define XDP_FEATURES_WORD(blocks, index) ((blocks)[(index) / 32U])
> +#define XDP_FEATURES_FIELD_FLAG(index) (1U << (index) % 32U)
> +#define XDP_FEATURES_BIT_IS_SET(blocks, index) \
> + (XDP_FEATURES_WORD(blocks, index) & XDP_FEATURES_FIELD_FLAG(index))
> +
> +#endif /* __UAPI_LINUX_XDP_FEATURES__ */
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 64289bc98887..1c299746b614 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -1016,6 +1016,14 @@ static size_t rtnl_xdp_size(void)
> return xdp_size;
> }
> +static size_t rtnl_xdp_features_size(void)
> +{
> + size_t xdp_size = nla_total_size(0) + /* nest IFLA_XDP_FEATURES */
> + XDP_FEATURES_WORDS * nla_total_size(4);
> +
> + return xdp_size;
> +}
> +
> static size_t rtnl_prop_list_size(const struct net_device *dev)
> {
> struct netdev_name_node *name_node;
> @@ -1103,6 +1111,7 @@ static noinline size_t if_nlmsg_size(const struct
> net_device *dev,
> + rtnl_prop_list_size(dev)
> + nla_total_size(MAX_ADDR_LEN) /* IFLA_PERM_ADDRESS */
> + rtnl_devlink_port_size(dev)
> + + rtnl_xdp_features_size() /* IFLA_XDP_FEATURES */
> + 0;
> }
> @@ -1546,6 +1555,27 @@ static int rtnl_xdp_fill(struct sk_buff *skb,
> struct net_device *dev)
> return err;
> }
> +static int rtnl_xdp_features_fill(struct sk_buff *skb, struct net_device
> *dev)
> +{
> + struct nlattr *attr;
> +
> + attr = nla_nest_start_noflag(skb, IFLA_XDP_FEATURES);
> + if (!attr)
> + return -EMSGSIZE;
> +
> + BUILD_BUG_ON(XDP_FEATURES_WORDS != 1);
> + if (nla_put_u32(skb, IFLA_XDP_FEATURES_BITS_WORD, dev->xdp_features))
> + goto err_cancel;
> +
> + nla_nest_end(skb, attr);
> +
> + return 0;
> +
> +err_cancel:
> + nla_nest_cancel(skb, attr);
> + return -EMSGSIZE;
> +}
> +
> static u32 rtnl_get_event(unsigned long event)
> {
> u32 rtnl_event_type = IFLA_EVENT_NONE;
> @@ -1904,6 +1934,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
> if (rtnl_fill_devlink_port(skb, dev))
> goto nla_put_failure;
> + if (rtnl_xdp_features_fill(skb, dev))
> + goto nla_put_failure;
> +
> nlmsg_end(skb, nlh);
> return 0;
> @@ -1968,6 +2001,7 @@ static const struct nla_policy
> ifla_policy[IFLA_MAX+1] = {
> [IFLA_TSO_MAX_SIZE] = { .type = NLA_REJECT },
> [IFLA_TSO_MAX_SEGS] = { .type = NLA_REJECT },
> [IFLA_ALLMULTI] = { .type = NLA_REJECT },
> + [IFLA_XDP_FEATURES] = { .type = NLA_NESTED },
> };
> static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
> diff --git a/tools/include/uapi/linux/if_link.h
> b/tools/include/uapi/linux/if_link.h
> index 82fe18f26db5..994228e9909a 100644
> --- a/tools/include/uapi/linux/if_link.h
> +++ b/tools/include/uapi/linux/if_link.h
> @@ -354,6 +354,8 @@ enum {
> IFLA_DEVLINK_PORT,
> + IFLA_XDP_FEATURES,
> +
> __IFLA_MAX
> };
> @@ -1222,6 +1224,11 @@ enum {
> #define IFLA_XDP_MAX (__IFLA_XDP_MAX - 1)
> +enum {
> + IFLA_XDP_FEATURES_WORD_UNSPEC = 0,
> + IFLA_XDP_FEATURES_BITS_WORD,
> +};
> +
> enum {
> IFLA_EVENT_NONE,
> IFLA_EVENT_REBOOT, /* internal reset / reboot */
> diff --git a/tools/include/uapi/linux/xdp_features.h
> b/tools/include/uapi/linux/xdp_features.h
> new file mode 100644
> index 000000000000..48eb42069bcd
> --- /dev/null
> +++ b/tools/include/uapi/linux/xdp_features.h
> @@ -0,0 +1,34 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +/*
> + * Copyright (c) 2020 Intel
> + */
> +
> +#ifndef __UAPI_LINUX_XDP_FEATURES__
> +#define __UAPI_LINUX_XDP_FEATURES__
> +
> +enum {
> + XDP_F_ABORTED_BIT,
> + XDP_F_DROP_BIT,
> + XDP_F_PASS_BIT,
> + XDP_F_TX_BIT,
> + XDP_F_REDIRECT_BIT,
> + XDP_F_REDIRECT_TARGET_BIT,
> + XDP_F_SOCK_ZEROCOPY_BIT,
> + XDP_F_HW_OFFLOAD_BIT,
> + XDP_F_TX_LOCK_BIT,
> + XDP_F_FRAG_RX_BIT,
> + XDP_F_FRAG_TARGET_BIT,
> + /*
> + * Add your fresh new property above and remember to update
> + * documentation.
> + */
> + XDP_FEATURES_COUNT,
> +};
> +
> +#define XDP_FEATURES_WORDS ((XDP_FEATURES_COUNT + 32 - 1) / 32)
> +#define XDP_FEATURES_WORD(blocks, index) ((blocks)[(index) / 32U])
> +#define XDP_FEATURES_FIELD_FLAG(index) (1U << (index) % 32U)
> +#define XDP_FEATURES_BIT_IS_SET(blocks, index) \
> + (XDP_FEATURES_WORD(blocks, index) & XDP_FEATURES_FIELD_FLAG(index))
> +
> +#endif /* __UAPI_LINUX_XDP_FEATURES__ */
> --
> 2.38.1
^ permalink raw reply
* Re: [syzbot] KASAN: use-after-free Read in put_pmu_ctx
From: syzbot @ 2022-12-19 19:56 UTC (permalink / raw)
To: acme, alexander.shishkin, bpf, jolsa, linux-kernel,
linux-perf-users, mark.rutland, mingo, namhyung, netdev, peterz,
sdf, syzkaller-bugs
In-Reply-To: <Y6C8iQGENUk/XY/A@google.com>
Hello,
syzbot tried to test the proposed patch but the build/boot failed:
failed to apply patch:
checking file kernel/events/core.c
patch: **** unexpected end of file in patch
Tested on:
commit: 13e3c779 Merge tag 'for-netdev' of https://git.kernel...
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
dashboard link: https://syzkaller.appspot.com/bug?extid=b8e8c01c8ade4fe6e48f
compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=15861a9f880000
^ permalink raw reply
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