net: bridge: convert and rename mcast disabled
Convert mcast disabled to an option bit and while doing so convert the logic to check if multicast is enabled instead. That is make the logic follow the option value - if it's set then mcast is enabled and vice versa. This avoids a few confusing places where we inverted the value that's being set to follow the mcast_disabled logic. Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
be3664a038
Коммит
13cefad2f2
|
@ -84,7 +84,7 @@ static int br_mdb_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
|
||||||
int i, err = 0;
|
int i, err = 0;
|
||||||
int idx = 0, s_idx = cb->args[1];
|
int idx = 0, s_idx = cb->args[1];
|
||||||
|
|
||||||
if (br->multicast_disabled)
|
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mdb = rcu_dereference(br->mdb);
|
mdb = rcu_dereference(br->mdb);
|
||||||
|
@ -598,7 +598,7 @@ static int __br_mdb_add(struct net *net, struct net_bridge *br,
|
||||||
struct net_bridge_port *p;
|
struct net_bridge_port *p;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!netif_running(br->dev) || br->multicast_disabled)
|
if (!netif_running(br->dev) || !br_opt_get(br, BROPT_MULTICAST_ENABLED))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
dev = __dev_get_by_index(net, entry->ifindex);
|
dev = __dev_get_by_index(net, entry->ifindex);
|
||||||
|
@ -673,7 +673,7 @@ static int __br_mdb_del(struct net_bridge *br, struct br_mdb_entry *entry)
|
||||||
struct br_ip ip;
|
struct br_ip ip;
|
||||||
int err = -EINVAL;
|
int err = -EINVAL;
|
||||||
|
|
||||||
if (!netif_running(br->dev) || br->multicast_disabled)
|
if (!netif_running(br->dev) || !br_opt_get(br, BROPT_MULTICAST_ENABLED))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
__mdb_entry_to_br_ip(entry, &ip);
|
__mdb_entry_to_br_ip(entry, &ip);
|
||||||
|
|
|
@ -158,7 +158,7 @@ struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
|
||||||
struct net_bridge_mdb_htable *mdb = rcu_dereference(br->mdb);
|
struct net_bridge_mdb_htable *mdb = rcu_dereference(br->mdb);
|
||||||
struct br_ip ip;
|
struct br_ip ip;
|
||||||
|
|
||||||
if (br->multicast_disabled)
|
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (BR_INPUT_SKB_CB(skb)->igmp)
|
if (BR_INPUT_SKB_CB(skb)->igmp)
|
||||||
|
@ -628,7 +628,7 @@ static struct net_bridge_mdb_entry *br_multicast_get_group(
|
||||||
port ? port->dev->name : br->dev->name);
|
port ? port->dev->name : br->dev->name);
|
||||||
err = -E2BIG;
|
err = -E2BIG;
|
||||||
disable:
|
disable:
|
||||||
br->multicast_disabled = 1;
|
br_opt_toggle(br, BROPT_MULTICAST_ENABLED, false);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -894,7 +894,7 @@ static void br_multicast_querier_expired(struct net_bridge *br,
|
||||||
struct bridge_mcast_own_query *query)
|
struct bridge_mcast_own_query *query)
|
||||||
{
|
{
|
||||||
spin_lock(&br->multicast_lock);
|
spin_lock(&br->multicast_lock);
|
||||||
if (!netif_running(br->dev) || br->multicast_disabled)
|
if (!netif_running(br->dev) || !br_opt_get(br, BROPT_MULTICAST_ENABLED))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
br_multicast_start_querier(br, query);
|
br_multicast_start_querier(br, query);
|
||||||
|
@ -965,7 +965,8 @@ static void br_multicast_send_query(struct net_bridge *br,
|
||||||
struct br_ip br_group;
|
struct br_ip br_group;
|
||||||
unsigned long time;
|
unsigned long time;
|
||||||
|
|
||||||
if (!netif_running(br->dev) || br->multicast_disabled ||
|
if (!netif_running(br->dev) ||
|
||||||
|
!br_opt_get(br, BROPT_MULTICAST_ENABLED) ||
|
||||||
!br->multicast_querier)
|
!br->multicast_querier)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1036,7 +1037,7 @@ static void br_mc_disabled_update(struct net_device *dev, bool value)
|
||||||
.orig_dev = dev,
|
.orig_dev = dev,
|
||||||
.id = SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED,
|
.id = SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED,
|
||||||
.flags = SWITCHDEV_F_DEFER,
|
.flags = SWITCHDEV_F_DEFER,
|
||||||
.u.mc_disabled = value,
|
.u.mc_disabled = !value,
|
||||||
};
|
};
|
||||||
|
|
||||||
switchdev_port_attr_set(dev, &attr);
|
switchdev_port_attr_set(dev, &attr);
|
||||||
|
@ -1054,7 +1055,8 @@ int br_multicast_add_port(struct net_bridge_port *port)
|
||||||
timer_setup(&port->ip6_own_query.timer,
|
timer_setup(&port->ip6_own_query.timer,
|
||||||
br_ip6_multicast_port_query_expired, 0);
|
br_ip6_multicast_port_query_expired, 0);
|
||||||
#endif
|
#endif
|
||||||
br_mc_disabled_update(port->dev, port->br->multicast_disabled);
|
br_mc_disabled_update(port->dev,
|
||||||
|
br_opt_get(port->br, BROPT_MULTICAST_ENABLED));
|
||||||
|
|
||||||
port->mcast_stats = netdev_alloc_pcpu_stats(struct bridge_mcast_stats);
|
port->mcast_stats = netdev_alloc_pcpu_stats(struct bridge_mcast_stats);
|
||||||
if (!port->mcast_stats)
|
if (!port->mcast_stats)
|
||||||
|
@ -1091,7 +1093,7 @@ static void __br_multicast_enable_port(struct net_bridge_port *port)
|
||||||
{
|
{
|
||||||
struct net_bridge *br = port->br;
|
struct net_bridge *br = port->br;
|
||||||
|
|
||||||
if (br->multicast_disabled || !netif_running(br->dev))
|
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED) || !netif_running(br->dev))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
br_multicast_enable(&port->ip4_own_query);
|
br_multicast_enable(&port->ip4_own_query);
|
||||||
|
@ -1904,7 +1906,7 @@ int br_multicast_rcv(struct net_bridge *br, struct net_bridge_port *port,
|
||||||
BR_INPUT_SKB_CB(skb)->igmp = 0;
|
BR_INPUT_SKB_CB(skb)->igmp = 0;
|
||||||
BR_INPUT_SKB_CB(skb)->mrouters_only = 0;
|
BR_INPUT_SKB_CB(skb)->mrouters_only = 0;
|
||||||
|
|
||||||
if (br->multicast_disabled)
|
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (skb->protocol) {
|
switch (skb->protocol) {
|
||||||
|
@ -1998,7 +2000,7 @@ static void __br_multicast_open(struct net_bridge *br,
|
||||||
{
|
{
|
||||||
query->startup_sent = 0;
|
query->startup_sent = 0;
|
||||||
|
|
||||||
if (br->multicast_disabled)
|
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mod_timer(&query->timer, jiffies);
|
mod_timer(&query->timer, jiffies);
|
||||||
|
@ -2173,12 +2175,12 @@ int br_multicast_toggle(struct net_bridge *br, unsigned long val)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
spin_lock_bh(&br->multicast_lock);
|
spin_lock_bh(&br->multicast_lock);
|
||||||
if (br->multicast_disabled == !val)
|
if (!!br_opt_get(br, BROPT_MULTICAST_ENABLED) == !!val)
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
br_mc_disabled_update(br->dev, !val);
|
br_mc_disabled_update(br->dev, val);
|
||||||
br->multicast_disabled = !val;
|
br_opt_toggle(br, BROPT_MULTICAST_ENABLED, !!val);
|
||||||
if (br->multicast_disabled)
|
if (!br_opt_get(br, BROPT_MULTICAST_ENABLED))
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
if (!netif_running(br->dev))
|
if (!netif_running(br->dev))
|
||||||
|
@ -2189,7 +2191,7 @@ int br_multicast_toggle(struct net_bridge *br, unsigned long val)
|
||||||
if (mdb->old) {
|
if (mdb->old) {
|
||||||
err = -EEXIST;
|
err = -EEXIST;
|
||||||
rollback:
|
rollback:
|
||||||
br->multicast_disabled = !!val;
|
br_opt_toggle(br, BROPT_MULTICAST_ENABLED, false);
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2213,7 +2215,7 @@ bool br_multicast_enabled(const struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct net_bridge *br = netdev_priv(dev);
|
struct net_bridge *br = netdev_priv(dev);
|
||||||
|
|
||||||
return !br->multicast_disabled;
|
return !!br_opt_get(br, BROPT_MULTICAST_ENABLED);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(br_multicast_enabled);
|
EXPORT_SYMBOL_GPL(br_multicast_enabled);
|
||||||
|
|
||||||
|
|
|
@ -1422,7 +1422,8 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
||||||
if (nla_put_u8(skb, IFLA_BR_MCAST_ROUTER, br->multicast_router) ||
|
if (nla_put_u8(skb, IFLA_BR_MCAST_ROUTER, br->multicast_router) ||
|
||||||
nla_put_u8(skb, IFLA_BR_MCAST_SNOOPING, !br->multicast_disabled) ||
|
nla_put_u8(skb, IFLA_BR_MCAST_SNOOPING,
|
||||||
|
br_opt_get(br, BROPT_MULTICAST_ENABLED)) ||
|
||||||
nla_put_u8(skb, IFLA_BR_MCAST_QUERY_USE_IFADDR,
|
nla_put_u8(skb, IFLA_BR_MCAST_QUERY_USE_IFADDR,
|
||||||
br->multicast_query_use_ifaddr) ||
|
br->multicast_query_use_ifaddr) ||
|
||||||
nla_put_u8(skb, IFLA_BR_MCAST_QUERIER, br->multicast_querier) ||
|
nla_put_u8(skb, IFLA_BR_MCAST_QUERIER, br->multicast_querier) ||
|
||||||
|
|
|
@ -313,6 +313,7 @@ enum net_bridge_opts {
|
||||||
BROPT_NF_CALL_IP6TABLES,
|
BROPT_NF_CALL_IP6TABLES,
|
||||||
BROPT_NF_CALL_ARPTABLES,
|
BROPT_NF_CALL_ARPTABLES,
|
||||||
BROPT_GROUP_ADDR_SET,
|
BROPT_GROUP_ADDR_SET,
|
||||||
|
BROPT_MULTICAST_ENABLED,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct net_bridge {
|
struct net_bridge {
|
||||||
|
@ -366,7 +367,6 @@ struct net_bridge {
|
||||||
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
||||||
unsigned char multicast_router;
|
unsigned char multicast_router;
|
||||||
|
|
||||||
u8 multicast_disabled:1;
|
|
||||||
u8 multicast_querier:1;
|
u8 multicast_querier:1;
|
||||||
u8 multicast_query_use_ifaddr:1;
|
u8 multicast_query_use_ifaddr:1;
|
||||||
u8 has_ipv6_addr:1;
|
u8 has_ipv6_addr:1;
|
||||||
|
|
|
@ -349,7 +349,7 @@ static ssize_t multicast_snooping_show(struct device *d,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct net_bridge *br = to_bridge(d);
|
struct net_bridge *br = to_bridge(d);
|
||||||
return sprintf(buf, "%d\n", !br->multicast_disabled);
|
return sprintf(buf, "%d\n", br_opt_get(br, BROPT_MULTICAST_ENABLED));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t multicast_snooping_store(struct device *d,
|
static ssize_t multicast_snooping_store(struct device *d,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче