Commit 5c937de78b39e47ce9924fc4b863c5b727edc328
Committed by
David S. Miller
1 parent
28c5107aa9
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>
Showing 2 changed files with 21 additions and 6 deletions Side-by-side Diff
drivers/net/macsec.c
... | ... | @@ -424,6 +424,23 @@ |
424 | 424 | return (struct macsec_eth_header *)skb_mac_header(skb); |
425 | 425 | } |
426 | 426 | |
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 | + | |
427 | 444 | static u32 tx_sa_update_pn(struct macsec_tx_sa *tx_sa, struct macsec_secy *secy) |
428 | 445 | { |
429 | 446 | u32 pn; |
... | ... | @@ -432,12 +449,8 @@ |
432 | 449 | pn = tx_sa->next_pn; |
433 | 450 | |
434 | 451 | 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); | |
441 | 454 | spin_unlock_bh(&tx_sa->lock); |
442 | 455 | |
443 | 456 | return pn; |