Vivien Didelot
2019-Aug-01 19:17 UTC
[Bridge] [PATCH] net: bridge: Allow bridge to joing multicast groups
Hi Horatiu, On Thu, 25 Jul 2019 13:44:04 +0200, Horatiu Vultur <horatiu.vultur at microchip.com> wrote:> There is no way to configure the bridge, to receive only specific link > layer multicast addresses. From the description of the command 'bridge > fdb append' is supposed to do that, but there was no way to notify the > network driver that the bridge joined a group, because LLADDR was added > to the unicast netdev_hw_addr_list. > > Therefore update fdb_add_entry to check if the NLM_F_APPEND flag is set > and if the source is NULL, which represent the bridge itself. Then add > address to multicast netdev_hw_addr_list for each bridge interfaces. > And then the .ndo_set_rx_mode function on the driver is called. To notify > the driver that the list of multicast mac addresses changed. > > Signed-off-by: Horatiu Vultur <horatiu.vultur at microchip.com> > --- > net/bridge/br_fdb.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 46 insertions(+), 3 deletions(-) > > diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c > index b1d3248..d93746d 100644 > --- a/net/bridge/br_fdb.c > +++ b/net/bridge/br_fdb.c > @@ -175,6 +175,29 @@ static void fdb_add_hw_addr(struct net_bridge *br, const unsigned char *addr) > } > } > > +static void fdb_add_hw_maddr(struct net_bridge *br, const unsigned char *addr) > +{ > + int err; > + struct net_bridge_port *p; > + > + ASSERT_RTNL(); > + > + list_for_each_entry(p, &br->port_list, list) { > + if (!br_promisc_port(p)) { > + err = dev_mc_add(p->dev, addr); > + if (err) > + goto undo; > + } > + } > + > + return; > +undo: > + list_for_each_entry_continue_reverse(p, &br->port_list, list) { > + if (!br_promisc_port(p)) > + dev_mc_del(p->dev, addr); > + } > +} > + > /* When a static FDB entry is deleted, the HW address from that entry is > * also removed from the bridge private HW address list and updates all > * the ports with needed information. > @@ -192,13 +215,27 @@ static void fdb_del_hw_addr(struct net_bridge *br, const unsigned char *addr) > } > } > > +static void fdb_del_hw_maddr(struct net_bridge *br, const unsigned char *addr) > +{ > + struct net_bridge_port *p; > + > + ASSERT_RTNL(); > + > + list_for_each_entry(p, &br->port_list, list) { > + if (!br_promisc_port(p)) > + dev_mc_del(p->dev, addr); > + } > +} > + > static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f, > bool swdev_notify) > { > trace_fdb_delete(br, f); > > - if (f->is_static) > + if (f->is_static) { > fdb_del_hw_addr(br, f->key.addr.addr); > + fdb_del_hw_maddr(br, f->key.addr.addr); > + } > > hlist_del_init_rcu(&f->fdb_node); > rhashtable_remove_fast(&br->fdb_hash_tbl, &f->rhnode, > @@ -843,13 +880,19 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source, > fdb->is_local = 1; > if (!fdb->is_static) { > fdb->is_static = 1; > - fdb_add_hw_addr(br, addr); > + if (flags & NLM_F_APPEND && !source) > + fdb_add_hw_maddr(br, addr); > + else > + fdb_add_hw_addr(br, addr); > } > } else if (state & NUD_NOARP) { > fdb->is_local = 0; > if (!fdb->is_static) { > fdb->is_static = 1; > - fdb_add_hw_addr(br, addr); > + if (flags & NLM_F_APPEND && !source) > + fdb_add_hw_maddr(br, addr); > + else > + fdb_add_hw_addr(br, addr); > } > } else { > fdb->is_local = 0; > -- > 2.7.4 >I'm a bit late in the conversation. Isn't this what you want? ip address add <multicast IPv4 address> dev br0 autojoin Thanks, Vivien
Horatiu Vultur
2019-Aug-01 19:48 UTC
[Bridge] [PATCH] net: bridge: Allow bridge to joing multicast groups
Hi Vivien, The 08/01/2019 15:17, Vivien Didelot wrote:> External E-Mail > > I'm a bit late in the conversation. Isn't this what you want? > > ip address add <multicast IPv4 address> dev br0 autojoin >Not really, I was looking in a way to register the ports to link layer multicast address. Sorry for the confusion, my description of the patch was totally missleaning. If you follow this thread you will get a better idea what we wanted to achive. We got some really good comments and based on these we send a RFC[1].> > Thanks, > Vivien[1] https://patchwork.ozlabs.org/patch/1140468/ -- /Horatiu