Skip to content

Commit 36b20fc

Browse files
Murali Karicheridavem330
authored andcommitted
net: hsr: Add support for MC filtering at the slave device
When MC (multicast) list is updated by the networking layer due to a user command and as well as when allmulti flag is set, it needs to be passed to the enslaved Ethernet devices. This patch allows this to happen by implementing ndo_change_rx_flags() and ndo_set_rx_mode() API calls that in turns pass it to the slave devices using existing API calls. Signed-off-by: Murali Karicheri <[email protected]> Signed-off-by: Ravi Gunasekaran <[email protected]> Reviewed-by: Wojciech Drewek <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5347528 commit 36b20fc

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

net/hsr/hsr_device.c

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,24 @@ static int hsr_dev_open(struct net_device *dev)
173173

174174
static int hsr_dev_close(struct net_device *dev)
175175
{
176-
/* Nothing to do here. */
176+
struct hsr_port *port;
177+
struct hsr_priv *hsr;
178+
179+
hsr = netdev_priv(dev);
180+
hsr_for_each_port(hsr, port) {
181+
if (port->type == HSR_PT_MASTER)
182+
continue;
183+
switch (port->type) {
184+
case HSR_PT_SLAVE_A:
185+
case HSR_PT_SLAVE_B:
186+
dev_uc_unsync(port->dev, dev);
187+
dev_mc_unsync(port->dev, dev);
188+
break;
189+
default:
190+
break;
191+
}
192+
}
193+
177194
return 0;
178195
}
179196

@@ -404,12 +421,60 @@ void hsr_del_ports(struct hsr_priv *hsr)
404421
hsr_del_port(port);
405422
}
406423

424+
static void hsr_set_rx_mode(struct net_device *dev)
425+
{
426+
struct hsr_port *port;
427+
struct hsr_priv *hsr;
428+
429+
hsr = netdev_priv(dev);
430+
431+
hsr_for_each_port(hsr, port) {
432+
if (port->type == HSR_PT_MASTER)
433+
continue;
434+
switch (port->type) {
435+
case HSR_PT_SLAVE_A:
436+
case HSR_PT_SLAVE_B:
437+
dev_mc_sync_multiple(port->dev, dev);
438+
dev_uc_sync_multiple(port->dev, dev);
439+
break;
440+
default:
441+
break;
442+
}
443+
}
444+
}
445+
446+
static void hsr_change_rx_flags(struct net_device *dev, int change)
447+
{
448+
struct hsr_port *port;
449+
struct hsr_priv *hsr;
450+
451+
hsr = netdev_priv(dev);
452+
453+
hsr_for_each_port(hsr, port) {
454+
if (port->type == HSR_PT_MASTER)
455+
continue;
456+
switch (port->type) {
457+
case HSR_PT_SLAVE_A:
458+
case HSR_PT_SLAVE_B:
459+
if (change & IFF_ALLMULTI)
460+
dev_set_allmulti(port->dev,
461+
dev->flags &
462+
IFF_ALLMULTI ? 1 : -1);
463+
break;
464+
default:
465+
break;
466+
}
467+
}
468+
}
469+
407470
static const struct net_device_ops hsr_device_ops = {
408471
.ndo_change_mtu = hsr_dev_change_mtu,
409472
.ndo_open = hsr_dev_open,
410473
.ndo_stop = hsr_dev_close,
411474
.ndo_start_xmit = hsr_dev_xmit,
475+
.ndo_change_rx_flags = hsr_change_rx_flags,
412476
.ndo_fix_features = hsr_fix_features,
477+
.ndo_set_rx_mode = hsr_set_rx_mode,
413478
};
414479

415480
static struct device_type hsr_type = {

0 commit comments

Comments
 (0)