* Re: [bpf-next V2 PATCH 4/8] tun: implement flush flag for ndo_xdp_xmit
From: Song Liu @ 2018-05-31 16:14 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: Networking, Daniel Borkmann, Alexei Starovoitov, Song Liu,
John Fastabend
In-Reply-To: <152775720301.24817.4050947353101519726.stgit@firesoul>
On Thu, May 31, 2018 at 2:00 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> When passed the XDP_XMIT_FLUSH flag tun_xdp_xmit now performs the same
> kind of socket wake up as in tun_xdp_flush(). The wake up code from
> tun_xdp_flush is generalized and shared with tun_xdp_xmit.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Song Liu <songliubraving@fb.com>
> ---
> drivers/net/tun.c | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index b182b8cdd219..d82a05fb0594 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1285,6 +1285,14 @@ static const struct net_device_ops tun_netdev_ops = {
> .ndo_get_stats64 = tun_net_get_stats64,
> };
>
> +static void __tun_xdp_flush_tfile(struct tun_file *tfile)
> +{
> + /* Notify and wake up reader process */
> + if (tfile->flags & TUN_FASYNC)
> + kill_fasync(&tfile->fasync, SIGIO, POLL_IN);
> + tfile->socket.sk->sk_data_ready(tfile->socket.sk);
> +}
> +
> static int tun_xdp_xmit(struct net_device *dev, int n,
> struct xdp_frame **frames, u32 flags)
> {
> @@ -1295,7 +1303,7 @@ static int tun_xdp_xmit(struct net_device *dev, int n,
> int cnt = n;
> int i;
>
> - if (unlikely(flags & ~XDP_XMIT_FLAGS_NONE))
> + if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
> return -EINVAL;
>
> rcu_read_lock();
> @@ -1325,6 +1333,9 @@ static int tun_xdp_xmit(struct net_device *dev, int n,
> }
> spin_unlock(&tfile->tx_ring.producer_lock);
>
> + if (flags & XDP_XMIT_FLUSH)
> + __tun_xdp_flush_tfile(tfile);
> +
> rcu_read_unlock();
> return cnt - drops;
> }
> @@ -1353,11 +1364,7 @@ static void tun_xdp_flush(struct net_device *dev)
>
> tfile = rcu_dereference(tun->tfiles[smp_processor_id() %
> numqueues]);
> - /* Notify and wake up reader process */
> - if (tfile->flags & TUN_FASYNC)
> - kill_fasync(&tfile->fasync, SIGIO, POLL_IN);
> - tfile->socket.sk->sk_data_ready(tfile->socket.sk);
> -
> + __tun_xdp_flush_tfile(tfile);
> out:
> rcu_read_unlock();
> }
>
^ permalink raw reply
* Re: [bpf-next V2 PATCH 5/8] virtio_net: implement flush flag for ndo_xdp_xmit
From: Song Liu @ 2018-05-31 16:15 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: Networking, Daniel Borkmann, Alexei Starovoitov, Song Liu,
John Fastabend
In-Reply-To: <152775720805.24817.1149926292475954272.stgit@firesoul>
On Thu, May 31, 2018 at 2:00 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> When passed the XDP_XMIT_FLUSH flag virtnet_xdp_xmit now performs the
> same virtqueue_kick as virtnet_xdp_flush.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Song Liu <songliubraving@fb.com>
> ---
> drivers/net/virtio_net.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 4ed823625953..62ba8aadd8e6 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -481,7 +481,7 @@ static int virtnet_xdp_xmit(struct net_device *dev,
> int err;
> int i;
>
> - if (unlikely(flags & ~XDP_XMIT_FLAGS_NONE))
> + if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
> return -EINVAL;
>
> qp = vi->curr_queue_pairs - vi->xdp_queue_pairs + smp_processor_id();
> @@ -507,6 +507,10 @@ static int virtnet_xdp_xmit(struct net_device *dev,
> drops++;
> }
> }
> +
> + if (flags & XDP_XMIT_FLUSH)
> + virtqueue_kick(sq->vq);
> +
> return n - drops;
> }
>
>
^ permalink raw reply
* Re: [PATCH rdma-next v3 00/14] Verbs flow counters support
From: Yishai Hadas @ 2018-05-31 16:15 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe
Cc: Leon Romanovsky, Leon Romanovsky, RDMA mailing list,
Boris Pismenny, Matan Barak, Michael J . Ruhl, Or Gerlitz,
Raed Salem, Yishai Hadas, Saeed Mahameed, linux-netdev
In-Reply-To: <20180531134341.18441-1-leon@kernel.org>
On 5/31/2018 4:43 PM, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
>
> Changelog:
> v2->v3:
> * Change function mlx5_fc_query signature to hide the details of
> internal core driver struct mlx5_fc
> * Add commen to data[] field at struct mlx5_ib_flow_counters_data (mlx5-abi.h)
> * Use array of struct mlx5_ib_flow_counters_desc to clarify the output
> v1->v2:
> * Removed conversion from struct mlx5_fc* to void*
> * Fixed one place with double space in it
> * Balanced release of hardware handler in case of counters allocation failure
> * Added Tested-by
> * Minimize time spent holding mutex lock
> * Fixed deadlock caused by nested lock in error path
> * Protect from handler pointer derefence in the error paths
>
> Not changed: mlx5-abi.h
>
> v0->v1:
> * Decouple from DevX submission
> * Use uverbs_attr_get_obj at counters read method
> * Added define for max read buffer size (MAX_COUNTERS_BUFF_SIZE)
> * Removed the struct mlx5_ib_flow_counter basic_flow_cnts and
> the related structs used, used define instead
> * Took Matan's patch from DevX
> * uverbs_free_counters removed void* casting
> * Added check to bound ncounters value (added define
> * Changed user supplied data buffer structure to be array of
> struct <desc,index> pair (applied this change to user space also)
>
> Not changed:
> * UAPI files
> * Addition of uhw to flow
>
> Thanks
The corresponding rdma-core PR [1] was updated to match this V3 series.
[1] https://github.com/linux-rdma/rdma-core/pull/330
Yishai
> ----------------------------------------------------------------------
> From Raed:
>
> This series comes to allow user space applications to monitor real time
> traffic activity and events of the verbs objects it manages, e.g.:
> ibv_qp, ibv_wq, ibv_flow.
>
> This API enables generic counters creation and define mapping
> to association with a verbs object, current mlx5 driver using
> this API for flow counters.
>
> With this API, an application can monitor the entire life cycle of
> object activity, defined here as a static counters attachment.
> This API also allows dynamic counters monitoring of measurement points
> for a partial period in the verbs object life cycle.
>
> In addition it presents the implementation of the generic counters interface.
>
> This will be achieved by extending flow creation by adding a new flow count
> specification type which allows the user to associate a previously created
> flow counters using the generic verbs counters interface to the created flow,
> once associated the user could read statistics by using the read function of
> the generic counters interface.
>
> The API includes:
> 1. create and destroyed API of a new counters objects
> 2. read the counters values from HW
>
> Note:
> Attaching API to allow application to define the measurement points per objects
> is a user space only API and this data is passed to kernel when the counted
> object (e.g. flow) is created with the counters object.
>
> Thanks
>
> Matan Barak (2):
> IB/uverbs: Add an ib_uobject getter to ioctl() infrastructure
> IB/core: Support passing uhw for create_flow
>
> Or Gerlitz (1):
> net/mlx5: Use flow counter pointer as input to the query function
>
> Raed Salem (11):
> net/mlx5: Export flow counter related API
> IB/core: Introduce counters object and its create/destroy
> IB/uverbs: Add create/destroy counters support
> IB/core: Introduce counters read verb
> IB/uverbs: Add read counters support
> IB/core: Add support for flow counters
> IB/uverbs: Add support for flow counters
> IB/mlx5: Add counters create and destroy support
> IB/mlx5: Add flow counters binding support
> IB/mlx5: Add flow counters read support
> IB/mlx5: Add counters read support
>
> drivers/infiniband/core/Makefile | 2 +-
> drivers/infiniband/core/uverbs.h | 2 +
> drivers/infiniband/core/uverbs_cmd.c | 88 +++++-
> drivers/infiniband/core/uverbs_std_types.c | 3 +-
> .../infiniband/core/uverbs_std_types_counters.c | 157 +++++++++++
> drivers/infiniband/core/uverbs_std_types_cq.c | 23 +-
> .../infiniband/core/uverbs_std_types_flow_action.c | 4 +-
> drivers/infiniband/core/verbs.c | 2 +-
> drivers/infiniband/hw/mlx4/main.c | 6 +-
> drivers/infiniband/hw/mlx5/main.c | 305 ++++++++++++++++++++-
> drivers/infiniband/hw/mlx5/mlx5_ib.h | 36 +++
> drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 15 +-
> drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 2 -
> .../net/ethernet/mellanox/mlx5/core/fs_counters.c | 7 +-
> include/linux/mlx5/fs.h | 4 +
> include/rdma/ib_verbs.h | 43 ++-
> include/rdma/uverbs_ioctl.h | 11 +
> include/uapi/rdma/ib_user_ioctl_cmds.h | 21 ++
> include/uapi/rdma/ib_user_verbs.h | 13 +
> include/uapi/rdma/mlx5-abi.h | 24 ++
> 20 files changed, 712 insertions(+), 56 deletions(-)
> create mode 100644 drivers/infiniband/core/uverbs_std_types_counters.c
>
> --
> 2.14.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [bpf-next V2 PATCH 6/8] xdp: done implementing ndo_xdp_xmit flush flag for all drivers
From: Song Liu @ 2018-05-31 16:16 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: Networking, Daniel Borkmann, Alexei Starovoitov, Song Liu,
John Fastabend
In-Reply-To: <152775721311.24817.8828370689349824973.stgit@firesoul>
On Thu, May 31, 2018 at 2:00 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> Removing XDP_XMIT_FLAGS_NONE as all driver now implement
> a flush operation in their ndo_xdp_xmit call. The compiler
> will catch if any users of XDP_XMIT_FLAGS_NONE remains.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Song Liu <songliubraving@fb.com>
> ---
> include/net/xdp.h | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/include/net/xdp.h b/include/net/xdp.h
> index 0c45f0f943ed..a3b71a4dd71d 100644
> --- a/include/net/xdp.h
> +++ b/include/net/xdp.h
> @@ -41,7 +41,6 @@ enum xdp_mem_type {
> };
>
> /* XDP flags for ndo_xdp_xmit */
> -#define XDP_XMIT_FLAGS_NONE 0U
> #define XDP_XMIT_FLUSH (1U << 0) /* doorbell signal consumer */
> #define XDP_XMIT_FLAGS_MASK XDP_XMIT_FLUSH
>
>
^ permalink raw reply
* Re: [bpf-next V2 PATCH 7/8] bpf/xdp: non-map redirect can avoid calling ndo_xdp_flush
From: Song Liu @ 2018-05-31 16:16 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: Networking, Daniel Borkmann, Alexei Starovoitov, Song Liu,
John Fastabend
In-Reply-To: <152775721817.24817.11576562399044807823.stgit@firesoul>
On Thu, May 31, 2018 at 2:00 AM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> This is the first real user of the XDP_XMIT_FLUSH flag.
>
> As pointed out many times, XDP_REDIRECT without using BPF maps is
> significant slower than the map variant. This is primary due to the
> lack of bulking, as the ndo_xdp_flush operation is required after each
> frame (to avoid frames hanging on the egress device).
>
> It is still possible to optimize this case. Instead of invoking two
> NDO indirect calls, which are very expensive with CONFIG_RETPOLINE,
> instead instruct ndo_xdp_xmit to flush via XDP_XMIT_FLUSH flag.
>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Acked-by: Song Liu <songliubraving@fb.com>
> ---
> net/core/filter.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 6a21dbcad350..6981b4608979 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -3056,10 +3056,9 @@ static int __bpf_tx_xdp(struct net_device *dev,
> if (unlikely(!xdpf))
> return -EOVERFLOW;
>
> - sent = dev->netdev_ops->ndo_xdp_xmit(dev, 1, &xdpf, 0);
> + sent = dev->netdev_ops->ndo_xdp_xmit(dev, 1, &xdpf, XDP_XMIT_FLUSH);
> if (sent <= 0)
> return sent;
> - dev->netdev_ops->ndo_xdp_flush(dev);
> return 0;
> }
>
>
^ permalink raw reply
* Re: [PATCH v2] netfilter: properly initialize xt_table_info structure
From: Greg Kroah-Hartman @ 2018-05-31 16:25 UTC (permalink / raw)
To: Michal Kubecek
Cc: peter pi, Florian Westphal, Jan Engelhardt, Eric Dumazet,
Greg Hackmann, Pablo Neira Ayuso, Jozsef Kadlecsik,
netfilter-devel, coreteam, netdev
In-Reply-To: <20180531115557.sxfbgtgzy5gh5ldl@unicorn.suse.cz>
On Thu, May 31, 2018 at 01:55:57PM +0200, Michal Kubecek wrote:
> On Thu, May 31, 2018 at 01:32:16PM +0200, Michal Kubecek wrote:
> > I think I start to understand the problem. IPT_SO_GET_ENTRIES leads to
> > calling copy_entries_to_user() which copies the entries as they are to
> > user provided buffer. It also copies instances of struct xt_entry_match
> > and struct xt_entry_target which contain kernel pointers. We then
> > rewrite them with match/target name for userspace but the layout looks
> > (on x86_64) like this
> >
> > /* offset | size */ type = struct xt_entry_match {
> > /* 0 | 32 */ union {
> > /* 32 */ struct {
> > /* 0 | 2 */ __u16 match_size;
> > /* 2 | 29 */ char name[29];
> > /* 31 | 1 */ __u8 revision;
> >
> > /* total size (bytes): 32 */
> > } user;
> > /* 16 */ struct {
> > /* 0 | 2 */ __u16 match_size;
> > /* XXX 6-byte hole */
> > /* 8 | 8 */ struct xt_match *match;
> >
> > /* total size (bytes): 16 */
> > } kernel;
> > /* 2 */ __u16 match_size;
> >
> > /* total size (bytes): 32 */
> > } u;
> > /* 32 | 0 */ unsigned char data[];
> >
> > /* total size (bytes): 32 */
> > }
> >
> >
> > so that if match name is no longer than five characters (which is often
> > the case), writing to .u.user.name leaves .u.kernel.match untouched. The
> > same problem exists in struct xt_entry_target.
>
> And this should no longer happen since the series
>
> f32815d21d4d ("xtables: add xt_match, xt_target and data copy_to_user functions")
> f77bc5b23fb1 ("iptables: use match, target and data copy_to_user helpers")
> e47ddb2c4691 ("ip6tables: use match, target and data copy_to_user helpers")
> 244b531bee2b ("arptables: use match, target and data copy_to_user helpers")
> b5040f6c33a5 ("ebtables: use match, target and data copy_to_user helpers")
> 4915f7bbc402 ("xtables: use match, target and data copy_to_user helpers in compat")
> ec2318904965 ("xtables: extend matches and targets with .usersize")
>
> changed the logic in 4.11-rc1.
Thank you so much for the detailed description. And sorry for digging
up this old issue. Peter, if you could verify that you do not see this
issue on a kernel newer than 4.11, that would be wonderful.
Michal, do you think it is worth backporting those commits to the 4.9.y
and 4.4.y stable kernels to remove this problem there?
thanks,
greg k-h
^ permalink raw reply
* [PATCH net-next] netfilter: nf_tables: check msg_type before nft_trans_set(trans)
From: Alexey Kodanev @ 2018-05-31 16:53 UTC (permalink / raw)
To: netfilter-devel
Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal, coreteam,
netdev, Alexey Kodanev
The patch moves the "trans->msg_type == NFT_MSG_NEWSET" check before
using nft_trans_set(trans). Otherwise we can get out of bounds read.
For example, KASAN reported the one when running 0001_cache_handling_0 nft
test. In this case "trans->msg_type" was NFT_MSG_NEWTABLE:
[75517.177808] BUG: KASAN: slab-out-of-bounds in nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75517.279094] Read of size 8 at addr ffff881bdb643fc8 by task nft/7356
...
[75517.375605] CPU: 26 PID: 7356 Comm: nft Tainted: G E 4.17.0-rc7.1.x86_64 #1
[75517.489587] Hardware name: Oracle Corporation SUN SERVER X4-2
[75517.618129] Call Trace:
[75517.648821] dump_stack+0xd1/0x13b
[75517.691040] ? show_regs_print_info+0x5/0x5
[75517.742519] ? kmsg_dump_rewind_nolock+0xf5/0xf5
[75517.799300] ? lock_acquire+0x143/0x310
[75517.846738] print_address_description+0x85/0x3a0
[75517.904547] kasan_report+0x18d/0x4b0
[75517.949892] ? nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75518.019153] ? nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75518.088420] ? nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75518.157689] nft_set_lookup_global+0x22f/0x270 [nf_tables]
[75518.224869] nf_tables_newsetelem+0x1a5/0x5d0 [nf_tables]
[75518.291024] ? nft_add_set_elem+0x2280/0x2280 [nf_tables]
[75518.357154] ? nla_parse+0x1a5/0x300
[75518.401455] ? kasan_kmalloc+0xa6/0xd0
[75518.447842] nfnetlink_rcv+0xc43/0x1bdf [nfnetlink]
[75518.507743] ? nfnetlink_rcv+0x7a5/0x1bdf [nfnetlink]
[75518.569745] ? nfnl_err_reset+0x3c0/0x3c0 [nfnetlink]
[75518.631711] ? lock_acquire+0x143/0x310
[75518.679133] ? netlink_deliver_tap+0x9b/0x1070
[75518.733840] ? kasan_unpoison_shadow+0x31/0x40
[75518.788542] netlink_unicast+0x45d/0x680
[75518.837111] ? __isolate_free_page+0x890/0x890
[75518.891913] ? netlink_attachskb+0x6b0/0x6b0
[75518.944542] netlink_sendmsg+0x6fa/0xd30
[75518.993107] ? netlink_unicast+0x680/0x680
[75519.043758] ? netlink_unicast+0x680/0x680
[75519.094402] sock_sendmsg+0xd9/0x160
[75519.138810] ___sys_sendmsg+0x64d/0x980
[75519.186234] ? copy_msghdr_from_user+0x350/0x350
[75519.243118] ? lock_downgrade+0x650/0x650
[75519.292738] ? do_raw_spin_unlock+0x5d/0x250
[75519.345456] ? _raw_spin_unlock+0x24/0x30
[75519.395065] ? __handle_mm_fault+0xbde/0x3410
[75519.448830] ? sock_setsockopt+0x3d2/0x1940
[75519.500516] ? __lock_acquire.isra.25+0xdc/0x19d0
[75519.558448] ? lock_downgrade+0x650/0x650
[75519.608057] ? __audit_syscall_entry+0x317/0x720
[75519.664960] ? __fget_light+0x58/0x250
[75519.711325] ? __sys_sendmsg+0xde/0x170
[75519.758850] __sys_sendmsg+0xde/0x170
[75519.804193] ? __ia32_sys_shutdown+0x90/0x90
[75519.856725] ? syscall_trace_enter+0x897/0x10e0
[75519.912354] ? trace_event_raw_event_sys_enter+0x920/0x920
[75519.979432] ? __audit_syscall_entry+0x720/0x720
[75520.036118] do_syscall_64+0xa3/0x3d0
[75520.081248] ? prepare_exit_to_usermode+0x47/0x1d0
[75520.139904] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[75520.201680] RIP: 0033:0x7fc153320ba0
[75520.245772] RSP: 002b:00007ffe294c3638 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
[75520.337708] RAX: ffffffffffffffda RBX: 00007ffe294c4820 RCX: 00007fc153320ba0
[75520.424547] RDX: 0000000000000000 RSI: 00007ffe294c46b0 RDI: 0000000000000003
[75520.511386] RBP: 00007ffe294c47b0 R08: 0000000000000004 R09: 0000000002114090
[75520.598225] R10: 00007ffe294c30a0 R11: 0000000000000246 R12: 00007ffe294c3660
[75520.684961] R13: 0000000000000001 R14: 00007ffe294c3650 R15: 0000000000000001
[75520.790946] Allocated by task 7356:
[75520.833994] kasan_kmalloc+0xa6/0xd0
[75520.878088] __kmalloc+0x189/0x450
[75520.920107] nft_trans_alloc_gfp+0x20/0x190 [nf_tables]
[75520.983961] nf_tables_newtable+0xcd0/0x1bd0 [nf_tables]
[75521.048857] nfnetlink_rcv+0xc43/0x1bdf [nfnetlink]
[75521.108655] netlink_unicast+0x45d/0x680
[75521.157013] netlink_sendmsg+0x6fa/0xd30
[75521.205271] sock_sendmsg+0xd9/0x160
[75521.249365] ___sys_sendmsg+0x64d/0x980
[75521.296686] __sys_sendmsg+0xde/0x170
[75521.341822] do_syscall_64+0xa3/0x3d0
[75521.386957] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[75521.467867] Freed by task 23454:
[75521.507804] __kasan_slab_free+0x132/0x180
[75521.558137] kfree+0x14d/0x4d0
[75521.596005] free_rt_sched_group+0x153/0x280
[75521.648410] sched_autogroup_create_attach+0x19a/0x520
[75521.711330] ksys_setsid+0x2ba/0x400
[75521.755529] __ia32_sys_setsid+0xa/0x10
[75521.802850] do_syscall_64+0xa3/0x3d0
[75521.848090] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[75521.929000] The buggy address belongs to the object at ffff881bdb643f80
which belongs to the cache kmalloc-96 of size 96
[75522.079797] The buggy address is located 72 bytes inside of
96-byte region [ffff881bdb643f80, ffff881bdb643fe0)
[75522.221234] The buggy address belongs to the page:
[75522.280100] page:ffffea006f6d90c0 count:1 mapcount:0 mapping:0000000000000000 index:0x0
[75522.377443] flags: 0x2fffff80000100(slab)
[75522.426956] raw: 002fffff80000100 0000000000000000 0000000000000000 0000000180200020
[75522.521275] raw: ffffea006e6fafc0 0000000c0000000c ffff881bf180f400 0000000000000000
[75522.615601] page dumped because: kasan: bad access detected
Fixes: 37a9cc525525 ("netfilter: nf_tables: add generation mask to sets")
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
net/netfilter/nf_tables_api.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 91e80aa..dd1f93c 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -2726,12 +2726,13 @@ static struct nft_set *nf_tables_set_lookup_byid(const struct net *net,
u32 id = ntohl(nla_get_be32(nla));
list_for_each_entry(trans, &net->nft.commit_list, list) {
- struct nft_set *set = nft_trans_set(trans);
+ if (trans->msg_type == NFT_MSG_NEWSET) {
+ struct nft_set *set = nft_trans_set(trans);
- if (trans->msg_type == NFT_MSG_NEWSET &&
- id == nft_trans_set_id(trans) &&
- nft_active_genmask(set, genmask))
- return set;
+ if (id == nft_trans_set_id(trans) &&
+ nft_active_genmask(set, genmask))
+ return set;
+ }
}
return ERR_PTR(-ENOENT);
}
--
1.8.3.1
^ permalink raw reply related
* [PATCH v3 net-next] net: stmmac: Add Flexible PPS support
From: Jose Abreu @ 2018-05-31 17:01 UTC (permalink / raw)
To: netdev
Cc: Jose Abreu, David S. Miller, Joao Pinto, Vitor Soares,
Giuseppe Cavallaro, Alexandre Torgue, Richard Cochran
This adds support for Flexible PPS output (which is equivalent
to per_out output of PTP subsystem).
Tested using an oscilloscope and the following commands:
1) Start PTP4L:
# ptp4l -A -4 -H -m -i eth0 &
2) Set Flexible PPS frequency:
# echo <idx> <ts> <tns> <ps> <pns> > /sys/class/ptp/ptpX/period
Where, ts/tns is start time and ps/pns is period time, and ptpX is ptp
of eth0.
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Joao Pinto <jpinto@synopsys.com>
Cc: Vitor Soares <soares@synopsys.com>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Cc: Richard Cochran <richardcochran@gmail.com>
---
Changes from v2:
- Remove PPS support as we can't input the event to PTP
subsystem
Changes from v1:
- Correct kbuild errors in some archs
---
drivers/net/ethernet/stmicro/stmmac/common.h | 2 +
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 1 +
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 1 +
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 2 +
drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 55 +++++++++++++++++++++
drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 22 ++++++++
drivers/net/ethernet/stmicro/stmmac/hwif.h | 7 +++
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 12 +++++
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 42 +++++++++++++++-
10 files changed, 145 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index a679cb7..78fd0f8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -346,6 +346,8 @@ struct dma_features {
/* TX and RX number of queues */
unsigned int number_rx_queues;
unsigned int number_tx_queues;
+ /* PPS output */
+ unsigned int pps_out_num;
/* Alternate (enhanced) DESC mode */
unsigned int enh_desc;
/* TX and RX FIFO sizes */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index 6330a55..eb013d5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -187,6 +187,7 @@ enum power_event {
#define GMAC_HW_RXFIFOSIZE GENMASK(4, 0)
/* MAC HW features2 bitmap */
+#define GMAC_HW_FEAT_PPSOUTNUM GENMASK(26, 24)
#define GMAC_HW_FEAT_TXCHCNT GENMASK(21, 18)
#define GMAC_HW_FEAT_RXCHCNT GENMASK(15, 12)
#define GMAC_HW_FEAT_TXQCNT GENMASK(9, 6)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index a7121a7..7e5d5db 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -796,6 +796,7 @@ static void dwmac4_debug(void __iomem *ioaddr, struct stmmac_extra_stats *x,
.safety_feat_irq_status = dwmac5_safety_feat_irq_status,
.safety_feat_dump = dwmac5_safety_feat_dump,
.rxp_config = dwmac5_rxp_config,
+ .flex_pps_config = dwmac5_flex_pps_config,
};
int dwmac4_setup(struct stmmac_priv *priv)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
index bf8e5a1..d37f17c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
@@ -373,6 +373,8 @@ static void dwmac4_get_hw_feature(void __iomem *ioaddr,
((hw_cap & GMAC_HW_FEAT_RXQCNT) >> 0) + 1;
dma_cap->number_tx_queues =
((hw_cap & GMAC_HW_FEAT_TXQCNT) >> 6) + 1;
+ /* PPS output */
+ dma_cap->pps_out_num = (hw_cap & GMAC_HW_FEAT_PPSOUTNUM) >> 24;
/* IEEE 1588-2002 */
dma_cap->time_stamp = 0;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
index b2becb8..3f4f313 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c
@@ -8,6 +8,7 @@
#include "dwmac4.h"
#include "dwmac5.h"
#include "stmmac.h"
+#include "stmmac_ptp.h"
struct dwmac5_error_desc {
bool valid;
@@ -494,3 +495,57 @@ int dwmac5_rxp_config(void __iomem *ioaddr, struct stmmac_tc_entry *entries,
writel(old_val, ioaddr + GMAC_CONFIG);
return ret;
}
+
+int dwmac5_flex_pps_config(void __iomem *ioaddr, int index,
+ struct stmmac_pps_cfg *cfg, bool enable,
+ u32 sub_second_inc, u32 systime_flags)
+{
+ u32 tnsec = readl(ioaddr + MAC_PPSx_TARGET_TIME_NSEC(index));
+ u32 val = readl(ioaddr + MAC_PPS_CONTROL);
+ u64 period;
+
+ if (!cfg->available)
+ return -EINVAL;
+ if (tnsec & TRGTBUSY0)
+ return -EBUSY;
+ if (!sub_second_inc || !systime_flags)
+ return -EINVAL;
+
+ val &= ~PPSx_MASK(index);
+
+ if (!enable) {
+ val |= PPSCMDx(index, 0x5);
+ writel(val, ioaddr + MAC_PPS_CONTROL);
+ return 0;
+ }
+
+ val |= PPSCMDx(index, 0x2);
+ val |= TRGTMODSELx(index, 0x2);
+ val |= PPSEN0;
+
+ writel(cfg->start.tv_sec, ioaddr + MAC_PPSx_TARGET_TIME_SEC(index));
+
+ if (!(systime_flags & PTP_TCR_TSCTRLSSR))
+ cfg->start.tv_nsec = (cfg->start.tv_nsec * 1000) / 465;
+ writel(cfg->start.tv_nsec, ioaddr + MAC_PPSx_TARGET_TIME_NSEC(index));
+
+ period = cfg->period.tv_sec * 1000000000;
+ period += cfg->period.tv_nsec;
+
+ do_div(period, sub_second_inc);
+
+ if (period <= 1)
+ return -EINVAL;
+
+ writel(period - 1, ioaddr + MAC_PPSx_INTERVAL(index));
+
+ period >>= 1;
+ if (period <= 1)
+ return -EINVAL;
+
+ writel(period - 1, ioaddr + MAC_PPSx_WIDTH(index));
+
+ /* Finally, activate it */
+ writel(val, ioaddr + MAC_PPS_CONTROL);
+ return 0;
+}
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h
index cc810af..775db77 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h
@@ -11,6 +11,25 @@
#define PRTYEN BIT(1)
#define TMOUTEN BIT(0)
+#define MAC_PPS_CONTROL 0x00000b70
+#define PPS_MAXIDX(x) ((((x) + 1) * 8) - 1)
+#define PPS_MINIDX(x) ((x) * 8)
+#define PPSx_MASK(x) GENMASK(PPS_MAXIDX(x), PPS_MINIDX(x))
+#define MCGRENx(x) BIT(PPS_MAXIDX(x))
+#define TRGTMODSELx(x, val) \
+ GENMASK(PPS_MAXIDX(x) - 1, PPS_MAXIDX(x) - 2) & \
+ ((val) << (PPS_MAXIDX(x) - 2))
+#define PPSCMDx(x, val) \
+ GENMASK(PPS_MINIDX(x) + 3, PPS_MINIDX(x)) & \
+ ((val) << PPS_MINIDX(x))
+#define PPSEN0 BIT(4)
+#define MAC_PPSx_TARGET_TIME_SEC(x) (0x00000b80 + ((x) * 0x10))
+#define MAC_PPSx_TARGET_TIME_NSEC(x) (0x00000b84 + ((x) * 0x10))
+#define TRGTBUSY0 BIT(31)
+#define TTSL0 GENMASK(30, 0)
+#define MAC_PPSx_INTERVAL(x) (0x00000b88 + ((x) * 0x10))
+#define MAC_PPSx_WIDTH(x) (0x00000b8c + ((x) * 0x10))
+
#define MTL_RXP_CONTROL_STATUS 0x00000ca0
#define RXPI BIT(31)
#define NPE GENMASK(23, 16)
@@ -61,5 +80,8 @@ int dwmac5_safety_feat_dump(struct stmmac_safety_stats *stats,
int index, unsigned long *count, const char **desc);
int dwmac5_rxp_config(void __iomem *ioaddr, struct stmmac_tc_entry *entries,
unsigned int count);
+int dwmac5_flex_pps_config(void __iomem *ioaddr, int index,
+ struct stmmac_pps_cfg *cfg, bool enable,
+ u32 sub_second_inc, u32 systime_flags);
#endif /* __DWMAC5_H__ */
diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h
index f499a7f..e44e7b2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.h
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h
@@ -241,6 +241,7 @@ struct stmmac_dma_ops {
struct rgmii_adv;
struct stmmac_safety_stats;
struct stmmac_tc_entry;
+struct stmmac_pps_cfg;
/* Helpers to program the MAC core */
struct stmmac_ops {
@@ -313,6 +314,10 @@ struct stmmac_ops {
/* Flexible RX Parser */
int (*rxp_config)(void __iomem *ioaddr, struct stmmac_tc_entry *entries,
unsigned int count);
+ /* Flexible PPS */
+ int (*flex_pps_config)(void __iomem *ioaddr, int index,
+ struct stmmac_pps_cfg *cfg, bool enable,
+ u32 sub_second_inc, u32 systime_flags);
};
#define stmmac_core_init(__priv, __args...) \
@@ -379,6 +384,8 @@ struct stmmac_ops {
stmmac_do_callback(__priv, mac, safety_feat_dump, __args)
#define stmmac_rxp_config(__priv, __args...) \
stmmac_do_callback(__priv, mac, rxp_config, __args)
+#define stmmac_flex_pps_config(__priv, __args...) \
+ stmmac_do_callback(__priv, mac, flex_pps_config, __args)
/* PTP and HW Timer helpers */
struct stmmac_hwtimestamp {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index fbfe5dc..025efbf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -100,6 +100,13 @@ struct stmmac_tc_entry {
} __packed val;
};
+#define STMMAC_PPS_MAX 4
+struct stmmac_pps_cfg {
+ bool available;
+ struct timespec64 start;
+ struct timespec64 period;
+};
+
struct stmmac_priv {
/* Frequently used values are kept adjacent for cache effect */
u32 tx_count_frames;
@@ -160,6 +167,8 @@ struct stmmac_priv {
struct ptp_clock *ptp_clock;
struct ptp_clock_info ptp_clock_ops;
unsigned int default_addend;
+ u32 sub_second_inc;
+ u32 systime_flags;
u32 adv_ts;
int use_riwt;
int irq_wake;
@@ -181,6 +190,9 @@ struct stmmac_priv {
unsigned int tc_entries_max;
unsigned int tc_off_max;
struct stmmac_tc_entry *tc_entries;
+
+ /* Pulse Per Second output */
+ struct stmmac_pps_cfg pps[STMMAC_PPS_MAX];
};
enum stmmac_state {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 77af85c..11fb7c7 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -721,6 +721,10 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
priv->plat->has_gmac4, &sec_inc);
temp = div_u64(1000000000ULL, sec_inc);
+ /* Store sub second increment and flags for later use */
+ priv->sub_second_inc = sec_inc;
+ priv->systime_flags = value;
+
/* calculate default added value:
* formula is :
* addend = (2^32)/freq_div_ratio;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
index 7d3a5c7..0cb0e39 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
@@ -140,17 +140,43 @@ static int stmmac_set_time(struct ptp_clock_info *ptp,
static int stmmac_enable(struct ptp_clock_info *ptp,
struct ptp_clock_request *rq, int on)
{
- return -EOPNOTSUPP;
+ struct stmmac_priv *priv =
+ container_of(ptp, struct stmmac_priv, ptp_clock_ops);
+ struct stmmac_pps_cfg *cfg;
+ int ret = -EOPNOTSUPP;
+ unsigned long flags;
+
+ switch (rq->type) {
+ case PTP_CLK_REQ_PEROUT:
+ cfg = &priv->pps[rq->perout.index];
+
+ cfg->start.tv_sec = rq->perout.start.sec;
+ cfg->start.tv_nsec = rq->perout.start.nsec;
+ cfg->period.tv_sec = rq->perout.period.sec;
+ cfg->period.tv_nsec = rq->perout.period.nsec;
+
+ spin_lock_irqsave(&priv->ptp_lock, flags);
+ ret = stmmac_flex_pps_config(priv, priv->ioaddr,
+ rq->perout.index, cfg, on,
+ priv->sub_second_inc,
+ priv->systime_flags);
+ spin_unlock_irqrestore(&priv->ptp_lock, flags);
+ break;
+ default:
+ break;
+ }
+
+ return ret;
}
/* structure describing a PTP hardware clock */
-static const struct ptp_clock_info stmmac_ptp_clock_ops = {
+static struct ptp_clock_info stmmac_ptp_clock_ops = {
.owner = THIS_MODULE,
.name = "stmmac_ptp_clock",
.max_adj = 62500000,
.n_alarm = 0,
.n_ext_ts = 0,
- .n_per_out = 0,
+ .n_per_out = 0, /* will be overwritten in stmmac_ptp_register */
.n_pins = 0,
.pps = 0,
.adjfreq = stmmac_adjust_freq,
@@ -168,6 +194,16 @@ static int stmmac_enable(struct ptp_clock_info *ptp,
*/
void stmmac_ptp_register(struct stmmac_priv *priv)
{
+ int i;
+
+ for (i = 0; i < priv->dma_cap.pps_out_num; i++) {
+ if (i >= STMMAC_PPS_MAX)
+ break;
+ priv->pps[i].available = true;
+ }
+
+ stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num;
+
spin_lock_init(&priv->ptp_lock);
priv->ptp_clock_ops = stmmac_ptp_clock_ops;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH rdma-next v3 10/14] IB/uverbs: Add support for flow counters
From: Leon Romanovsky @ 2018-05-31 17:23 UTC (permalink / raw)
To: Ruhl, Michael J
Cc: Doug Ledford, Jason Gunthorpe, RDMA mailing list, Boris Pismenny,
Matan Barak, Or Gerlitz, Raed Salem, Yishai Hadas, Saeed Mahameed,
linux-netdev
In-Reply-To: <14063C7AD467DE4B82DEDB5C278E8663B38F0661@FMSMSX108.amr.corp.intel.com>
[-- Attachment #1: Type: text/plain, Size: 6930 bytes --]
On Thu, May 31, 2018 at 02:49:44PM +0000, Ruhl, Michael J wrote:
> >-----Original Message-----
> >From: Leon Romanovsky [mailto:leon@kernel.org]
> >Sent: Thursday, May 31, 2018 9:44 AM
> >To: Doug Ledford <dledford@redhat.com>; Jason Gunthorpe
> ><jgg@mellanox.com>
> >Cc: Leon Romanovsky <leonro@mellanox.com>; RDMA mailing list <linux-
> >rdma@vger.kernel.org>; Boris Pismenny <borisp@mellanox.com>; Matan
> >Barak <matanb@mellanox.com>; Ruhl, Michael J <michael.j.ruhl@intel.com>;
> >Or Gerlitz <ogerlitz@mellanox.com>; Raed Salem <raeds@mellanox.com>;
> >Yishai Hadas <yishaih@mellanox.com>; Saeed Mahameed
> ><saeedm@mellanox.com>; linux-netdev <netdev@vger.kernel.org>
> >Subject: [PATCH rdma-next v3 10/14] IB/uverbs: Add support for flow
> >counters
> >
> >From: Raed Salem <raeds@mellanox.com>
> >
> >The struct ib_uverbs_flow_spec_action_count associates
> >a counters object with the flow.
> >
> >Post this association the flow counters can be read via
> >the counters object.
> >
> >Reviewed-by: Yishai Hadas <yishaih@mellanox.com>
> >Signed-off-by: Raed Salem <raeds@mellanox.com>
> >Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> >---
> > drivers/infiniband/core/uverbs.h | 1 +
> > drivers/infiniband/core/uverbs_cmd.c | 81
> >+++++++++++++++++++++++++++++++-----
> > include/uapi/rdma/ib_user_verbs.h | 13 ++++++
> > 3 files changed, 84 insertions(+), 11 deletions(-)
> >
> >diff --git a/drivers/infiniband/core/uverbs.h
> >b/drivers/infiniband/core/uverbs.h
> >index 5b2461fa634d..c0d40fc3a53a 100644
> >--- a/drivers/infiniband/core/uverbs.h
> >+++ b/drivers/infiniband/core/uverbs.h
> >@@ -263,6 +263,7 @@ struct ib_uverbs_flow_spec {
> > struct ib_uverbs_flow_spec_action_tag flow_tag;
> > struct ib_uverbs_flow_spec_action_drop drop;
> > struct ib_uverbs_flow_spec_action_handle action;
> >+ struct ib_uverbs_flow_spec_action_count flow_count;
> > };
> > };
> >
> >diff --git a/drivers/infiniband/core/uverbs_cmd.c
> >b/drivers/infiniband/core/uverbs_cmd.c
> >index ddb9d79691be..3179a95c6f5e 100644
> >--- a/drivers/infiniband/core/uverbs_cmd.c
> >+++ b/drivers/infiniband/core/uverbs_cmd.c
> >@@ -2748,43 +2748,82 @@ ssize_t ib_uverbs_detach_mcast(struct
> >ib_uverbs_file *file,
> > struct ib_uflow_resources {
> > size_t max;
> > size_t num;
> >- struct ib_flow_action *collection[0];
> >+ size_t collection_num;
> >+ size_t counters_num;
> >+ struct ib_counters **counters;
> >+ struct ib_flow_action **collection;
> > };
> >
> > static struct ib_uflow_resources *flow_resources_alloc(size_t num_specs)
> > {
> > struct ib_uflow_resources *resources;
> >
> >- resources =
> >- kmalloc(sizeof(*resources) +
> >- num_specs * sizeof(*resources->collection),
> >GFP_KERNEL);
> >+ resources = kzalloc(sizeof(*resources), GFP_KERNEL);
> >
> > if (!resources)
> >- return NULL;
> >+ goto err_res;
>
> Why the new goto?
No real reason :)
>
> >+
> >+ resources->counters =
> >+ kcalloc(num_specs, sizeof(*resources->counters),
> >GFP_KERNEL);
> >+
> >+ if (!resources->counters)
> >+ goto err_cnt;
>
> kcalloc() zeros stuff. Could you just have a single common goto for the
> cleanup?
I have mixed feelings regarding such approach, technically you are
right, but I think that it will hurt readability.
I can send followup patch, will it work for you?
Thanks for review.
>
> Mike
>
> >+
> >+ resources->collection =
> >+ kcalloc(num_specs, sizeof(*resources->collection),
> >GFP_KERNEL);
> >+
> >+ if (!resources->collection)
> >+ goto err_collection;
> >
> >- resources->num = 0;
> > resources->max = num_specs;
> >
> > return resources;
> >+
> >+err_collection:
> >+ kfree(resources->counters);
> >+err_cnt:
> >+ kfree(resources);
> >+err_res:
> >+ return NULL;
> > }
> >
> > void ib_uverbs_flow_resources_free(struct ib_uflow_resources *uflow_res)
> > {
> > unsigned int i;
> >
> >- for (i = 0; i < uflow_res->num; i++)
> >+ for (i = 0; i < uflow_res->collection_num; i++)
> > atomic_dec(&uflow_res->collection[i]->usecnt);
> >
> >+ for (i = 0; i < uflow_res->counters_num; i++)
> >+ atomic_dec(&uflow_res->counters[i]->usecnt);
> >+
> >+ kfree(uflow_res->collection);
> >+ kfree(uflow_res->counters);
> > kfree(uflow_res);
> > }
> >
> > static void flow_resources_add(struct ib_uflow_resources *uflow_res,
> >- struct ib_flow_action *action)
> >+ enum ib_flow_spec_type type,
> >+ void *ibobj)
> > {
> > WARN_ON(uflow_res->num >= uflow_res->max);
> >
> >- atomic_inc(&action->usecnt);
> >- uflow_res->collection[uflow_res->num++] = action;
> >+ switch (type) {
> >+ case IB_FLOW_SPEC_ACTION_HANDLE:
> >+ atomic_inc(&((struct ib_flow_action *)ibobj)->usecnt);
> >+ uflow_res->collection[uflow_res->collection_num++] =
> >+ (struct ib_flow_action *)ibobj;
> >+ break;
> >+ case IB_FLOW_SPEC_ACTION_COUNT:
> >+ atomic_inc(&((struct ib_counters *)ibobj)->usecnt);
> >+ uflow_res->counters[uflow_res->counters_num++] =
> >+ (struct ib_counters *)ibobj;
> >+ break;
> >+ default:
> >+ WARN_ON(1);
> >+ }
> >+
> >+ uflow_res->num++;
> > }
> >
> > static int kern_spec_to_ib_spec_action(struct ib_ucontext *ucontext,
> >@@ -2821,9 +2860,29 @@ static int kern_spec_to_ib_spec_action(struct
> >ib_ucontext *ucontext,
> > return -EINVAL;
> > ib_spec->action.size =
> > sizeof(struct ib_flow_spec_action_handle);
> >- flow_resources_add(uflow_res, ib_spec->action.act);
> >+ flow_resources_add(uflow_res,
> >+ IB_FLOW_SPEC_ACTION_HANDLE,
> >+ ib_spec->action.act);
> > uobj_put_obj_read(ib_spec->action.act);
> > break;
> >+ case IB_FLOW_SPEC_ACTION_COUNT:
> >+ if (kern_spec->flow_count.size !=
> >+ sizeof(struct ib_uverbs_flow_spec_action_count))
> >+ return -EINVAL;
> >+ ib_spec->flow_count.counters =
> >+ uobj_get_obj_read(counters,
> >+ UVERBS_OBJECT_COUNTERS,
> >+ kern_spec->flow_count.handle,
> >+ ucontext);
> >+ if (!ib_spec->flow_count.counters)
> >+ return -EINVAL;
> >+ ib_spec->flow_count.size =
> >+ sizeof(struct ib_flow_spec_action_count);
> >+ flow_resources_add(uflow_res,
> >+ IB_FLOW_SPEC_ACTION_COUNT,
> >+ ib_spec->flow_count.counters);
> >+ uobj_put_obj_read(ib_spec->flow_count.counters);
> >+ break;
> > default:
> > return -EINVAL;
> > }
> >diff --git a/include/uapi/rdma/ib_user_verbs.h
> >b/include/uapi/rdma/ib_user_verbs.h
> >index 409507f83b91..4f9991de8e3a 100644
> >--- a/include/uapi/rdma/ib_user_verbs.h
> >+++ b/include/uapi/rdma/ib_user_verbs.h
> >@@ -998,6 +998,19 @@ struct ib_uverbs_flow_spec_action_handle {
> > __u32 reserved1;
> > };
> >
> >+struct ib_uverbs_flow_spec_action_count {
> >+ union {
> >+ struct ib_uverbs_flow_spec_hdr hdr;
> >+ struct {
> >+ __u32 type;
> >+ __u16 size;
> >+ __u16 reserved;
> >+ };
> >+ };
> >+ __u32 handle;
> >+ __u32 reserved1;
> >+};
> >+
> > struct ib_uverbs_flow_tunnel_filter {
> > __be32 tunnel_id;
> > };
> >--
> >2.14.3
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply
* Re: [PATCH net-next] tcp: minor optimization around tcp_hdr() usage in receive path
From: David Miller @ 2018-05-31 17:23 UTC (permalink / raw)
To: laoar.shao; +Cc: edumazet, netdev, linux-kernel
In-Reply-To: <1527607651-28262-1-git-send-email-laoar.shao@gmail.com>
From: Yafang Shao <laoar.shao@gmail.com>
Date: Tue, 29 May 2018 23:27:31 +0800
> This is additional to the
> commit ea1627c20c34 ("tcp: minor optimizations around tcp_hdr() usage").
> At this point, skb->data is same with tcp_hdr() as tcp header has not
> been pulled yet. So use the less expensive one to get the tcp header.
>
> Remove the third parameter of tcp_rcv_established() and put it into
> the function body.
>
> Furthermore, the local variables are listed as a reverse christmas tree :)
>
> Cc: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH v2 net-next] net: remove bypassed check in sch_direct_xmit()
From: David Miller @ 2018-05-31 17:26 UTC (permalink / raw)
To: songliubraving; +Cc: netdev, sergei.shtylyov, kernel-team, john.fastabend, ast
In-Reply-To: <20180529170321.1817618-1-songliubraving@fb.com>
From: Song Liu <songliubraving@fb.com>
Date: Tue, 29 May 2018 10:03:21 -0700
> Checking netif_xmit_frozen_or_stopped() at the end of sch_direct_xmit()
> is being bypassed. This is because "ret" from sch_direct_xmit() will be
> either NETDEV_TX_OK or NETDEV_TX_BUSY, and only ret == NETDEV_TX_OK == 0
> will reach the condition:
>
> if (ret && netif_xmit_frozen_or_stopped(txq))
> return false;
>
> This patch cleans up the code by removing the whole condition.
>
> For more discussion about this, please refer to
> https://marc.info/?t=152727195700008
>
> Signed-off-by: Song Liu <songliubraving@fb.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH 2/2 net-next] net_failover: fix error code in net_failover_create()
From: Samudrala, Sridhar @ 2018-05-31 17:26 UTC (permalink / raw)
To: Dan Carpenter, David S. Miller; +Cc: netdev, kernel-janitors
In-Reply-To: <20180531120425.tqwhhfxqawjuvtws@kili.mountain>
On 5/31/2018 5:04 AM, Dan Carpenter wrote:
> We forgot to set the error code on this path. This function is supposed
> to return error pointers, so with this bug it accidentally returns NULL
> and the caller doesn't check for that.
>
> Fixes: cfc80d9a1163 ("net: Introduce net_failover driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
>
> diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
> index ef50158e90a9..881f3fa13e6b 100644
> --- a/drivers/net/net_failover.c
> +++ b/drivers/net/net_failover.c
> @@ -761,8 +761,10 @@ struct failover *net_failover_create(struct net_device *standby_dev)
> netif_carrier_off(failover_dev);
>
> failover = failover_register(failover_dev, &net_failover_ops);
> - if (IS_ERR(failover))
> + if (IS_ERR(failover)) {
> + err = PTR_ERR(failover);
> goto err_failover_register;
> + }
>
> return failover;
>
^ permalink raw reply
* Re: [PATCH 1/2 net-next] net_failover: fix net_failover_compute_features()
From: Samudrala, Sridhar @ 2018-05-31 17:30 UTC (permalink / raw)
To: Dan Carpenter, David S. Miller
Cc: netdev, kernel-janitors, Jiri Pirko, Jay Vosburgh
In-Reply-To: <20180531120124.pc4txiifxnrslbei@kili.mountain>
On 5/31/2018 5:01 AM, Dan Carpenter wrote:
> This has an '&' vs '|' typo so it starts with vlan_features set to none.
> Also a u32 type isn't large enough to hold all the feature bits, it
> should be netdev_features_t.
>
> Fixes: cfc80d9a1163 ("net: Introduce net_failover driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
The patch looks correct, but this code is based on team/bonding drivers.
So would like to get a confirmation from Jiri/Jay and if a similar fix is
needed in those drivers too.
>
> diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
> index 8b508e2cf29b..ef50158e90a9 100644
> --- a/drivers/net/net_failover.c
> +++ b/drivers/net/net_failover.c
> @@ -380,7 +380,8 @@ static rx_handler_result_t net_failover_handle_frame(struct sk_buff **pskb)
>
> static void net_failover_compute_features(struct net_device *dev)
> {
> - u32 vlan_features = FAILOVER_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL;
> + netdev_features_t vlan_features = FAILOVER_VLAN_FEATURES |
> + NETIF_F_ALL_FOR_ALL;
> netdev_features_t enc_features = FAILOVER_ENC_FEATURES;
> unsigned short max_hard_header_len = ETH_HLEN;
> unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |
^ permalink raw reply
* Re: [PATCH net-next] qed: Add srq core support for RoCE and iWARP
From: Leon Romanovsky @ 2018-05-31 17:33 UTC (permalink / raw)
To: Yuval Bason
Cc: davem, netdev, jgg, dledford, linux-rdma, Michal Kalderon,
Ariel Elior
In-Reply-To: <20180530131137.4653-1-yuval.bason@cavium.com>
[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]
On Wed, May 30, 2018 at 04:11:37PM +0300, Yuval Bason wrote:
> This patch adds support for configuring SRQ and provides the necessary
> APIs for rdma upper layer driver (qedr) to enable the SRQ feature.
>
> Signed-off-by: Michal Kalderon <michal.kalderon@cavium.com>
> Signed-off-by: Ariel Elior <ariel.elior@cavium.com>
> Signed-off-by: Yuval Bason <yuval.bason@cavium.com>
> ---
> drivers/net/ethernet/qlogic/qed/qed_cxt.c | 5 +-
> drivers/net/ethernet/qlogic/qed/qed_cxt.h | 1 +
> drivers/net/ethernet/qlogic/qed/qed_hsi.h | 2 +
> drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 23 ++++
> drivers/net/ethernet/qlogic/qed/qed_main.c | 2 +
> drivers/net/ethernet/qlogic/qed/qed_rdma.c | 179 +++++++++++++++++++++++++++-
> drivers/net/ethernet/qlogic/qed/qed_rdma.h | 2 +
> drivers/net/ethernet/qlogic/qed/qed_roce.c | 17 ++-
> include/linux/qed/qed_rdma_if.h | 12 +-
> 9 files changed, 235 insertions(+), 8 deletions(-)
>
...
> + struct qed_sp_init_data init_data;
...
> + memset(&init_data, 0, sizeof(init_data));
This patter is so common in this patch, why?
"struct qed_sp_init_data init_data = {};" will do the trick.
Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply
* Re: [PATCH net-next v12 2/5] netvsc: refactor notifier/event handling code to use the failover framework
From: Michael S. Tsirkin @ 2018-05-31 17:34 UTC (permalink / raw)
To: Stephen Hemminger
Cc: Samudrala, Sridhar, davem, netdev, virtualization, virtio-dev,
jesse.brandeburg, alexander.h.duyck, kubakici, jasowang,
loseweigh, jiri, aaron.f.brown, anjali.singhai
In-Reply-To: <20180531085812.0b13afef@shemminger-XPS-13-9360>
On Thu, May 31, 2018 at 08:58:12AM -0400, Stephen Hemminger wrote:
> On Wed, 30 May 2018 20:03:11 -0700
> "Samudrala, Sridhar" <sridhar.samudrala@intel.com> wrote:
>
> > On 5/30/2018 7:06 PM, Stephen Hemminger wrote:
> > > On Thu, 24 May 2018 09:55:14 -0700
> > > Sridhar Samudrala <sridhar.samudrala@intel.com> wrote:
> > >
> > >> Use the registration/notification framework supported by the generic
> > >> failover infrastructure.
> > >>
> > >> Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>
> > > Why was this merged? It was never signed off by any of the netvsc maintainers,
> > > and there were still issues unresolved.
> > >
> > > There are also namespaces issues I am fixing and this breaks them.
> > > Will start my patch set with a revert for this. Sorry
> >
> > I would appreciate if you can make the fixes on top of this patch series. I tried hard
> > to make sure that netvsc functionality and behavior doesn't change.
> >
> > It is possible that there could be some bugs introduced, but they can be fixed.
> > Looks like Wei already found a bug and submitted a fix for that.
> >
>
> Ok, but several of these may clash with what you want for virtio.
> Like:
> - VF should be moved to namespace of virt device
> - VF should be associated based on message from host with serial # not
> registration notifier and MAC address.
> - control operations should use master device reference rather than
> searching based on MAC.
>
> As you can see these are structural changes.
We might want to do these for virtio as well, at least as
an option.
--
MST
^ permalink raw reply
* Re: [PATCH net-next] virtio_net: fix error return code in virtnet_probe()
From: Michael S. Tsirkin @ 2018-05-31 17:37 UTC (permalink / raw)
To: Wei Yongjun
Cc: Jason Wang, Sridhar Samudrala, virtualization, netdev,
kernel-janitors
In-Reply-To: <1527732307-145609-1-git-send-email-weiyongjun1@huawei.com>
On Thu, May 31, 2018 at 02:05:07AM +0000, Wei Yongjun wrote:
> Fix to return a negative error code from the failover create fail error
> handling case instead of 0, as done elsewhere in this function.
>
> Fixes: ba5e4426e80e ("virtio_net: Extend virtio to use VF datapath when available")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/net/virtio_net.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 8f08a3e..2d55e2a 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -2935,8 +2935,10 @@ static int virtnet_probe(struct virtio_device *vdev)
>
> if (virtio_has_feature(vdev, VIRTIO_NET_F_STANDBY)) {
> vi->failover = net_failover_create(vi->dev);
> - if (IS_ERR(vi->failover))
> + if (IS_ERR(vi->failover)) {
> + err = PTR_ERR(vi->failover);
> goto free_vqs;
> + }
> }
>
> err = register_netdev(dev);
^ permalink raw reply
* [PATCH net-next 0/9] Test mirror-to-gretap with bridge in UL
From: Petr Machata @ 2018-05-31 17:51 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
This patchset adds more tests to the mirror-to-gretap suite where bridge
is present in the underlay. Specifically it adds tests for bridge VLAN
handling, FDB, and bridge port STP status.
In patches #1-#3, the codebase is refactored to support the new tests.
In patch #4, an STP test is added to the mirroring library, that will
later be called from bridge tests.
In patches #5-#8, the test for mirror-to-gretap with an 802.1q bridge in
underlay is adapted and more tests are added.
In patch #9, an STP test is added to the test suite for mirror-to-gretap
with an 802.1d bridge in underlay.
Petr Machata (9):
selftests: forwarding: lib: Move here vlan_capture_{,un}install()
selftests: forwarding: mirror_lib: Move here
do_test_span_vlan_dir_ips()
selftests: forwarding: mirror_lib: skip_hw the VLAN capture
selftests: forwarding: mirror_gre_lib: Add STP test
selftests: forwarding: mirror_gre_vlan_bridge_1q: Fix tunnel name
selftests: forwarding: mirror_gre_vlan_bridge_1q: Test final config
selftests: forwarding: mirror_gre_vlan_bridge_1q: Rename two tests
selftests: forwarding: mirror_gre_vlan_bridge_1q: Add more tests
selftests: forwarding: mirror_gre_bridge_1d_vlan: Add STP test
tools/testing/selftests/net/forwarding/lib.sh | 23 ++++
.../net/forwarding/mirror_gre_bridge_1d_vlan.sh | 12 ++
.../selftests/net/forwarding/mirror_gre_lib.sh | 32 +++++
.../net/forwarding/mirror_gre_vlan_bridge_1q.sh | 148 +++++++++++++++++++--
.../testing/selftests/net/forwarding/mirror_lib.sh | 38 ++++++
.../selftests/net/forwarding/mirror_vlan.sh | 38 ------
6 files changed, 244 insertions(+), 47 deletions(-)
--
2.4.11
^ permalink raw reply
* [PATCH net-next 1/9] selftests: forwarding: lib: Move here vlan_capture_{,un}install()
From: Petr Machata @ 2018-05-31 17:52 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
In-Reply-To: <cover.1527788672.git.petrm@mellanox.com>
Move vlan_capture_install() and vlan_capture_uninstall() from
mirror_vlan.sh test to lib.sh so that it can be reused in other tests.
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
tools/testing/selftests/net/forwarding/lib.sh | 23 ++++++++++++++++++++++
.../selftests/net/forwarding/mirror_vlan.sh | 23 ----------------------
2 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 89ba4cd..7b18a53 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -514,6 +514,29 @@ icmp6_capture_uninstall()
__icmp_capture_add_del del 100 v6 "$@"
}
+__vlan_capture_add_del()
+{
+ local add_del=$1; shift
+ local pref=$1; shift
+ local dev=$1; shift
+ local filter=$1; shift
+
+ tc filter $add_del dev "$dev" ingress \
+ proto 802.1q pref $pref \
+ flower $filter \
+ action pass
+}
+
+vlan_capture_install()
+{
+ __vlan_capture_add_del add 100 "$@"
+}
+
+vlan_capture_uninstall()
+{
+ __vlan_capture_add_del del 100 "$@"
+}
+
matchall_sink_create()
{
local dev=$1; shift
diff --git a/tools/testing/selftests/net/forwarding/mirror_vlan.sh b/tools/testing/selftests/net/forwarding/mirror_vlan.sh
index 1e10520..758b6d0 100755
--- a/tools/testing/selftests/net/forwarding/mirror_vlan.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_vlan.sh
@@ -76,29 +76,6 @@ test_vlan()
test_vlan_dir egress 0 8
}
-vlan_capture_add_del()
-{
- local add_del=$1; shift
- local pref=$1; shift
- local dev=$1; shift
- local filter=$1; shift
-
- tc filter $add_del dev "$dev" ingress \
- proto 802.1q pref $pref \
- flower $filter \
- action pass
-}
-
-vlan_capture_install()
-{
- vlan_capture_add_del add 100 "$@"
-}
-
-vlan_capture_uninstall()
-{
- vlan_capture_add_del del 100 "$@"
-}
-
do_test_span_vlan_dir_ips()
{
local expect=$1; shift
--
2.4.11
^ permalink raw reply related
* [PATCH net-next 2/9] selftests: forwarding: mirror_lib: Move here do_test_span_vlan_dir_ips()
From: Petr Machata @ 2018-05-31 17:52 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
In-Reply-To: <cover.1527788672.git.petrm@mellanox.com>
Move the function do_test_span_vlan_dir_ips() from mirror_vlan.sh test
to a library file mirror_lib.sh to allow reuse. Fill in other entry
points similar to other testing functions in mirror_lib.sh, they will be
useful in following patches.
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
.../testing/selftests/net/forwarding/mirror_lib.sh | 35 ++++++++++++++++++++++
.../selftests/net/forwarding/mirror_vlan.sh | 15 ----------
2 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/tools/testing/selftests/net/forwarding/mirror_lib.sh b/tools/testing/selftests/net/forwarding/mirror_lib.sh
index 04cbc38..67efe25 100644
--- a/tools/testing/selftests/net/forwarding/mirror_lib.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_lib.sh
@@ -92,3 +92,38 @@ test_span_dir()
{
test_span_dir_ips "$@" 192.0.2.1 192.0.2.2
}
+
+do_test_span_vlan_dir_ips()
+{
+ local expect=$1; shift
+ local dev=$1; shift
+ local vid=$1; shift
+ local direction=$1; shift
+ local ip1=$1; shift
+ local ip2=$1; shift
+
+ vlan_capture_install $dev "vlan_id $vid"
+ mirror_test v$h1 $ip1 $ip2 $dev 100 $expect
+ mirror_test v$h2 $ip2 $ip1 $dev 100 $expect
+ vlan_capture_uninstall $dev
+}
+
+quick_test_span_vlan_dir_ips()
+{
+ do_test_span_vlan_dir_ips 10 "$@"
+}
+
+fail_test_span_vlan_dir_ips()
+{
+ do_test_span_vlan_dir_ips 0 "$@"
+}
+
+quick_test_span_vlan_dir()
+{
+ quick_test_span_vlan_dir_ips "$@" 192.0.2.1 192.0.2.2
+}
+
+fail_test_span_vlan_dir()
+{
+ fail_test_span_vlan_dir_ips "$@" 192.0.2.1 192.0.2.2
+}
diff --git a/tools/testing/selftests/net/forwarding/mirror_vlan.sh b/tools/testing/selftests/net/forwarding/mirror_vlan.sh
index 758b6d0..20b37a5 100755
--- a/tools/testing/selftests/net/forwarding/mirror_vlan.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_vlan.sh
@@ -76,21 +76,6 @@ test_vlan()
test_vlan_dir egress 0 8
}
-do_test_span_vlan_dir_ips()
-{
- local expect=$1; shift
- local dev=$1; shift
- local vid=$1; shift
- local direction=$1; shift
- local ip1=$1; shift
- local ip2=$1; shift
-
- vlan_capture_install $dev "vlan_id $vid"
- mirror_test v$h1 $ip1 $ip2 $dev 100 $expect
- mirror_test v$h2 $ip2 $ip1 $dev 100 $expect
- vlan_capture_uninstall $dev
-}
-
test_tagged_vlan_dir()
{
local direction=$1; shift
--
2.4.11
^ permalink raw reply related
* [PATCH net-next 3/9] selftests: forwarding: mirror_lib: skip_hw the VLAN capture
From: Petr Machata @ 2018-05-31 17:52 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
In-Reply-To: <cover.1527788672.git.petrm@mellanox.com>
When the VLAN capture is installed on a front panel device and not a
soft device, the packets are counted twice: once in fast path, and once
after they are trapped to the kernel. Resolve the problem by passing
skip_hw flag to vlan_capture_install().
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
tools/testing/selftests/net/forwarding/mirror_lib.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/forwarding/mirror_lib.sh b/tools/testing/selftests/net/forwarding/mirror_lib.sh
index 67efe25..d36dc26 100644
--- a/tools/testing/selftests/net/forwarding/mirror_lib.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_lib.sh
@@ -102,7 +102,10 @@ do_test_span_vlan_dir_ips()
local ip1=$1; shift
local ip2=$1; shift
- vlan_capture_install $dev "vlan_id $vid"
+ # Install the capture as skip_hw to avoid double-counting of packets.
+ # The traffic is meant for local box anyway, so will be trapped to
+ # kernel.
+ vlan_capture_install $dev "skip_hw vlan_id $vid"
mirror_test v$h1 $ip1 $ip2 $dev 100 $expect
mirror_test v$h2 $ip2 $ip1 $dev 100 $expect
vlan_capture_uninstall $dev
--
2.4.11
^ permalink raw reply related
* [PATCH net-next 4/9] selftests: forwarding: mirror_gre_lib: Add STP test
From: Petr Machata @ 2018-05-31 17:52 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
In-Reply-To: <cover.1527788672.git.petrm@mellanox.com>
Add a reusable full test that toggles STP state of a given bridge port
and checks that the mirroring reacts appropriately. The test will be
used by bridge tests in follow-up patches.
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
.../selftests/net/forwarding/mirror_gre_lib.sh | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh b/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
index 92ef6dd..619b469 100644
--- a/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_gre_lib.sh
@@ -96,3 +96,35 @@ full_test_span_gre_dir_vlan()
{
full_test_span_gre_dir_vlan_ips "$@" 192.0.2.1 192.0.2.2
}
+
+full_test_span_gre_stp_ips()
+{
+ local tundev=$1; shift
+ local nbpdev=$1; shift
+ local what=$1; shift
+ local ip1=$1; shift
+ local ip2=$1; shift
+ local h3mac=$(mac_get $h3)
+
+ RET=0
+
+ mirror_install $swp1 ingress $tundev "matchall $tcflags"
+ quick_test_span_gre_dir_ips $tundev ingress $ip1 $ip2
+
+ bridge link set dev $nbpdev state disabled
+ sleep 1
+ fail_test_span_gre_dir_ips $tundev ingress $ip1 $ip2
+
+ bridge link set dev $nbpdev state forwarding
+ sleep 1
+ quick_test_span_gre_dir_ips $tundev ingress $ip1 $ip2
+
+ mirror_uninstall $swp1 ingress
+
+ log_test "$what: STP state ($tcflags)"
+}
+
+full_test_span_gre_stp()
+{
+ full_test_span_gre_stp_ips "$@" 192.0.2.1 192.0.2.2
+}
--
2.4.11
^ permalink raw reply related
* [PATCH net-next 5/9] selftests: forwarding: mirror_gre_vlan_bridge_1q: Fix tunnel name
From: Petr Machata @ 2018-05-31 17:52 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
In-Reply-To: <cover.1527788672.git.petrm@mellanox.com>
The "ip6gretap" in the test name refers to the tunnel device type that
the test is supposed to be testing. However test_ip6gretap_forbidden()
tests, due to a typo, a gretap tunnel. Fix the typo.
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
index 01ec28a..29fde73 100755
--- a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
@@ -108,7 +108,7 @@ test_gretap_forbidden()
test_ip6gretap_forbidden()
{
- test_span_gre_forbidden gt4 "mirror to ip6gretap"
+ test_span_gre_forbidden gt6 "mirror to ip6gretap"
}
test_all()
--
2.4.11
^ permalink raw reply related
* [PATCH net-next 6/9] selftests: forwarding: mirror_gre_vlan_bridge_1q: Test final config
From: Petr Machata @ 2018-05-31 17:52 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
In-Reply-To: <cover.1527788672.git.petrm@mellanox.com>
After the final change reestablishes the original configuration, make
sure the traffic flows again as it should.
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
index 29fde73..0a3bac9 100755
--- a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
@@ -91,12 +91,13 @@ test_span_gre_forbidden()
# Now forbid the VLAN at the bridge and see it fail.
bridge vlan del dev br1 vid 555 self
sleep 1
-
fail_test_span_gre_dir $tundev ingress
- mirror_uninstall $swp1 ingress
bridge vlan add dev br1 vid 555 self
sleep 1
+ quick_test_span_gre_dir $tundev ingress
+
+ mirror_uninstall $swp1 ingress
log_test "$what: vlan forbidden at a bridge ($tcflags)"
}
--
2.4.11
^ permalink raw reply related
* [PATCH net-next 7/9] selftests: forwarding: mirror_gre_vlan_bridge_1q: Rename two tests
From: Petr Machata @ 2018-05-31 17:52 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
In-Reply-To: <cover.1527788672.git.petrm@mellanox.com>
Rename test_gretap_forbidden() and test_ip6gretap_forbidden() to a more
specific test_gretap_forbidden_cpu() and test_ip6gretap_forbidden_cpu().
This will make it clearer which is which when further down a patch is
introduced that forbids a VLAN on regular bridge port.
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
.../selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
index 0a3bac9..d91b347 100755
--- a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
@@ -10,8 +10,8 @@
ALL_TESTS="
test_gretap
test_ip6gretap
- test_gretap_forbidden
- test_ip6gretap_forbidden
+ test_gretap_forbidden_cpu
+ test_ip6gretap_forbidden_cpu
"
NUM_NETIFS=6
@@ -77,7 +77,7 @@ test_ip6gretap()
test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap"
}
-test_span_gre_forbidden()
+test_span_gre_forbidden_cpu()
{
local tundev=$1; shift
local what=$1; shift
@@ -102,14 +102,14 @@ test_span_gre_forbidden()
log_test "$what: vlan forbidden at a bridge ($tcflags)"
}
-test_gretap_forbidden()
+test_gretap_forbidden_cpu()
{
- test_span_gre_forbidden gt4 "mirror to gretap"
+ test_span_gre_forbidden_cpu gt4 "mirror to gretap"
}
-test_ip6gretap_forbidden()
+test_ip6gretap_forbidden_cpu()
{
- test_span_gre_forbidden gt6 "mirror to ip6gretap"
+ test_span_gre_forbidden_cpu gt6 "mirror to ip6gretap"
}
test_all()
--
2.4.11
^ permalink raw reply related
* [PATCH net-next 8/9] selftests: forwarding: mirror_gre_vlan_bridge_1q: Add more tests
From: Petr Machata @ 2018-05-31 17:52 UTC (permalink / raw)
To: netdev, linux-kselftest; +Cc: davem, shuah, idosch
In-Reply-To: <cover.1527788672.git.petrm@mellanox.com>
Offloading of mirror-to-gretap in mlxsw is tricky especially in cases
when the gretap underlay involves bridges. Add more tests that exercise
the bridge handling code:
- forbidden_egress tests that check vlan removal on bridge port in the
underlay packet path
- untagged_egress tests that similarly check "egress untagged"
- fdb_roaming tests that check whether learning FDB on a different port
is reflected
- stp tests for handling port STP status of bridge egress port
Signed-off-by: Petr Machata <petrm@mellanox.com>
---
.../net/forwarding/mirror_gre_vlan_bridge_1q.sh | 129 +++++++++++++++++++++
1 file changed, 129 insertions(+)
diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
index d91b347..5dbc7a0 100755
--- a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
+++ b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh
@@ -12,6 +12,14 @@ ALL_TESTS="
test_ip6gretap
test_gretap_forbidden_cpu
test_ip6gretap_forbidden_cpu
+ test_gretap_forbidden_egress
+ test_ip6gretap_forbidden_egress
+ test_gretap_untagged_egress
+ test_ip6gretap_untagged_egress
+ test_gretap_fdb_roaming
+ test_ip6gretap_fdb_roaming
+ test_gretap_stp
+ test_ip6gretap_stp
"
NUM_NETIFS=6
@@ -43,12 +51,14 @@ setup_prepare()
ip link set dev $swp3 master br1
bridge vlan add dev $swp3 vid 555
+ bridge vlan add dev $swp2 vid 555
}
cleanup()
{
pre_cleanup
+ ip link set dev $swp2 nomaster
ip link set dev $swp3 nomaster
vlan_destroy $h3 555
vlan_destroy br1 555
@@ -112,6 +122,125 @@ test_ip6gretap_forbidden_cpu()
test_span_gre_forbidden_cpu gt6 "mirror to ip6gretap"
}
+test_span_gre_forbidden_egress()
+{
+ local tundev=$1; shift
+ local what=$1; shift
+
+ RET=0
+
+ mirror_install $swp1 ingress $tundev "matchall $tcflags"
+ quick_test_span_gre_dir $tundev ingress
+
+ bridge vlan del dev $swp3 vid 555
+ sleep 1
+ fail_test_span_gre_dir $tundev ingress
+
+ bridge vlan add dev $swp3 vid 555
+ # Re-prime FDB
+ arping -I br1.555 192.0.2.130 -fqc 1
+ sleep 1
+ quick_test_span_gre_dir $tundev ingress
+
+ mirror_uninstall $swp1 ingress
+
+ log_test "$what: vlan forbidden at a bridge egress ($tcflags)"
+}
+
+test_gretap_forbidden_egress()
+{
+ test_span_gre_forbidden_egress gt4 "mirror to gretap"
+}
+
+test_ip6gretap_forbidden_egress()
+{
+ test_span_gre_forbidden_egress gt6 "mirror to ip6gretap"
+}
+
+test_span_gre_untagged_egress()
+{
+ local tundev=$1; shift
+ local what=$1; shift
+
+ RET=0
+
+ mirror_install $swp1 ingress $tundev "matchall $tcflags"
+
+ quick_test_span_gre_dir $tundev ingress
+ quick_test_span_vlan_dir $h3 555 ingress
+
+ bridge vlan add dev $swp3 vid 555 pvid untagged
+ sleep 1
+ quick_test_span_gre_dir $tundev ingress
+ fail_test_span_vlan_dir $h3 555 ingress
+
+ bridge vlan add dev $swp3 vid 555
+ sleep 1
+ quick_test_span_gre_dir $tundev ingress
+ quick_test_span_vlan_dir $h3 555 ingress
+
+ mirror_uninstall $swp1 ingress
+
+ log_test "$what: vlan untagged at a bridge egress ($tcflags)"
+}
+
+test_gretap_untagged_egress()
+{
+ test_span_gre_untagged_egress gt4 "mirror to gretap"
+}
+
+test_ip6gretap_untagged_egress()
+{
+ test_span_gre_untagged_egress gt6 "mirror to ip6gretap"
+}
+
+test_span_gre_fdb_roaming()
+{
+ local tundev=$1; shift
+ local what=$1; shift
+ local h3mac=$(mac_get $h3)
+
+ RET=0
+
+ mirror_install $swp1 ingress $tundev "matchall $tcflags"
+ quick_test_span_gre_dir $tundev ingress
+
+ bridge fdb del dev $swp3 $h3mac vlan 555 master
+ bridge fdb add dev $swp2 $h3mac vlan 555 master
+ sleep 1
+ fail_test_span_gre_dir $tundev ingress
+
+ bridge fdb del dev $swp2 $h3mac vlan 555 master
+ # Re-prime FDB
+ arping -I br1.555 192.0.2.130 -fqc 1
+ sleep 1
+ quick_test_span_gre_dir $tundev ingress
+
+ mirror_uninstall $swp1 ingress
+
+ log_test "$what: MAC roaming ($tcflags)"
+}
+
+test_gretap_fdb_roaming()
+{
+ test_span_gre_fdb_roaming gt4 "mirror to gretap"
+}
+
+test_ip6gretap_fdb_roaming()
+{
+ test_span_gre_fdb_roaming gt6 "mirror to ip6gretap"
+}
+
+test_gretap_stp()
+{
+ full_test_span_gre_stp gt4 $swp3 "mirror to gretap"
+}
+
+test_ip6gretap_stp()
+{
+ full_test_span_gre_stp gt6 $swp3 "mirror to ip6gretap"
+}
+
test_all()
{
slow_path_trap_install $swp1 ingress
--
2.4.11
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox