Lines Matching refs:rx_sa
145 struct macsec_rx_sa *rx_sa; member
723 struct macsec_rx_sa *rx_sa = macsec_skb_cb(skb)->rx_sa; in macsec_post_decrypt() local
724 struct pcpu_rx_sc_stats *rxsc_stats = this_cpu_ptr(rx_sa->sc->stats); in macsec_post_decrypt()
728 spin_lock(&rx_sa->lock); in macsec_post_decrypt()
729 if (rx_sa->next_pn_halves.lower >= secy->replay_window) in macsec_post_decrypt()
730 lowest_pn = rx_sa->next_pn_halves.lower - secy->replay_window; in macsec_post_decrypt()
737 spin_unlock(&rx_sa->lock); in macsec_post_decrypt()
754 spin_unlock(&rx_sa->lock); in macsec_post_decrypt()
768 this_cpu_inc(rx_sa->stats->InPktsInvalid); in macsec_post_decrypt()
781 this_cpu_inc(rx_sa->stats->InPktsOK); in macsec_post_decrypt()
786 if (pn + 1 > rx_sa->next_pn_halves.lower) { in macsec_post_decrypt()
787 rx_sa->next_pn_halves.lower = pn + 1; in macsec_post_decrypt()
789 !pn_same_half(pn, rx_sa->next_pn_halves.lower)) { in macsec_post_decrypt()
790 rx_sa->next_pn_halves.upper++; in macsec_post_decrypt()
791 rx_sa->next_pn_halves.lower = pn + 1; in macsec_post_decrypt()
794 spin_unlock(&rx_sa->lock); in macsec_post_decrypt()
834 struct macsec_rx_sa *rx_sa = macsec_skb_cb(skb)->rx_sa; in macsec_decrypt_done() local
835 struct macsec_rx_sc *rx_sc = rx_sa->sc; in macsec_decrypt_done()
863 macsec_rxsa_put(rx_sa); in macsec_decrypt_done()
870 struct macsec_rx_sa *rx_sa, in macsec_decrypt() argument
893 req = macsec_alloc_req(rx_sa->key.tfm, &iv, &sg, ret); in macsec_decrypt()
903 pn_t recovered_pn = rx_sa->next_pn_halves; in macsec_decrypt()
906 if (hdr_pn < rx_sa->next_pn_halves.lower && in macsec_decrypt()
907 !pn_same_half(hdr_pn, rx_sa->next_pn_halves.lower)) in macsec_decrypt()
910 macsec_fill_iv_xpn(iv, rx_sa->ssci, recovered_pn.full64, in macsec_decrypt()
911 rx_sa->key.salt); in macsec_decrypt()
1076 struct macsec_rx_sa *rx_sa; in macsec_handle_frame() local
1159 rx_sa = macsec_rxsa_get(rx_sc->sa[macsec_skb_cb(skb)->assoc_num]); in macsec_handle_frame()
1160 if (!rx_sa) { in macsec_handle_frame()
1188 spin_lock(&rx_sa->lock); in macsec_handle_frame()
1189 late = rx_sa->next_pn_halves.lower >= secy->replay_window && in macsec_handle_frame()
1190 hdr_pn < (rx_sa->next_pn_halves.lower - secy->replay_window); in macsec_handle_frame()
1193 late = late && pn_same_half(rx_sa->next_pn_halves.lower, hdr_pn); in macsec_handle_frame()
1194 spin_unlock(&rx_sa->lock); in macsec_handle_frame()
1204 macsec_skb_cb(skb)->rx_sa = rx_sa; in macsec_handle_frame()
1209 skb = macsec_decrypt(skb, dev, rx_sa, sci, secy); in macsec_handle_frame()
1214 macsec_rxsa_put(rx_sa); in macsec_handle_frame()
1230 if (rx_sa) in macsec_handle_frame()
1231 macsec_rxsa_put(rx_sa); in macsec_handle_frame()
1248 macsec_rxsa_put(rx_sa); in macsec_handle_frame()
1329 static int init_rx_sa(struct macsec_rx_sa *rx_sa, char *sak, int key_len, in init_rx_sa() argument
1332 rx_sa->stats = alloc_percpu(struct macsec_rx_sa_stats); in init_rx_sa()
1333 if (!rx_sa->stats) in init_rx_sa()
1336 rx_sa->key.tfm = macsec_alloc_tfm(sak, key_len, icv_len); in init_rx_sa()
1337 if (IS_ERR(rx_sa->key.tfm)) { in init_rx_sa()
1338 free_percpu(rx_sa->stats); in init_rx_sa()
1339 return PTR_ERR(rx_sa->key.tfm); in init_rx_sa()
1342 rx_sa->ssci = MACSEC_UNDEF_SSCI; in init_rx_sa()
1343 rx_sa->active = false; in init_rx_sa()
1344 rx_sa->next_pn = 1; in init_rx_sa()
1345 refcount_set(&rx_sa->refcnt, 1); in init_rx_sa()
1346 spin_lock_init(&rx_sa->lock); in init_rx_sa()
1351 static void clear_rx_sa(struct macsec_rx_sa *rx_sa) in clear_rx_sa() argument
1353 rx_sa->active = false; in clear_rx_sa()
1355 macsec_rxsa_put(rx_sa); in clear_rx_sa()
1579 struct macsec_rx_sa *rx_sa; in get_rxsa_from_nl() local
1592 rx_sa = rtnl_dereference(rx_sc->sa[*assoc_num]); in get_rxsa_from_nl()
1593 if (!rx_sa) in get_rxsa_from_nl()
1597 return rx_sa; in get_rxsa_from_nl()
1716 struct macsec_rx_sa *rx_sa; in macsec_add_rxsa() local
1775 rx_sa = rtnl_dereference(rx_sc->sa[assoc_num]); in macsec_add_rxsa()
1776 if (rx_sa) { in macsec_add_rxsa()
1781 rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL); in macsec_add_rxsa()
1782 if (!rx_sa) { in macsec_add_rxsa()
1787 err = init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), in macsec_add_rxsa()
1790 kfree(rx_sa); in macsec_add_rxsa()
1796 spin_lock_bh(&rx_sa->lock); in macsec_add_rxsa()
1797 rx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]); in macsec_add_rxsa()
1798 spin_unlock_bh(&rx_sa->lock); in macsec_add_rxsa()
1802 rx_sa->active = !!nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]); in macsec_add_rxsa()
1804 rx_sa->sc = rx_sc; in macsec_add_rxsa()
1818 ctx.sa.rx_sa = rx_sa; in macsec_add_rxsa()
1829 rx_sa->ssci = nla_get_ssci(tb_sa[MACSEC_SA_ATTR_SSCI]); in macsec_add_rxsa()
1830 nla_memcpy(rx_sa->key.salt.bytes, tb_sa[MACSEC_SA_ATTR_SALT], in macsec_add_rxsa()
1834 nla_memcpy(rx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEYID], MACSEC_KEYID_LEN); in macsec_add_rxsa()
1835 rcu_assign_pointer(rx_sc->sa[assoc_num], rx_sa); in macsec_add_rxsa()
1842 macsec_rxsa_put(rx_sa); in macsec_add_rxsa()
2096 struct macsec_rx_sa *rx_sa; in macsec_del_rxsa() local
2112 rx_sa = get_rxsa_from_nl(genl_info_net(info), attrs, tb_rxsc, tb_sa, in macsec_del_rxsa()
2114 if (IS_ERR(rx_sa)) { in macsec_del_rxsa()
2116 return PTR_ERR(rx_sa); in macsec_del_rxsa()
2119 if (rx_sa->active) { in macsec_del_rxsa()
2136 ctx.sa.rx_sa = rx_sa; in macsec_del_rxsa()
2145 clear_rx_sa(rx_sa); in macsec_del_rxsa()
2403 struct macsec_rx_sa *rx_sa; in macsec_upd_rxsa() local
2426 rx_sa = get_rxsa_from_nl(genl_info_net(info), attrs, tb_rxsc, tb_sa, in macsec_upd_rxsa()
2428 if (IS_ERR(rx_sa)) { in macsec_upd_rxsa()
2430 return PTR_ERR(rx_sa); in macsec_upd_rxsa()
2444 spin_lock_bh(&rx_sa->lock); in macsec_upd_rxsa()
2445 prev_pn = rx_sa->next_pn_halves; in macsec_upd_rxsa()
2446 rx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]); in macsec_upd_rxsa()
2447 spin_unlock_bh(&rx_sa->lock); in macsec_upd_rxsa()
2450 was_active = rx_sa->active; in macsec_upd_rxsa()
2452 rx_sa->active = nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]); in macsec_upd_rxsa()
2466 ctx.sa.rx_sa = rx_sa; in macsec_upd_rxsa()
2479 spin_lock_bh(&rx_sa->lock); in macsec_upd_rxsa()
2480 rx_sa->next_pn_halves = prev_pn; in macsec_upd_rxsa()
2481 spin_unlock_bh(&rx_sa->lock); in macsec_upd_rxsa()
2483 rx_sa->active = was_active; in macsec_upd_rxsa()
2706 struct macsec_rx_sa *rx_sa, in get_rx_sa_stats() argument
2720 ctx.sa.rx_sa = rx_sa; in get_rx_sa_stats()
2731 per_cpu_ptr(rx_sa->stats, cpu); in get_rx_sa_stats()
3182 struct macsec_rx_sa *rx_sa = rtnl_dereference(rx_sc->sa[i]); in dump_secy() local
3187 if (!rx_sa) in dump_secy()
3207 get_rx_sa_stats(dev, rx_sc, i, rx_sa, &rx_sa_stats); in dump_secy()
3218 pn = rx_sa->next_pn; in dump_secy()
3221 pn = rx_sa->next_pn_halves.lower; in dump_secy()
3227 nla_put(skb, MACSEC_SA_ATTR_KEYID, MACSEC_KEYID_LEN, rx_sa->key.id) || in dump_secy()
3228 (secy->xpn && nla_put_ssci(skb, MACSEC_SA_ATTR_SSCI, rx_sa->ssci)) || in dump_secy()
3229 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, rx_sa->active)) { in dump_secy()