summaryrefslogtreecommitdiff
path: root/net/dsa/switch.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2021-10-25 14:59:25 +0300
committerDavid S. Miller <davem@davemloft.net>2021-10-25 14:59:25 +0300
commit2d7e73f09fc2f5d968ca375f047718cf25ae2b92 (patch)
tree6091f03456ecea6d6eda5bbf064af911df649768 /net/dsa/switch.c
parent12f241f26436cf1134f8a05551d23961ee46037e (diff)
downloadlinux-2d7e73f09fc2f5d968ca375f047718cf25ae2b92.tar.xz
Revert "Merge branch 'dsa-rtnl'"
This reverts commit 965e6b262f48257dbdb51b565ecfd84877a0ab5f, reversing changes made to 4d98bb0d7ec2d0b417df6207b0bafe1868bad9f8.
Diffstat (limited to 'net/dsa/switch.c')
-rw-r--r--net/dsa/switch.c76
1 files changed, 24 insertions, 52 deletions
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,