From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Gal Pressman <galp@mellanox.com>,
Saeed Mahameed <saeedm@mellanox.com>
Subject: [PATCH 4.9 50/75] net/mlx5e: Add refcount to VXLAN structure
Date: Mon, 1 Jan 2018 15:32:27 +0100 [thread overview]
Message-ID: <20180101140104.965134719@linuxfoundation.org> (raw)
In-Reply-To: <20180101140056.475827799@linuxfoundation.org>
4.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <galp@mellanox.com>
[ Upstream commit 23f4cc2cd9ed92570647220aca60d0197d8c1fa9 ]
A refcount mechanism must be implemented in order to prevent unwanted
scenarios such as:
- Open an IPv4 VXLAN interface
- Open an IPv6 VXLAN interface (different socket)
- Remove one of the interfaces
With current implementation, the UDP port will be removed from our VXLAN
database and turn off the offloads for the other interface, which is
still active.
The reference count mechanism will only allow UDP port removals once all
consumers are gone.
Fixes: b3f63c3d5e2c ("net/mlx5e: Add netdev support for VXLAN tunneling")
Signed-off-by: Gal Pressman <galp@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ethernet/mellanox/mlx5/core/vxlan.c | 50 ++++++++++++------------
drivers/net/ethernet/mellanox/mlx5/core/vxlan.h | 1
2 files changed, 28 insertions(+), 23 deletions(-)
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
@@ -88,8 +88,11 @@ static void mlx5e_vxlan_add_port(struct
struct mlx5e_vxlan *vxlan;
int err;
- if (mlx5e_vxlan_lookup_port(priv, port))
+ vxlan = mlx5e_vxlan_lookup_port(priv, port);
+ if (vxlan) {
+ atomic_inc(&vxlan->refcount);
goto free_work;
+ }
if (mlx5e_vxlan_core_add_port_cmd(priv->mdev, port))
goto free_work;
@@ -99,6 +102,7 @@ static void mlx5e_vxlan_add_port(struct
goto err_delete_port;
vxlan->udp_port = port;
+ atomic_set(&vxlan->refcount, 1);
spin_lock_bh(&vxlan_db->lock);
err = radix_tree_insert(&vxlan_db->tree, vxlan->udp_port, vxlan);
@@ -116,32 +120,33 @@ free_work:
kfree(vxlan_work);
}
-static void __mlx5e_vxlan_core_del_port(struct mlx5e_priv *priv, u16 port)
+static void mlx5e_vxlan_del_port(struct work_struct *work)
{
+ struct mlx5e_vxlan_work *vxlan_work =
+ container_of(work, struct mlx5e_vxlan_work, work);
+ struct mlx5e_priv *priv = vxlan_work->priv;
struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
+ u16 port = vxlan_work->port;
struct mlx5e_vxlan *vxlan;
+ bool remove = false;
spin_lock_bh(&vxlan_db->lock);
- vxlan = radix_tree_delete(&vxlan_db->tree, port);
- spin_unlock_bh(&vxlan_db->lock);
-
+ vxlan = radix_tree_lookup(&vxlan_db->tree, port);
if (!vxlan)
- return;
-
- mlx5e_vxlan_core_del_port_cmd(priv->mdev, vxlan->udp_port);
-
- kfree(vxlan);
-}
+ goto out_unlock;
-static void mlx5e_vxlan_del_port(struct work_struct *work)
-{
- struct mlx5e_vxlan_work *vxlan_work =
- container_of(work, struct mlx5e_vxlan_work, work);
- struct mlx5e_priv *priv = vxlan_work->priv;
- u16 port = vxlan_work->port;
+ if (atomic_dec_and_test(&vxlan->refcount)) {
+ radix_tree_delete(&vxlan_db->tree, port);
+ remove = true;
+ }
- __mlx5e_vxlan_core_del_port(priv, port);
+out_unlock:
+ spin_unlock_bh(&vxlan_db->lock);
+ if (remove) {
+ mlx5e_vxlan_core_del_port_cmd(priv->mdev, port);
+ kfree(vxlan);
+ }
kfree(vxlan_work);
}
@@ -171,12 +176,11 @@ void mlx5e_vxlan_cleanup(struct mlx5e_pr
struct mlx5e_vxlan *vxlan;
unsigned int port = 0;
- spin_lock_bh(&vxlan_db->lock);
+ /* Lockless since we are the only radix-tree consumers, wq is disabled */
while (radix_tree_gang_lookup(&vxlan_db->tree, (void **)&vxlan, port, 1)) {
port = vxlan->udp_port;
- spin_unlock_bh(&vxlan_db->lock);
- __mlx5e_vxlan_core_del_port(priv, (u16)port);
- spin_lock_bh(&vxlan_db->lock);
+ radix_tree_delete(&vxlan_db->tree, port);
+ mlx5e_vxlan_core_del_port_cmd(priv->mdev, port);
+ kfree(vxlan);
}
- spin_unlock_bh(&vxlan_db->lock);
}
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
@@ -36,6 +36,7 @@
#include "en.h"
struct mlx5e_vxlan {
+ atomic_t refcount;
u16 udp_port;
};
next prev parent reply other threads:[~2018-01-01 14:32 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-01 14:31 [PATCH 4.9 00/75] 4.9.74-stable review Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 01/75] sync objtools copy of x86-opcode-map.txt Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 02/75] tracing: Remove extra zeroing out of the ring buffer page Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 03/75] tracing: Fix possible double free on failure of allocating trace buffer Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 04/75] tracing: Fix crash when it fails to alloc ring buffer Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 05/75] ring-buffer: Mask out the info bits when returning buffer page length Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 06/75] iw_cxgb4: Only validate the MSN for successful completions Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 07/75] ASoC: wm_adsp: Fix validation of firmware and coeff lengths Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 08/75] ASoC: da7218: fix fix child-node lookup Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 09/75] ASoC: fsl_ssi: AC97 ops need regmap, clock and cleaning up on failure Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 10/75] ASoC: twl4030: fix child-node lookup Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 11/75] ASoC: tlv320aic31xx: Fix GPIO1 register definition Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 12/75] ALSA: hda: Drop useless WARN_ON() Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 13/75] ALSA: hda - fix headset mic detection issue on a Dell machine Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 14/75] x86/vm86/32: Switch to flush_tlb_mm_range() in mark_screen_rdonly() Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 15/75] x86/mm: Remove flush_tlb() and flush_tlb_current_task() Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 16/75] x86/mm: Make flush_tlb_mm_range() more predictable Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 17/75] x86/mm: Reimplement flush_tlb_page() using flush_tlb_mm_range() Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 18/75] x86/mm: Remove the UP asm/tlbflush.h code, always use the (formerly) SMP code Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 19/75] x86/mm: Disable PCID on 32-bit kernels Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 20/75] x86/mm: Add the nopcid boot option to turn off PCID Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 21/75] x86/mm: Enable CR4.PCIDE on supported systems Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 22/75] x86/mm/64: Fix reboot interaction with CR4.PCIDE Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 25/75] ipv6: mcast: better catch silly mtu values Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 26/75] net: fec: unmap the xmit buffer that are not transferred by DMA Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 27/75] net: igmp: Use correct source address on IGMPv3 reports Greg Kroah-Hartman
2018-01-16 3:50 ` Sebastian Gottschall
2018-01-16 3:58 ` Kevin Cernekee
2018-01-16 4:26 ` Sebastian Gottschall
2018-01-16 4:32 ` Kevin Cernekee
2018-01-16 4:44 ` Sebastian Gottschall
2018-01-16 5:16 ` Kevin Cernekee
2018-01-16 9:18 ` Sebastian Gottschall
2018-01-16 15:31 ` Kevin Cernekee
2018-01-16 15:40 ` Sebastian Gottschall
2018-01-16 9:21 ` Sebastian Gottschall
2018-01-16 4:55 ` Sebastian Gottschall
2018-01-16 5:55 ` Greg Kroah-Hartman
2018-01-16 7:34 ` Sebastian Gottschall
2018-01-16 8:15 ` Greg Kroah-Hartman
2018-01-16 15:25 ` David Miller
2018-01-16 15:34 ` Sebastian Gottschall
2018-01-01 14:32 ` [PATCH 4.9 28/75] netlink: Add netns check on taps Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 30/75] net: reevalulate autoflowlabel setting after sysctl setting Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 31/75] ptr_ring: add barriers Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 32/75] RDS: Check cmsg_len before dereferencing CMSG_DATA Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 33/75] tcp_bbr: record "full bw reached" decision in new full_bw_reached bit Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 34/75] tcp md5sig: Use skbs saddr when replying to an incoming segment Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 35/75] tg3: Fix rx hang on MTU change with 5717/5719 Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 36/75] net: ipv4: fix for a race condition in raw_sendmsg Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 37/75] net: mvmdio: disable/unprepare clocks in EPROBE_DEFER case Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 38/75] sctp: Replace use of sockets_allocated with specified macro Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 39/75] adding missing rcu_read_unlock in ipxip6_rcv Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 40/75] ipv4: Fix use-after-free when flushing FIB tables Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 41/75] net: bridge: fix early call to br_stp_change_bridge_id and plug newlink leaks Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 42/75] net: fec: Allow reception of frames bigger than 1522 bytes Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 43/75] net: Fix double free and memory corruption in get_net_ns_by_id() Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 44/75] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 45/75] sock: free skb in skb_complete_tx_timestamp on error Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 46/75] tcp: invalidate rate samples during SACK reneging Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 47/75] net/mlx5: Fix rate limit packet pacing naming and struct Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 48/75] net/mlx5e: Fix features check of IPv6 traffic Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 49/75] net/mlx5e: Fix possible deadlock of VXLAN lock Greg Kroah-Hartman
2018-01-01 14:32 ` Greg Kroah-Hartman [this message]
2018-01-01 14:32 ` [PATCH 4.9 51/75] net/mlx5e: Prevent possible races in VXLAN control flow Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 52/75] net/mlx5: Fix error flow in CREATE_QP command Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 53/75] s390/qeth: apply takeover changes when mode is toggled Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 54/75] s390/qeth: dont apply takeover changes to RXIP Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 55/75] s390/qeth: lock IP table while applying takeover changes Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 56/75] s390/qeth: update takeover IPs after configuration change Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 57/75] usbip: fix usbip bind writing random string after command in match_busid Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 58/75] usbip: prevent leaking socket pointer address in messages Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 59/75] usbip: stub: stop printing kernel pointer addresses " Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 60/75] usbip: vhci: " Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 61/75] USB: serial: ftdi_sio: add id for Airbus DS P8GR Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 63/75] USB: serial: option: add support for Telit ME910 PID 0x1101 Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 65/75] usb: Add device quirk for Logitech HD Pro Webcam C925e Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 66/75] usb: add RESET_RESUME for ELSA MicroLink 56K Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 67/75] USB: Fix off by one in type-specific length check of BOS SSP capability Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 68/75] usb: xhci: Add XHCI_TRUST_TX_LENGTH for Renesas uPD720201 Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 69/75] timers: Use deferrable base independent of base::nohz_active Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 70/75] timers: Invoke timer_start_debug() where it makes sense Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 71/75] timers: Reinitialize per cpu bases on hotplug Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 72/75] nohz: Prevent a timer interrupt storm in tick_nohz_stop_sched_tick() Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 73/75] x86/smpboot: Remove stale TLB flush invocations Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 74/75] n_tty: fix EXTPROC vs ICANON interaction with TIOCINQ (aka FIONREAD) Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 75/75] tty: fix tty_ldisc_receive_buf() documentation Greg Kroah-Hartman
2018-01-01 20:38 ` [PATCH 4.9 00/75] 4.9.74-stable review Naresh Kamboju
2018-01-02 16:49 ` Guenter Roeck
2018-01-02 18:22 ` Greg Kroah-Hartman
2018-01-02 16:57 ` Neal Cardwell
2018-01-02 18:21 ` Greg Kroah-Hartman
2018-01-02 18:32 ` David Miller
2018-01-02 19:11 ` Neal Cardwell
2018-01-02 19:12 ` David Miller
2018-01-02 20:08 ` Greg KH
2018-01-02 22:31 ` Neal Cardwell
2018-01-02 22:23 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180101140104.965134719@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=galp@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).