Subject: Re: [PATCH RFC net-next v1 2/3] macsec: Detect if Rx skb is macsec-related for offloading devices that update md_dst

From: Sabrina Dubroca <[email-masked]>
Date: Wed, 13 Dec 2023 15:36:54 +0100

2023-11-27, 11:10:19 -0800, Rahul Rameshbabu wrote:
> On Thu, 23 Nov, 2023 15:38:04 +0100 Sabrina Dubroca <[email-masked]> wrote:
> > If the device provided md_dst, either we find the corresponding rx_sc,
> > then we receive on this macsec device only, or we don't and try the
> > other macsec devices.
> >
> > Something like this (completely untested):
> >
> > 	if (macsec_is_offloaded(macsec) && netif_running(ndev)) {
> > 		struct macsec_rx_sc *rx_sc = NULL;
> > 		bool exact = false;
> >
> > 		if (macsec->offload_md_dst && !is_macsec_md_dst)
> > 			continue;
> >
> > 		if (is_macsec_md_dst) {
> > 			DEBUG_NET_WARN_ON_ONCE(!macsec->offload_md_dst);
> > 			rx_sc = find_rx_sc(&macsec->secy, md_dst->u.macsec_info.sci);
> > 			if (!rx_sc)
> > 				continue;
> > 			exact = true;
> > 		}
> >
> > 		if (exact ||
> > 		    ether_addr_equal_64bits(hdr->h_dest, ndev->dev_addr)) {
> > 			/* exact match, divert skb to this port */
> > 	[keep the existing code after this]
> >
> >
> > Am I missing something?
> 
> I just have one question with regards to this (will be testing this out
> too). For the exact match case, if the receiving traffic was macsec
> encrypted multicast, would the pkt_type be PACKET_HOST or
> PACKET_BROADCAST/PACKET_MULTICAST? My intuition is screaming to me that
> '[keep the existing code after this]' is not 100% true because we would
> want to update the skb pkt_type to PACKET_BROADCAST/PACKET_MULTICAST
> even if we are able to identify the incoming multicast frame was macsec
> encrypted and specifically intended for this device. Does that sound
> right?

Yes, I guess. SW decrypt path calls eth_type_trans, but that does a
lot more than we need here.

-- 
Sabrina