net: bridge: mcast: consolidate querier selection for ipv4 and ipv6
We can consolidate both functions as they share almost the same logic. This is easier to maintain and we have a single querier update function. Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
67b746f94f
commit
c3fb3698f9
@ -2864,55 +2864,46 @@ unlock_continue:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool br_ip4_multicast_select_querier(struct net_bridge_mcast *brmctx,
|
static bool br_multicast_select_querier(struct net_bridge_mcast *brmctx,
|
||||||
struct net_bridge_mcast_port *pmctx,
|
struct net_bridge_mcast_port *pmctx,
|
||||||
struct br_ip *saddr)
|
struct br_ip *saddr)
|
||||||
{
|
{
|
||||||
int port_ifidx = pmctx ? pmctx->port->dev->ifindex : 0;
|
int port_ifidx = pmctx ? pmctx->port->dev->ifindex : 0;
|
||||||
|
struct timer_list *own_timer, *other_timer;
|
||||||
|
struct bridge_mcast_querier *querier;
|
||||||
|
|
||||||
if (!timer_pending(&brmctx->ip4_own_query.timer) &&
|
switch (saddr->proto) {
|
||||||
!timer_pending(&brmctx->ip4_other_query.timer))
|
case htons(ETH_P_IP):
|
||||||
|
querier = &brmctx->ip4_querier;
|
||||||
|
own_timer = &brmctx->ip4_own_query.timer;
|
||||||
|
other_timer = &brmctx->ip4_other_query.timer;
|
||||||
|
if (!querier->addr.src.ip4 ||
|
||||||
|
ntohl(saddr->src.ip4) <= ntohl(querier->addr.src.ip4))
|
||||||
goto update;
|
goto update;
|
||||||
|
break;
|
||||||
if (!brmctx->ip4_querier.addr.src.ip4)
|
|
||||||
goto update;
|
|
||||||
|
|
||||||
if (ntohl(saddr->src.ip4) <= ntohl(brmctx->ip4_querier.addr.src.ip4))
|
|
||||||
goto update;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
update:
|
|
||||||
br_multicast_update_querier(brmctx, &brmctx->ip4_querier, port_ifidx,
|
|
||||||
saddr);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_IPV6)
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
static bool br_ip6_multicast_select_querier(struct net_bridge_mcast *brmctx,
|
case htons(ETH_P_IPV6):
|
||||||
struct net_bridge_mcast_port *pmctx,
|
querier = &brmctx->ip6_querier;
|
||||||
struct br_ip *saddr)
|
own_timer = &brmctx->ip6_own_query.timer;
|
||||||
{
|
other_timer = &brmctx->ip6_other_query.timer;
|
||||||
int port_ifidx = pmctx ? pmctx->port->dev->ifindex : 0;
|
if (ipv6_addr_cmp(&saddr->src.ip6, &querier->addr.src.ip6) <= 0)
|
||||||
|
|
||||||
if (!timer_pending(&brmctx->ip6_own_query.timer) &&
|
|
||||||
!timer_pending(&brmctx->ip6_other_query.timer))
|
|
||||||
goto update;
|
goto update;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (ipv6_addr_cmp(&saddr->src.ip6,
|
if (!timer_pending(own_timer) && !timer_pending(other_timer))
|
||||||
&brmctx->ip6_querier.addr.src.ip6) <= 0)
|
|
||||||
goto update;
|
goto update;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
update:
|
update:
|
||||||
br_multicast_update_querier(brmctx, &brmctx->ip6_querier, port_ifidx,
|
br_multicast_update_querier(brmctx, querier, port_ifidx, saddr);
|
||||||
saddr);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
br_multicast_update_query_timer(struct net_bridge_mcast *brmctx,
|
br_multicast_update_query_timer(struct net_bridge_mcast *brmctx,
|
||||||
@ -3115,7 +3106,7 @@ br_ip4_multicast_query_received(struct net_bridge_mcast *brmctx,
|
|||||||
struct br_ip *saddr,
|
struct br_ip *saddr,
|
||||||
unsigned long max_delay)
|
unsigned long max_delay)
|
||||||
{
|
{
|
||||||
if (!br_ip4_multicast_select_querier(brmctx, pmctx, saddr))
|
if (!br_multicast_select_querier(brmctx, pmctx, saddr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
br_multicast_update_query_timer(brmctx, query, max_delay);
|
br_multicast_update_query_timer(brmctx, query, max_delay);
|
||||||
@ -3130,7 +3121,7 @@ br_ip6_multicast_query_received(struct net_bridge_mcast *brmctx,
|
|||||||
struct br_ip *saddr,
|
struct br_ip *saddr,
|
||||||
unsigned long max_delay)
|
unsigned long max_delay)
|
||||||
{
|
{
|
||||||
if (!br_ip6_multicast_select_querier(brmctx, pmctx, saddr))
|
if (!br_multicast_select_querier(brmctx, pmctx, saddr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
br_multicast_update_query_timer(brmctx, query, max_delay);
|
br_multicast_update_query_timer(brmctx, query, max_delay);
|
||||||
|
Loading…
Reference in New Issue
Block a user