Skip to content

Commit 7661351

Browse files
Emeel Hakimdavem330
authored andcommitted
macsec: Don't rely solely on the dst MAC address to identify destination MACsec device
Offloading device drivers will mark offloaded MACsec SKBs with the corresponding SCI in the skb_metadata_dst so the macsec rx handler will know to which interface to divert those skbs, in case of a marked skb and a mismatch on the dst MAC address, divert the skb to the macsec net_device where the macsec rx_handler will be called to consider cases where relying solely on the dst MAC address is insufficient. One such instance is when using MACsec with a VLAN as an inner header, where the packet structure is ETHERNET | SECTAG | VLAN. In such a scenario, the dst MAC address in the ethernet header will correspond to the VLAN MAC address, resulting in a mismatch. Signed-off-by: Emeel Hakim <ehakim@nvidia.com> Reviewed-by: Subbaraya Sundeep <sbhatta@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 765f974 commit 7661351

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/net/macsec.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,12 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb)
10211021
* the SecTAG, so we have to deduce which port to deliver to.
10221022
*/
10231023
if (macsec_is_offloaded(macsec) && netif_running(ndev)) {
1024-
if (md_dst && md_dst->type == METADATA_MACSEC &&
1025-
(!find_rx_sc(&macsec->secy, md_dst->u.macsec_info.sci)))
1024+
struct macsec_rx_sc *rx_sc = NULL;
1025+
1026+
if (md_dst && md_dst->type == METADATA_MACSEC)
1027+
rx_sc = find_rx_sc(&macsec->secy, md_dst->u.macsec_info.sci);
1028+
1029+
if (md_dst && md_dst->type == METADATA_MACSEC && !rx_sc)
10261030
continue;
10271031

10281032
if (ether_addr_equal_64bits(hdr->h_dest,
@@ -1047,7 +1051,13 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb)
10471051
nskb->pkt_type = PACKET_MULTICAST;
10481052

10491053
__netif_rx(nskb);
1054+
} else if (rx_sc || ndev->flags & IFF_PROMISC) {
1055+
skb->dev = ndev;
1056+
skb->pkt_type = PACKET_HOST;
1057+
ret = RX_HANDLER_ANOTHER;
1058+
goto out;
10501059
}
1060+
10511061
continue;
10521062
}
10531063

0 commit comments

Comments
 (0)