Commit 83f7398e authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller

net: bridge: mdb: use extack in br_mdb_add() and br_mdb_add_group()

Pass and use extack all the way down to br_mdb_add_group().
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7eea629d
...@@ -723,7 +723,8 @@ static int br_mdb_parse(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -723,7 +723,8 @@ static int br_mdb_parse(struct sk_buff *skb, struct nlmsghdr *nlh,
} }
static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
struct br_ip *group, struct br_mdb_entry *entry) struct br_ip *group, struct br_mdb_entry *entry,
struct netlink_ext_ack *extack)
{ {
struct net_bridge_mdb_entry *mp; struct net_bridge_mdb_entry *mp;
struct net_bridge_port_group *p; struct net_bridge_port_group *p;
...@@ -742,10 +743,14 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, ...@@ -742,10 +743,14 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
/* host join */ /* host join */
if (!port) { if (!port) {
/* don't allow any flags for host-joined groups */ /* don't allow any flags for host-joined groups */
if (entry->state) if (entry->state) {
NL_SET_ERR_MSG_MOD(extack, "Flags are not allowed for host groups");
return -EINVAL; return -EINVAL;
if (mp->host_joined) }
if (mp->host_joined) {
NL_SET_ERR_MSG_MOD(extack, "Group is already joined by host");
return -EEXIST; return -EEXIST;
}
br_multicast_host_join(mp, false); br_multicast_host_join(mp, false);
br_mdb_notify(br->dev, mp, NULL, RTM_NEWMDB); br_mdb_notify(br->dev, mp, NULL, RTM_NEWMDB);
...@@ -756,16 +761,20 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, ...@@ -756,16 +761,20 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
for (pp = &mp->ports; for (pp = &mp->ports;
(p = mlock_dereference(*pp, br)) != NULL; (p = mlock_dereference(*pp, br)) != NULL;
pp = &p->next) { pp = &p->next) {
if (p->port == port) if (p->port == port) {
NL_SET_ERR_MSG_MOD(extack, "Group is already joined by port");
return -EEXIST; return -EEXIST;
}
if ((unsigned long)p->port < (unsigned long)port) if ((unsigned long)p->port < (unsigned long)port)
break; break;
} }
p = br_multicast_new_port_group(port, group, *pp, entry->state, NULL, p = br_multicast_new_port_group(port, group, *pp, entry->state, NULL,
MCAST_EXCLUDE); MCAST_EXCLUDE);
if (unlikely(!p)) if (unlikely(!p)) {
NL_SET_ERR_MSG_MOD(extack, "Couldn't allocate new port group");
return -ENOMEM; return -ENOMEM;
}
rcu_assign_pointer(*pp, p); rcu_assign_pointer(*pp, p);
if (entry->state == MDB_TEMPORARY) if (entry->state == MDB_TEMPORARY)
mod_timer(&p->timer, now + br->multicast_membership_interval); mod_timer(&p->timer, now + br->multicast_membership_interval);
...@@ -776,7 +785,8 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, ...@@ -776,7 +785,8 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
static int __br_mdb_add(struct net *net, struct net_bridge *br, static int __br_mdb_add(struct net *net, struct net_bridge *br,
struct net_bridge_port *p, struct net_bridge_port *p,
struct br_mdb_entry *entry) struct br_mdb_entry *entry,
struct netlink_ext_ack *extack)
{ {
struct br_ip ip; struct br_ip ip;
int ret; int ret;
...@@ -784,7 +794,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br, ...@@ -784,7 +794,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
__mdb_entry_to_br_ip(entry, &ip); __mdb_entry_to_br_ip(entry, &ip);
spin_lock_bh(&br->multicast_lock); spin_lock_bh(&br->multicast_lock);
ret = br_mdb_add_group(br, p, &ip, entry); ret = br_mdb_add_group(br, p, &ip, entry, extack);
spin_unlock_bh(&br->multicast_lock); spin_unlock_bh(&br->multicast_lock);
return ret; return ret;
...@@ -808,17 +818,37 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -808,17 +818,37 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
br = netdev_priv(dev); br = netdev_priv(dev);
if (!netif_running(br->dev) || !br_opt_get(br, BROPT_MULTICAST_ENABLED)) if (!netif_running(br->dev)) {
NL_SET_ERR_MSG_MOD(extack, "Bridge device is not running");
return -EINVAL; return -EINVAL;
}
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED)) {
NL_SET_ERR_MSG_MOD(extack, "Bridge's multicast processing is disabled");
return -EINVAL;
}
if (entry->ifindex != br->dev->ifindex) { if (entry->ifindex != br->dev->ifindex) {
pdev = __dev_get_by_index(net, entry->ifindex); pdev = __dev_get_by_index(net, entry->ifindex);
if (!pdev) if (!pdev) {
NL_SET_ERR_MSG_MOD(extack, "Port net device doesn't exist");
return -ENODEV; return -ENODEV;
}
p = br_port_get_rtnl(pdev); p = br_port_get_rtnl(pdev);
if (!p || p->br != br || p->state == BR_STATE_DISABLED) if (!p) {
NL_SET_ERR_MSG_MOD(extack, "Net device is not a bridge port");
return -EINVAL; return -EINVAL;
}
if (p->br != br) {
NL_SET_ERR_MSG_MOD(extack, "Port belongs to a different bridge device");
return -EINVAL;
}
if (p->state == BR_STATE_DISABLED) {
NL_SET_ERR_MSG_MOD(extack, "Port is in disabled state");
return -EINVAL;
}
vg = nbp_vlan_group(p); vg = nbp_vlan_group(p);
} else { } else {
vg = br_vlan_group(br); vg = br_vlan_group(br);
...@@ -830,12 +860,12 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -830,12 +860,12 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) { if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) {
list_for_each_entry(v, &vg->vlan_list, vlist) { list_for_each_entry(v, &vg->vlan_list, vlist) {
entry->vid = v->vid; entry->vid = v->vid;
err = __br_mdb_add(net, br, p, entry); err = __br_mdb_add(net, br, p, entry, extack);
if (err) if (err)
break; break;
} }
} else { } else {
err = __br_mdb_add(net, br, p, entry); err = __br_mdb_add(net, br, p, entry, extack);
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment