developer | 7e32f7e | 2022-05-18 21:10:08 +0800 | [diff] [blame^] | 1 | From 182879f89b858fede98136ea3ad45fe9c7178387 Mon Sep 17 00:00:00 2001 |
| 2 | From: Dmitry Bogdanov <dbogdanov@marvell.com> |
| 3 | Date: Wed, 25 Mar 2020 15:52:34 +0300 |
| 4 | Subject: net: macsec: init secy pointer in macsec_context |
| 5 | |
| 6 | This patch adds secy pointer initialization in the macsec_context. |
| 7 | It will be used by MAC drivers in offloading operations. |
| 8 | |
| 9 | Signed-off-by: Dmitry Bogdanov <dbogdanov@marvell.com> |
| 10 | Signed-off-by: Mark Starovoytov <mstarovoitov@marvell.com> |
| 11 | Signed-off-by: Igor Russkikh <irusskikh@marvell.com> |
| 12 | Signed-off-by: David S. Miller <davem@davemloft.net> |
| 13 | --- |
| 14 | drivers/net/macsec.c | 16 +++++++++++++++- |
| 15 | 1 file changed, 15 insertions(+), 1 deletion(-) |
| 16 | |
| 17 | diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c |
| 18 | index d29c072e19af6..093e81d605ec7 100644 |
| 19 | --- a/drivers/net/macsec.c |
| 20 | +++ b/drivers/net/macsec.c |
| 21 | @@ -1794,6 +1794,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info) |
| 22 | |
| 23 | ctx.sa.assoc_num = assoc_num; |
| 24 | ctx.sa.rx_sa = rx_sa; |
| 25 | + ctx.secy = secy; |
| 26 | memcpy(ctx.sa.key, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), |
| 27 | MACSEC_KEYID_LEN); |
| 28 | |
| 29 | @@ -1841,6 +1842,7 @@ static int macsec_add_rxsc(struct sk_buff *skb, struct genl_info *info) |
| 30 | struct nlattr **attrs = info->attrs; |
| 31 | struct macsec_rx_sc *rx_sc; |
| 32 | struct nlattr *tb_rxsc[MACSEC_RXSC_ATTR_MAX + 1]; |
| 33 | + struct macsec_secy *secy; |
| 34 | bool was_active; |
| 35 | int ret; |
| 36 | |
| 37 | @@ -1860,6 +1862,7 @@ static int macsec_add_rxsc(struct sk_buff *skb, struct genl_info *info) |
| 38 | return PTR_ERR(dev); |
| 39 | } |
| 40 | |
| 41 | + secy = &macsec_priv(dev)->secy; |
| 42 | sci = nla_get_sci(tb_rxsc[MACSEC_RXSC_ATTR_SCI]); |
| 43 | |
| 44 | rx_sc = create_rx_sc(dev, sci); |
| 45 | @@ -1883,6 +1886,7 @@ static int macsec_add_rxsc(struct sk_buff *skb, struct genl_info *info) |
| 46 | } |
| 47 | |
| 48 | ctx.rx_sc = rx_sc; |
| 49 | + ctx.secy = secy; |
| 50 | |
| 51 | ret = macsec_offload(ops->mdo_add_rxsc, &ctx); |
| 52 | if (ret) |
| 53 | @@ -2032,6 +2036,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info) |
| 54 | |
| 55 | ctx.sa.assoc_num = assoc_num; |
| 56 | ctx.sa.tx_sa = tx_sa; |
| 57 | + ctx.secy = secy; |
| 58 | memcpy(ctx.sa.key, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), |
| 59 | MACSEC_KEYID_LEN); |
| 60 | |
| 61 | @@ -2107,6 +2112,7 @@ static int macsec_del_rxsa(struct sk_buff *skb, struct genl_info *info) |
| 62 | |
| 63 | ctx.sa.assoc_num = assoc_num; |
| 64 | ctx.sa.rx_sa = rx_sa; |
| 65 | + ctx.secy = secy; |
| 66 | |
| 67 | ret = macsec_offload(ops->mdo_del_rxsa, &ctx); |
| 68 | if (ret) |
| 69 | @@ -2172,6 +2178,7 @@ static int macsec_del_rxsc(struct sk_buff *skb, struct genl_info *info) |
| 70 | } |
| 71 | |
| 72 | ctx.rx_sc = rx_sc; |
| 73 | + ctx.secy = secy; |
| 74 | ret = macsec_offload(ops->mdo_del_rxsc, &ctx); |
| 75 | if (ret) |
| 76 | goto cleanup; |
| 77 | @@ -2230,6 +2237,7 @@ static int macsec_del_txsa(struct sk_buff *skb, struct genl_info *info) |
| 78 | |
| 79 | ctx.sa.assoc_num = assoc_num; |
| 80 | ctx.sa.tx_sa = tx_sa; |
| 81 | + ctx.secy = secy; |
| 82 | |
| 83 | ret = macsec_offload(ops->mdo_del_txsa, &ctx); |
| 84 | if (ret) |
| 85 | @@ -2341,6 +2349,7 @@ static int macsec_upd_txsa(struct sk_buff *skb, struct genl_info *info) |
| 86 | |
| 87 | ctx.sa.assoc_num = assoc_num; |
| 88 | ctx.sa.tx_sa = tx_sa; |
| 89 | + ctx.secy = secy; |
| 90 | |
| 91 | ret = macsec_offload(ops->mdo_upd_txsa, &ctx); |
| 92 | if (ret) |
| 93 | @@ -2433,6 +2442,7 @@ static int macsec_upd_rxsa(struct sk_buff *skb, struct genl_info *info) |
| 94 | |
| 95 | ctx.sa.assoc_num = assoc_num; |
| 96 | ctx.sa.rx_sa = rx_sa; |
| 97 | + ctx.secy = secy; |
| 98 | |
| 99 | ret = macsec_offload(ops->mdo_upd_rxsa, &ctx); |
| 100 | if (ret) |
| 101 | @@ -2503,6 +2513,7 @@ static int macsec_upd_rxsc(struct sk_buff *skb, struct genl_info *info) |
| 102 | } |
| 103 | |
| 104 | ctx.rx_sc = rx_sc; |
| 105 | + ctx.secy = secy; |
| 106 | |
| 107 | ret = macsec_offload(ops->mdo_upd_rxsc, &ctx); |
| 108 | if (ret) |
| 109 | @@ -3370,6 +3381,7 @@ static int macsec_dev_open(struct net_device *dev) |
| 110 | goto clear_allmulti; |
| 111 | } |
| 112 | |
| 113 | + ctx.secy = &macsec->secy; |
| 114 | err = macsec_offload(ops->mdo_dev_open, &ctx); |
| 115 | if (err) |
| 116 | goto clear_allmulti; |
| 117 | @@ -3401,8 +3413,10 @@ static int macsec_dev_stop(struct net_device *dev) |
| 118 | struct macsec_context ctx; |
| 119 | |
| 120 | ops = macsec_get_ops(macsec, &ctx); |
| 121 | - if (ops) |
| 122 | + if (ops) { |
| 123 | + ctx.secy = &macsec->secy; |
| 124 | macsec_offload(ops->mdo_dev_stop, &ctx); |
| 125 | + } |
| 126 | } |
| 127 | |
| 128 | dev_mc_unsync(real_dev, dev); |
| 129 | -- |
| 130 | cgit 1.2.3-1.el7 |
| 131 | |