Skip to content

Commit

Permalink
dsa: Allow forwarding of redirected IGMP traffic
Browse files Browse the repository at this point in the history
The driver for Marvell switches puts all ports in IGMP snooping mode
which results in all IGMP/MLD frames that ingress on the ports to be
forwarded to the CPU only.

The bridge code in the kernel can then interpret these frames and act
upon them, for instance by updating the mdb in the switch to reflect
multicast memberships of stations connected to the ports. However,
the IGMP/MLD frames must then also be forwarded to other ports of the
bridge so external IGMP queriers can track membership reports, and
external multicast clients can receive query reports from foreign IGMP
queriers.

Currently, this is impossible as the EDSA tagger sets offload_fwd_mark
on the skb when it unwraps the tagged frames, and that will make the
switchdev layer prevent the skb from egressing on any other port of
the same switch.

To fix that, look at the To_CPU code in the DSA header and make
forwarding of the frame possible for trapped IGMP packets.

Introduce some #defines for the frame types to make the code a bit more
comprehensive.

This was tested on a Marvell 88E6352 variant.

Signed-off-by: Daniel Mack <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Tested-by: Andrew Lunn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
zonque authored and davem330 committed Jun 24, 2020
1 parent 1784365 commit 1ed9ec9
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions net/dsa/tag_edsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
#define DSA_HLEN 4
#define EDSA_HLEN 8

#define FRAME_TYPE_TO_CPU 0x00
#define FRAME_TYPE_FORWARD 0x03

#define TO_CPU_CODE_MGMT_TRAP 0x00
#define TO_CPU_CODE_FRAME2REG 0x01
#define TO_CPU_CODE_IGMP_MLD_TRAP 0x02
#define TO_CPU_CODE_POLICY_TRAP 0x03
#define TO_CPU_CODE_ARP_MIRROR 0x04
#define TO_CPU_CODE_POLICY_MIRROR 0x05

static struct sk_buff *edsa_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct dsa_port *dp = dsa_slave_to_port(dev);
Expand Down Expand Up @@ -77,6 +87,8 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
{
u8 *edsa_header;
int frame_type;
int code;
int source_device;
int source_port;

Expand All @@ -91,8 +103,29 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
/*
* Check that frame type is either TO_CPU or FORWARD.
*/
if ((edsa_header[0] & 0xc0) != 0x00 && (edsa_header[0] & 0xc0) != 0xc0)
frame_type = edsa_header[0] >> 6;

switch (frame_type) {
case FRAME_TYPE_TO_CPU:
code = (edsa_header[1] & 0x6) | ((edsa_header[2] >> 4) & 1);

/*
* Mark the frame to never egress on any port of the same switch
* unless it's a trapped IGMP/MLD packet, in which case the
* bridge might want to forward it.
*/
if (code != TO_CPU_CODE_IGMP_MLD_TRAP)
skb->offload_fwd_mark = 1;

break;

case FRAME_TYPE_FORWARD:
skb->offload_fwd_mark = 1;
break;

default:
return NULL;
}

/*
* Determine source device and port.
Expand Down Expand Up @@ -156,8 +189,6 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
2 * ETH_ALEN);
}

skb->offload_fwd_mark = 1;

return skb;
}

Expand Down

0 comments on commit 1ed9ec9

Please sign in to comment.