Skip to content

Commit 5c937de

Browse files
atenartdavem330
authored andcommitted
net: macsec: PN wrap callback
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. Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 28c5107 commit 5c937de

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

‎drivers/net/macsec.c‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,23 @@ static struct macsec_eth_header *macsec_ethhdr(struct sk_buff *skb)
424424
return (struct macsec_eth_header *)skb_mac_header(skb);
425425
}
426426

427+
static void __macsec_pn_wrapped(struct macsec_secy *secy,
428+
struct macsec_tx_sa *tx_sa)
429+
{
430+
pr_debug("PN wrapped, transitioning to !oper\n");
431+
tx_sa->active = false;
432+
if (secy->protect_frames)
433+
secy->operational = false;
434+
}
435+
436+
void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa)
437+
{
438+
spin_lock_bh(&tx_sa->lock);
439+
__macsec_pn_wrapped(secy, tx_sa);
440+
spin_unlock_bh(&tx_sa->lock);
441+
}
442+
EXPORT_SYMBOL_GPL(macsec_pn_wrapped);
443+
427444
static u32 tx_sa_update_pn(struct macsec_tx_sa *tx_sa, struct macsec_secy *secy)
428445
{
429446
u32 pn;
@@ -432,12 +449,8 @@ static u32 tx_sa_update_pn(struct macsec_tx_sa *tx_sa, struct macsec_secy *secy)
432449
pn = tx_sa->next_pn;
433450

434451
tx_sa->next_pn++;
435-
if (tx_sa->next_pn == 0) {
436-
pr_debug("PN wrapped, transitioning to !oper\n");
437-
tx_sa->active = false;
438-
if (secy->protect_frames)
439-
secy->operational = false;
440-
}
452+
if (tx_sa->next_pn == 0)
453+
__macsec_pn_wrapped(secy, tx_sa);
441454
spin_unlock_bh(&tx_sa->lock);
442455

443456
return pn;

‎include/net/macsec.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,6 @@ struct macsec_ops {
219219
int (*mdo_del_txsa)(struct macsec_context *ctx);
220220
};
221221

222+
void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa);
223+
222224
#endif /* _NET_MACSEC_H_ */

0 commit comments

Comments
 (0)