netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Hurley <john.hurley@netronome.com>
To: netdev@vger.kernel.org
Cc: jiri@mellanox.com, ogerlitz@mellanox.com,
	jakub.kicinski@netronome.com, simon.horman@netronome.com,
	John Hurley <john.hurley@netronome.com>
Subject: [RFC net-next 3/6] drivers: net: bonding: restrict bond mods when rules are offloaded
Date: Mon,  5 Mar 2018 13:28:31 +0000	[thread overview]
Message-ID: <1520256514-27885-4-git-send-email-john.hurley@netronome.com> (raw)
In-Reply-To: <1520256514-27885-1-git-send-email-john.hurley@netronome.com>

When a bond has tc rules offloaded to its slaves, prevent new slaves being
added. To remove a slave from a bond, the offloaded rules must first be
deleted. For the case where a slave port on a bond is unregistered from
the kernel, flush all offloaded rules and destroy the bond.

Signed-off-by: John Hurley <john.hurley@netronome.com>
---
 drivers/net/bonding/bond_main.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index d9e41cf..4c146b1 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1607,6 +1607,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 		return -EPERM;
 	}
 
+	/* check for TC offloaded */
+	if (bond_get_offload_cnt(bond)) {
+		NL_SET_ERR_MSG(extack,
+			       "Cannot enslave - bond has offloaded rules.");
+		netdev_err(bond_dev,
+			   "cannot enslave - bond has offloaded rules.\n");
+		return -EPERM;
+	}
+
 	/* vlan challenged mutual exclusion */
 	/* no need to lock since we're protected by rtnl_lock */
 	if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
@@ -2237,6 +2246,13 @@ static int __bond_release_one(struct net_device *bond_dev,
 /* A wrapper used because of ndo_del_link */
 int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
 {
+	if (bond_get_offload_cnt(netdev_priv(bond_dev))) {
+		netdev_err(bond_dev,
+			   "cannot release %s - has offloaded rules.\n",
+			   slave_dev->name);
+		return -EPERM;
+	}
+
 	return __bond_release_one(bond_dev, slave_dev, false, false);
 }
 
@@ -3325,6 +3341,8 @@ static int bond_slave_netdev_event(unsigned long event,
 	case NETDEV_UNREGISTER:
 		if (bond_dev->type != ARPHRD_ETHER)
 			bond_release_and_destroy(bond_dev, slave_dev);
+		else if (bond_get_offload_cnt(bond))
+			unregister_netdevice_queue(bond_dev, NULL);
 		else
 			__bond_release_one(bond_dev, slave_dev, false, true);
 		break;
-- 
2.7.4

  parent reply	other threads:[~2018-03-05 13:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05 13:28 [RFC net-next 0/6] offload linux bonding tc ingress rules John Hurley
2018-03-05 13:28 ` [RFC net-next 1/6] drivers: net: bonding: add tc offload infastructure to bond John Hurley
2018-03-05 13:28 ` [RFC net-next 2/6] driver: net: bonding: allow registration of tc offload callbacks in bond John Hurley
2018-03-07 10:57   ` Jiri Pirko
2018-03-05 13:28 ` John Hurley [this message]
2018-03-05 13:28 ` [RFC net-next 4/6] nfp: add ndo_set_mac_address for representors John Hurley
2018-03-05 21:39   ` Or Gerlitz
2018-03-05 23:20     ` John Hurley
2018-03-05 13:28 ` [RFC net-next 5/6] nfp: register repr ports for bond offloads John Hurley
2018-03-05 13:28 ` [RFC net-next 6/6] nfp: support offloading multiple rules with same cookie John Hurley
2018-03-05 21:43 ` [RFC net-next 0/6] offload linux bonding tc ingress rules Or Gerlitz
2018-03-05 23:57   ` John Hurley
2018-03-06  0:16     ` Jakub Kicinski
2018-03-05 22:08 ` Jakub Kicinski
2018-03-06  2:34   ` Roopa Prabhu
2018-03-06  7:49 ` Ido Schimmel

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=1520256514-27885-4-git-send-email-john.hurley@netronome.com \
    --to=john.hurley@netronome.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=simon.horman@netronome.com \
    /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).