summaryrefslogtreecommitdiff
path: root/net/dsa
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2021-10-25 12:59:25 +0100
committerDavid S. Miller <davem@davemloft.net>2021-10-25 12:59:25 +0100
commit2d7e73f09fc2f5d968ca375f047718cf25ae2b92 (patch)
tree6091f03456ecea6d6eda5bbf064af911df649768 /net/dsa
parent12f241f26436cf1134f8a05551d23961ee46037e (diff)
Revert "Merge branch 'dsa-rtnl'"
This reverts commit 965e6b262f48257dbdb51b565ecfd84877a0ab5f, reversing changes made to 4d98bb0d7ec2d0b417df6207b0bafe1868bad9f8.
Diffstat (limited to 'net/dsa')
-rw-r--r--net/dsa/dsa2.c1
-rw-r--r--net/dsa/slave.c2
-rw-r--r--net/dsa/switch.c76
3 files changed, 26 insertions, 53 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 826957b6442b..f5270114dcb8 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -433,7 +433,6 @@ static int dsa_port_setup(struct dsa_port *dp)
if (dp->setup)
return 0;
- mutex_init(&dp->addr_lists_lock);
INIT_LIST_HEAD(&dp->fdbs);
INIT_LIST_HEAD(&dp->mdbs);
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index adcfb2cb4e61..9d9fef668eba 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2413,6 +2413,7 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work)
dp = dsa_to_port(ds, switchdev_work->port);
+ rtnl_lock();
switch (switchdev_work->event) {
case SWITCHDEV_FDB_ADD_TO_DEVICE:
if (switchdev_work->host_addr)
@@ -2447,6 +2448,7 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work)
break;
}
+ rtnl_unlock();
dev_put(switchdev_work->dev);
kfree(switchdev_work);
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 6871e5f9b597..2b1b21bde830 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -215,30 +215,26 @@ static int dsa_port_do_mdb_add(struct dsa_port *dp,
struct dsa_switch *ds = dp->ds;
struct dsa_mac_addr *a;
int port = dp->index;
- int err = 0;
+ int err;
/* No need to bother with refcounting for user ports */
if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
return ds->ops->port_mdb_add(ds, port, mdb);
- mutex_lock(&dp->addr_lists_lock);
-
a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid);
if (a) {
refcount_inc(&a->refcount);
- goto out;
+ return 0;
}
a = kzalloc(sizeof(*a), GFP_KERNEL);
- if (!a) {
- err = -ENOMEM;
- goto out;
- }
+ if (!a)
+ return -ENOMEM;
err = ds->ops->port_mdb_add(ds, port, mdb);
if (err) {
kfree(a);
- goto out;
+ return err;
}
ether_addr_copy(a->addr, mdb->addr);
@@ -246,10 +242,7 @@ static int dsa_port_do_mdb_add(struct dsa_port *dp,
refcount_set(&a->refcount, 1);
list_add_tail(&a->list, &dp->mdbs);
-out:
- mutex_unlock(&dp->addr_lists_lock);
-
- return err;
+ return 0;
}
static int dsa_port_do_mdb_del(struct dsa_port *dp,
@@ -258,36 +251,29 @@ static int dsa_port_do_mdb_del(struct dsa_port *dp,
struct dsa_switch *ds = dp->ds;
struct dsa_mac_addr *a;
int port = dp->index;
- int err = 0;
+ int err;
/* No need to bother with refcounting for user ports */
if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
return ds->ops->port_mdb_del(ds, port, mdb);
- mutex_lock(&dp->addr_lists_lock);
-
a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid);
- if (!a) {
- err = -ENOENT;
- goto out;
- }
+ if (!a)
+ return -ENOENT;
if (!refcount_dec_and_test(&a->refcount))
- goto out;
+ return 0;
err = ds->ops->port_mdb_del(ds, port, mdb);
if (err) {
refcount_inc(&a->refcount);
- goto out;
+ return err;
}
list_del(&a->list);
kfree(a);
-out:
- mutex_unlock(&dp->addr_lists_lock);
-
- return err;
+ return 0;
}
static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr,
@@ -296,30 +282,26 @@ static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr,
struct dsa_switch *ds = dp->ds;
struct dsa_mac_addr *a;
int port = dp->index;
- int err = 0;
+ int err;
/* No need to bother with refcounting for user ports */
if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
return ds->ops->port_fdb_add(ds, port, addr, vid);
- mutex_lock(&dp->addr_lists_lock);
-
a = dsa_mac_addr_find(&dp->fdbs, addr, vid);
if (a) {
refcount_inc(&a->refcount);
- goto out;
+ return 0;
}
a = kzalloc(sizeof(*a), GFP_KERNEL);
- if (!a) {
- err = -ENOMEM;
- goto out;
- }
+ if (!a)
+ return -ENOMEM;
err = ds->ops->port_fdb_add(ds, port, addr, vid);
if (err) {
kfree(a);
- goto out;
+ return err;
}
ether_addr_copy(a->addr, addr);
@@ -327,10 +309,7 @@ static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr,
refcount_set(&a->refcount, 1);
list_add_tail(&a->list, &dp->fdbs);
-out:
- mutex_unlock(&dp->addr_lists_lock);
-
- return err;
+ return 0;
}
static int dsa_port_do_fdb_del(struct dsa_port *dp, const unsigned char *addr,
@@ -339,36 +318,29 @@ static int dsa_port_do_fdb_del(struct dsa_port *dp, const unsigned char *addr,
struct dsa_switch *ds = dp->ds;
struct dsa_mac_addr *a;
int port = dp->index;
- int err = 0;
+ int err;
/* No need to bother with refcounting for user ports */
if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp)))
return ds->ops->port_fdb_del(ds, port, addr, vid);
- mutex_lock(&dp->addr_lists_lock);
-
a = dsa_mac_addr_find(&dp->fdbs, addr, vid);
- if (!a) {
- err = -ENOENT;
- goto out;
- }
+ if (!a)
+ return -ENOENT;
if (!refcount_dec_and_test(&a->refcount))
- goto out;
+ return 0;
err = ds->ops->port_fdb_del(ds, port, addr, vid);
if (err) {
refcount_inc(&a->refcount);
- goto out;
+ return err;
}
list_del(&a->list);
kfree(a);
-out:
- mutex_unlock(&dp->addr_lists_lock);
-
- return err;
+ return 0;
}
static int dsa_switch_host_fdb_add(struct dsa_switch *ds,