Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8482465b authored by Antoine Tenart's avatar Antoine Tenart Committed by Jinesh K. Jayakumar
Browse files

net: macsec: PN wrap callback (#10)



[ Upstream (net-next) commit 5c937de78b39e47ce9924fc4b863c5b727edc328 ]

Allow to call macsec_pn_wrapped from hardware drivers to notify when a
PN rolls over. Some drivers might used an interrupt to implement this.

Change-Id: I6f749e47b8127908d06c60d23ad4831bb7a91f6d
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Git-commit: 195ac132552b03d0cc918dd1c6e42463e372706c
Git-repo: https://github.com/aquantia/linux-4.14-atlantic-forwarding


Signed-off-by: default avatarJinesh K. Jayakumar <jineshk@codeaurora.org>
parent 8e710728
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -410,6 +410,23 @@ static struct macsec_eth_header *macsec_ethhdr(struct sk_buff *skb)
	return (struct macsec_eth_header *)skb_mac_header(skb);
}

static void __macsec_pn_wrapped(struct macsec_secy *secy,
				struct macsec_tx_sa *tx_sa)
{
	pr_debug("PN wrapped, transitioning to !oper\n");
	tx_sa->active = false;
	if (secy->protect_frames)
		secy->operational = false;
}

void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa)
{
	spin_lock_bh(&tx_sa->lock);
	__macsec_pn_wrapped(secy, tx_sa);
	spin_unlock_bh(&tx_sa->lock);
}
EXPORT_SYMBOL_GPL(macsec_pn_wrapped);

static u32 tx_sa_update_pn(struct macsec_tx_sa *tx_sa, struct macsec_secy *secy)
{
	u32 pn;
@@ -418,12 +435,8 @@ static u32 tx_sa_update_pn(struct macsec_tx_sa *tx_sa, struct macsec_secy *secy)
	pn = tx_sa->next_pn;

	tx_sa->next_pn++;
	if (tx_sa->next_pn == 0) {
		pr_debug("PN wrapped, transitioning to !oper\n");
		tx_sa->active = false;
		if (secy->protect_frames)
			secy->operational = false;
	}
	if (tx_sa->next_pn == 0)
		__macsec_pn_wrapped(secy, tx_sa);
	spin_unlock_bh(&tx_sa->lock);

	return pn;
+2 −0
Original line number Diff line number Diff line
@@ -200,4 +200,6 @@ struct macsec_context {
	u8 is_phy:1;
};

void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa);

#endif /* _NET_MACSEC_H_ */