developer | 655d8f0 | 2024-01-11 13:37:13 +0800 | [diff] [blame] | 1 | From 5c937de78b39e47ce9924fc4b863c5b727edc328 Mon Sep 17 00:00:00 2001 |
| 2 | From: Antoine Tenart <antoine.tenart@bootlin.com> |
| 3 | Date: Mon, 13 Jan 2020 23:31:47 +0100 |
| 4 | Subject: net: macsec: PN wrap callback |
| 5 | |
| 6 | Allow to call macsec_pn_wrapped from hardware drivers to notify when a |
| 7 | PN rolls over. Some drivers might used an interrupt to implement this. |
| 8 | |
| 9 | Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com> |
| 10 | Signed-off-by: David S. Miller <davem@davemloft.net> |
| 11 | --- |
| 12 | drivers/net/macsec.c | 25 +++++++++++++++++++------ |
| 13 | include/net/macsec.h | 2 ++ |
| 14 | 2 files changed, 21 insertions(+), 6 deletions(-) |
| 15 | |
| 16 | diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c |
| 17 | index e515919e8687f..45bfd99f17fa9 100644 |
| 18 | --- a/drivers/net/macsec.c |
| 19 | +++ b/drivers/net/macsec.c |
| 20 | @@ -424,6 +424,23 @@ static struct macsec_eth_header *macsec_ethhdr(struct sk_buff *skb) |
| 21 | return (struct macsec_eth_header *)skb_mac_header(skb); |
| 22 | } |
| 23 | |
| 24 | +static void __macsec_pn_wrapped(struct macsec_secy *secy, |
| 25 | + struct macsec_tx_sa *tx_sa) |
| 26 | +{ |
| 27 | + pr_debug("PN wrapped, transitioning to !oper\n"); |
| 28 | + tx_sa->active = false; |
| 29 | + if (secy->protect_frames) |
| 30 | + secy->operational = false; |
| 31 | +} |
| 32 | + |
| 33 | +void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa) |
| 34 | +{ |
| 35 | + spin_lock_bh(&tx_sa->lock); |
| 36 | + __macsec_pn_wrapped(secy, tx_sa); |
| 37 | + spin_unlock_bh(&tx_sa->lock); |
| 38 | +} |
| 39 | +EXPORT_SYMBOL_GPL(macsec_pn_wrapped); |
| 40 | + |
| 41 | static u32 tx_sa_update_pn(struct macsec_tx_sa *tx_sa, struct macsec_secy *secy) |
| 42 | { |
| 43 | u32 pn; |
| 44 | @@ -432,12 +449,8 @@ static u32 tx_sa_update_pn(struct macsec_tx_sa *tx_sa, struct macsec_secy *secy) |
| 45 | pn = tx_sa->next_pn; |
| 46 | |
| 47 | tx_sa->next_pn++; |
| 48 | - if (tx_sa->next_pn == 0) { |
| 49 | - pr_debug("PN wrapped, transitioning to !oper\n"); |
| 50 | - tx_sa->active = false; |
| 51 | - if (secy->protect_frames) |
| 52 | - secy->operational = false; |
| 53 | - } |
| 54 | + if (tx_sa->next_pn == 0) |
| 55 | + __macsec_pn_wrapped(secy, tx_sa); |
| 56 | spin_unlock_bh(&tx_sa->lock); |
| 57 | |
| 58 | return pn; |
| 59 | diff --git a/include/net/macsec.h b/include/net/macsec.h |
| 60 | index 16e7e5061178e..92e43db8b5667 100644 |
| 61 | --- a/include/net/macsec.h |
| 62 | +++ b/include/net/macsec.h |
| 63 | @@ -219,4 +219,6 @@ struct macsec_ops { |
| 64 | int (*mdo_del_txsa)(struct macsec_context *ctx); |
| 65 | }; |
| 66 | |
| 67 | +void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa); |
| 68 | + |
| 69 | #endif /* _NET_MACSEC_H_ */ |
| 70 | -- |
| 71 | cgit 1.2.3-1.el7 |
| 72 | |