Skip to content

Commit a55d824

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
bridge: mcast: add support for temporary port router
Add support for a temporary router port which doesn't depend only on the incoming query. It can be refreshed if set to the same value, which is a no-op for the rest. Signed-off-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4950cfd commit a55d824

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

include/uapi/linux/if_bridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ enum {
182182
MDB_RTR_TYPE_DISABLED,
183183
MDB_RTR_TYPE_TEMP_QUERY,
184184
MDB_RTR_TYPE_PERM,
185+
MDB_RTR_TYPE_TEMP
185186
};
186187

187188
enum {

net/bridge/br_multicast.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,13 +759,17 @@ static void br_multicast_router_expired(unsigned long data)
759759
struct net_bridge *br = port->br;
760760

761761
spin_lock(&br->multicast_lock);
762-
if (port->multicast_router != MDB_RTR_TYPE_TEMP_QUERY ||
762+
if (port->multicast_router == MDB_RTR_TYPE_DISABLED ||
763+
port->multicast_router == MDB_RTR_TYPE_PERM ||
763764
timer_pending(&port->multicast_router_timer) ||
764765
hlist_unhashed(&port->rlist))
765766
goto out;
766767

767768
hlist_del_init_rcu(&port->rlist);
768769
br_rtr_notify(br->dev, port, RTM_DELMDB);
770+
/* Don't allow timer refresh if the router expired */
771+
if (port->multicast_router == MDB_RTR_TYPE_TEMP)
772+
port->multicast_router = MDB_RTR_TYPE_TEMP_QUERY;
769773

770774
out:
771775
spin_unlock(&br->multicast_lock);
@@ -981,6 +985,9 @@ void br_multicast_disable_port(struct net_bridge_port *port)
981985
if (!hlist_unhashed(&port->rlist)) {
982986
hlist_del_init_rcu(&port->rlist);
983987
br_rtr_notify(br->dev, port, RTM_DELMDB);
988+
/* Don't allow timer refresh if disabling */
989+
if (port->multicast_router == MDB_RTR_TYPE_TEMP)
990+
port->multicast_router = MDB_RTR_TYPE_TEMP_QUERY;
984991
}
985992
del_timer(&port->multicast_router_timer);
986993
del_timer(&port->ip4_own_query.timer);
@@ -1234,7 +1241,8 @@ static void br_multicast_mark_router(struct net_bridge *br,
12341241
return;
12351242
}
12361243

1237-
if (port->multicast_router != MDB_RTR_TYPE_TEMP_QUERY)
1244+
if (port->multicast_router == MDB_RTR_TYPE_DISABLED ||
1245+
port->multicast_router == MDB_RTR_TYPE_PERM)
12381246
return;
12391247

12401248
br_multicast_add_router(br, port);
@@ -1850,10 +1858,15 @@ static void __del_port_router(struct net_bridge_port *p)
18501858
int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val)
18511859
{
18521860
struct net_bridge *br = p->br;
1861+
unsigned long now = jiffies;
18531862
int err = -EINVAL;
18541863

18551864
spin_lock(&br->multicast_lock);
18561865
if (p->multicast_router == val) {
1866+
/* Refresh the temp router port timer */
1867+
if (p->multicast_router == MDB_RTR_TYPE_TEMP)
1868+
mod_timer(&p->multicast_router_timer,
1869+
now + br->multicast_querier_interval);
18571870
err = 0;
18581871
goto unlock;
18591872
}
@@ -1872,6 +1885,10 @@ int br_multicast_set_port_router(struct net_bridge_port *p, unsigned long val)
18721885
del_timer(&p->multicast_router_timer);
18731886
br_multicast_add_router(br, p);
18741887
break;
1888+
case MDB_RTR_TYPE_TEMP:
1889+
p->multicast_router = MDB_RTR_TYPE_TEMP;
1890+
br_multicast_mark_router(br, p);
1891+
break;
18751892
default:
18761893
goto unlock;
18771894
}

0 commit comments

Comments
 (0)