Lines Matching refs:secy

64 #define for_each_rxsc(secy, sc)				\  argument
65 for (sc = rcu_dereference_bh(secy->rx_sc); \
68 #define for_each_rxsc_rtnl(secy, sc) \ argument
69 for (sc = rtnl_dereference(secy->rx_sc); \
108 struct macsec_secy secy; member
245 static bool send_sci(const struct macsec_secy *secy) in send_sci() argument
247 const struct macsec_tx_sc *tx_sc = &secy->tx_sc; in send_sci()
250 (secy->n_rx_sc > 1 && !tx_sc->end_station && !tx_sc->scb); in send_sci()
293 const struct macsec_secy *secy, u32 pn, in macsec_fill_sectag() argument
296 const struct macsec_tx_sc *tx_sc = &secy->tx_sc; in macsec_fill_sectag()
303 memcpy(&h->secure_channel_id, &secy->sci, in macsec_fill_sectag()
317 else if (secy->icv_len != DEFAULT_ICV_LEN) in macsec_fill_sectag()
454 static void __macsec_pn_wrapped(struct macsec_secy *secy, in __macsec_pn_wrapped() argument
459 if (secy->protect_frames) in __macsec_pn_wrapped()
460 secy->operational = false; in __macsec_pn_wrapped()
463 void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa) in macsec_pn_wrapped() argument
466 __macsec_pn_wrapped(secy, tx_sa); in macsec_pn_wrapped()
472 struct macsec_secy *secy) in tx_sa_update_pn() argument
479 if (secy->xpn) in tx_sa_update_pn()
485 __macsec_pn_wrapped(secy, tx_sa); in tx_sa_update_pn()
542 macsec_count_tx(skb, &macsec->secy.tx_sc, macsec_skb_cb(skb)->tx_sa); in macsec_encrypt_done()
593 struct macsec_secy *secy; in macsec_encrypt() local
600 secy = &macsec->secy; in macsec_encrypt()
601 tx_sc = &secy->tx_sc; in macsec_encrypt()
606 secy->operational = false; in macsec_encrypt()
635 sci_present = send_sci(secy); in macsec_encrypt()
639 pn = tx_sa_update_pn(tx_sa, secy); in macsec_encrypt()
645 macsec_fill_sectag(hh, secy, pn.lower, sci_present); in macsec_encrypt()
648 skb_put(skb, secy->icv_len); in macsec_encrypt()
676 if (secy->xpn) in macsec_encrypt()
679 macsec_fill_iv(iv, secy->sci, pn.lower); in macsec_encrypt()
692 secy->icv_len; in macsec_encrypt()
697 aead_request_set_ad(req, skb->len - secy->icv_len); in macsec_encrypt()
723 static bool macsec_post_decrypt(struct sk_buff *skb, struct macsec_secy *secy, u32 pn) in macsec_post_decrypt() argument
731 if (rx_sa->next_pn_halves.lower >= secy->replay_window) in macsec_post_decrypt()
732 lowest_pn = rx_sa->next_pn_halves.lower - secy->replay_window; in macsec_post_decrypt()
737 if (secy->replay_protect && pn < lowest_pn && in macsec_post_decrypt()
738 (!secy->xpn || pn_same_half(pn, lowest_pn))) { in macsec_post_decrypt()
746 if (secy->validate_frames != MACSEC_VALIDATE_DISABLED) { in macsec_post_decrypt()
760 secy->validate_frames == MACSEC_VALIDATE_STRICT) { in macsec_post_decrypt()
768 if (secy->validate_frames == MACSEC_VALIDATE_CHECK) { in macsec_post_decrypt()
790 } else if (secy->xpn && in macsec_post_decrypt()
848 if (!macsec_post_decrypt(skb, &macsec->secy, pn)) { in macsec_decrypt_done()
854 macsec_finalize_skb(skb, macsec->secy.icv_len, in macsec_decrypt_done()
856 macsec_reset_skb(skb, macsec->secy.netdev); in macsec_decrypt_done()
874 struct macsec_secy *secy) in macsec_decrypt() argument
883 u16 icv_len = secy->icv_len; in macsec_decrypt()
904 if (secy->xpn) { in macsec_decrypt()
971 static struct macsec_rx_sc *find_rx_sc(struct macsec_secy *secy, sci_t sci) in find_rx_sc() argument
975 for_each_rxsc(secy, rx_sc) { in find_rx_sc()
983 static struct macsec_rx_sc *find_rx_sc_rtnl(struct macsec_secy *secy, sci_t sci) in find_rx_sc_rtnl() argument
987 for_each_rxsc_rtnl(secy, rx_sc) { in find_rx_sc_rtnl()
1009 struct net_device *ndev = macsec->secy.netdev; in handle_not_macsec()
1045 if (macsec->secy.validate_frames == MACSEC_VALIDATE_STRICT) { in handle_not_macsec()
1076 struct macsec_secy *secy = NULL; in macsec_handle_frame() local
1135 struct macsec_rx_sc *sc = find_rx_sc(&macsec->secy, sci); in macsec_handle_frame()
1140 secy = &macsec->secy; in macsec_handle_frame()
1146 if (!secy) in macsec_handle_frame()
1149 dev = secy->netdev; in macsec_handle_frame()
1154 if (!macsec_validate_skb(skb, secy->icv_len, secy->xpn)) { in macsec_handle_frame()
1169 secy->validate_frames == MACSEC_VALIDATE_STRICT) { in macsec_handle_frame()
1187 if (secy->replay_protect) { in macsec_handle_frame()
1191 late = rx_sa->next_pn_halves.lower >= secy->replay_window && in macsec_handle_frame()
1192 hdr_pn < (rx_sa->next_pn_halves.lower - secy->replay_window); in macsec_handle_frame()
1194 if (secy->xpn) in macsec_handle_frame()
1210 secy->validate_frames != MACSEC_VALIDATE_DISABLED) in macsec_handle_frame()
1211 skb = macsec_decrypt(skb, dev, rx_sa, sci, secy); in macsec_handle_frame()
1224 if (!macsec_post_decrypt(skb, secy, hdr_pn)) in macsec_handle_frame()
1228 macsec_finalize_skb(skb, secy->icv_len, in macsec_handle_frame()
1230 macsec_reset_skb(skb, secy->netdev); in macsec_handle_frame()
1242 macsec->secy.netdev->stats.rx_dropped++; in macsec_handle_frame()
1275 macsec->secy.validate_frames == MACSEC_VALIDATE_STRICT) { in macsec_handle_frame()
1289 macsec_reset_skb(nskb, macsec->secy.netdev); in macsec_handle_frame()
1297 macsec->secy.netdev->stats.rx_dropped++; in macsec_handle_frame()
1375 static struct macsec_rx_sc *del_rx_sc(struct macsec_secy *secy, sci_t sci) in del_rx_sc() argument
1379 for (rx_scp = &secy->rx_sc, rx_sc = rtnl_dereference(*rx_scp); in del_rx_sc()
1384 secy->n_rx_sc--; in del_rx_sc()
1399 struct macsec_secy *secy; in create_rx_sc() local
1402 if (find_rx_sc_rtnl(&macsec->secy, sci)) in create_rx_sc()
1420 secy = &macsec_priv(dev)->secy; in create_rx_sc()
1421 rcu_assign_pointer(rx_sc->next, secy->rx_sc); in create_rx_sc()
1422 rcu_assign_pointer(secy->rx_sc, rx_sc); in create_rx_sc()
1425 secy->n_rx_sc++; in create_rx_sc()
1511 struct macsec_secy *secy; in get_txsa_from_nl() local
1527 secy = &macsec_priv(dev)->secy; in get_txsa_from_nl()
1528 tx_sc = &secy->tx_sc; in get_txsa_from_nl()
1536 *secyp = secy; in get_txsa_from_nl()
1547 struct macsec_secy *secy; in get_rxsc_from_nl() local
1555 secy = &macsec_priv(dev)->secy; in get_rxsc_from_nl()
1561 rx_sc = find_rx_sc_rtnl(secy, sci); in get_rxsc_from_nl()
1565 *secyp = secy; in get_rxsc_from_nl()
1716 struct macsec_secy *secy; in macsec_add_rxsa() local
1738 rx_sc = get_rxsc_from_nl(genl_info_net(info), attrs, tb_rxsc, &dev, &secy); in macsec_add_rxsa()
1746 if (nla_len(tb_sa[MACSEC_SA_ATTR_KEY]) != secy->key_len) { in macsec_add_rxsa()
1748 nla_len(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len); in macsec_add_rxsa()
1753 pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN; in macsec_add_rxsa()
1761 if (secy->xpn) { in macsec_add_rxsa()
1789 secy->key_len, secy->icv_len); in macsec_add_rxsa()
1820 ctx.secy = secy; in macsec_add_rxsa()
1822 secy->key_len); in macsec_add_rxsa()
1829 if (secy->xpn) { in macsec_add_rxsa()
1868 struct macsec_secy *secy; in macsec_add_rxsc() local
1888 secy = &macsec_priv(dev)->secy; in macsec_add_rxsc()
1912 ctx.secy = secy; in macsec_add_rxsc()
1958 struct macsec_secy *secy; in macsec_add_txsa() local
1983 secy = &macsec_priv(dev)->secy; in macsec_add_txsa()
1984 tx_sc = &secy->tx_sc; in macsec_add_txsa()
1988 if (nla_len(tb_sa[MACSEC_SA_ATTR_KEY]) != secy->key_len) { in macsec_add_txsa()
1990 nla_len(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len); in macsec_add_txsa()
1995 pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN; in macsec_add_txsa()
2003 if (secy->xpn) { in macsec_add_txsa()
2031 secy->key_len, secy->icv_len); in macsec_add_txsa()
2045 was_operational = secy->operational; in macsec_add_txsa()
2047 secy->operational = true; in macsec_add_txsa()
2062 ctx.secy = secy; in macsec_add_txsa()
2064 secy->key_len); in macsec_add_txsa()
2071 if (secy->xpn) { in macsec_add_txsa()
2085 secy->operational = was_operational; in macsec_add_txsa()
2095 struct macsec_secy *secy; in macsec_del_rxsa() local
2114 &dev, &secy, &rx_sc, &assoc_num); in macsec_del_rxsa()
2138 ctx.secy = secy; in macsec_del_rxsa()
2161 struct macsec_secy *secy; in macsec_del_rxsc() local
2183 secy = &macsec_priv(dev)->secy; in macsec_del_rxsc()
2186 rx_sc = del_rx_sc(secy, sci); in macsec_del_rxsc()
2204 ctx.secy = secy; in macsec_del_rxsc()
2224 struct macsec_secy *secy; in macsec_del_txsa() local
2239 &dev, &secy, &tx_sc, &assoc_num); in macsec_del_txsa()
2263 ctx.secy = secy; in macsec_del_txsa()
2309 struct macsec_secy *secy; in macsec_upd_txsa() local
2331 &dev, &secy, &tx_sc, &assoc_num); in macsec_upd_txsa()
2340 pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN; in macsec_upd_txsa()
2358 was_operational = secy->operational; in macsec_upd_txsa()
2360 secy->operational = tx_sa->active; in macsec_upd_txsa()
2375 ctx.secy = secy; in macsec_upd_txsa()
2393 secy->operational = was_operational; in macsec_upd_txsa()
2402 struct macsec_secy *secy; in macsec_upd_rxsa() local
2428 &dev, &secy, &rx_sc, &assoc_num); in macsec_upd_rxsa()
2437 pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN; in macsec_upd_rxsa()
2468 ctx.secy = secy; in macsec_upd_rxsa()
2493 struct macsec_secy *secy; in macsec_upd_rxsc() local
2510 rx_sc = get_rxsc_from_nl(genl_info_net(info), attrs, tb_rxsc, &dev, &secy); in macsec_upd_rxsc()
2517 prev_n_rx_sc = secy->n_rx_sc; in macsec_upd_rxsc()
2522 secy->n_rx_sc += new ? 1 : -1; in macsec_upd_rxsc()
2539 ctx.secy = secy; in macsec_upd_rxsc()
2551 secy->n_rx_sc = prev_n_rx_sc; in macsec_upd_rxsc()
2559 struct macsec_secy *secy = &macsec->secy; in macsec_is_configured() local
2560 struct macsec_tx_sc *tx_sc = &secy->tx_sc; in macsec_is_configured()
2563 if (secy->n_rx_sc > 0) in macsec_is_configured()
2642 ctx.secy = &macsec->secy; in macsec_upd_offload()
2679 ctx.secy = &macsec_priv(dev)->secy; in get_tx_sa_stats()
2723 ctx.secy = &macsec_priv(dev)->secy; in get_rx_sa_stats()
2774 ctx.secy = &macsec_priv(dev)->secy; in get_rx_sc_stats()
2856 ctx.secy = &macsec_priv(dev)->secy; in get_tx_sc_stats()
2867 stats = per_cpu_ptr(macsec_priv(dev)->secy.tx_sc.stats, cpu); in get_tx_sc_stats()
2912 ctx.secy = &macsec_priv(dev)->secy; in get_secy_stats()
2971 static int nla_put_secy(struct macsec_secy *secy, struct sk_buff *skb) in nla_put_secy() argument
2973 struct macsec_tx_sc *tx_sc = &secy->tx_sc; in nla_put_secy()
2981 switch (secy->key_len) { in nla_put_secy()
2983 csid = secy->xpn ? MACSEC_CIPHER_ID_GCM_AES_XPN_128 : MACSEC_DEFAULT_CIPHER_ID; in nla_put_secy()
2986 csid = secy->xpn ? MACSEC_CIPHER_ID_GCM_AES_XPN_256 : MACSEC_CIPHER_ID_GCM_AES_256; in nla_put_secy()
2992 if (nla_put_sci(skb, MACSEC_SECY_ATTR_SCI, secy->sci, in nla_put_secy()
2996 nla_put_u8(skb, MACSEC_SECY_ATTR_ICV_LEN, secy->icv_len) || in nla_put_secy()
2997 nla_put_u8(skb, MACSEC_SECY_ATTR_OPER, secy->operational) || in nla_put_secy()
2998 nla_put_u8(skb, MACSEC_SECY_ATTR_PROTECT, secy->protect_frames) || in nla_put_secy()
2999 nla_put_u8(skb, MACSEC_SECY_ATTR_REPLAY, secy->replay_protect) || in nla_put_secy()
3000 nla_put_u8(skb, MACSEC_SECY_ATTR_VALIDATE, secy->validate_frames) || in nla_put_secy()
3008 if (secy->replay_protect) { in nla_put_secy()
3009 if (nla_put_u32(skb, MACSEC_SECY_ATTR_WINDOW, secy->replay_window)) in nla_put_secy()
3022 dump_secy(struct macsec_secy *secy, struct net_device *dev, in dump_secy() argument
3031 struct macsec_tx_sc *tx_sc = &secy->tx_sc; in dump_secy()
3055 if (nla_put_secy(secy, skb)) in dump_secy()
3113 if (secy->xpn) { in dump_secy()
3124 (secy->xpn && nla_put_ssci(skb, MACSEC_SA_ATTR_SSCI, tx_sa->ssci)) || in dump_secy()
3140 for_each_rxsc_rtnl(secy, rx_sc) { in dump_secy()
3218 if (secy->xpn) { in dump_secy()
3229 (secy->xpn && nla_put_ssci(skb, MACSEC_SA_ATTR_SSCI, rx_sa->ssci)) || in dump_secy()
3270 struct macsec_secy *secy; in macsec_dump_txsc() local
3278 secy = &macsec_priv(dev)->secy; in macsec_dump_txsc()
3279 if (dump_secy(secy, dev, skb, cb) < 0) in macsec_dump_txsc()
3375 struct macsec_secy *secy = &macsec->secy; in macsec_start_xmit() local
3385 if (!secy->protect_frames) { in macsec_start_xmit()
3397 if (!secy->operational) { in macsec_start_xmit()
3410 macsec_count_tx(skb, &macsec->secy.tx_sc, macsec_skb_cb(skb)->tx_sa); in macsec_start_xmit()
3522 ctx.secy = &macsec->secy; in macsec_dev_open()
3555 ctx.secy = &macsec->secy; in macsec_dev_stop()
3618 macsec->secy.sci = dev_to_sci(dev, MACSEC_PORT_ES); in macsec_set_mac_address()
3627 ctx.secy = &macsec->secy; in macsec_set_mac_address()
3638 unsigned int extra = macsec->secy.icv_len + macsec_extra_len(true); in macsec_change_mtu()
3705 free_percpu(macsec->secy.tx_sc.stats); in macsec_free_netdev()
3726 struct macsec_secy *secy; in macsec_changelink_common() local
3729 secy = &macsec_priv(dev)->secy; in macsec_changelink_common()
3730 tx_sc = &secy->tx_sc; in macsec_changelink_common()
3738 secy->operational = tx_sa && tx_sa->active; in macsec_changelink_common()
3742 secy->replay_window = nla_get_u32(data[IFLA_MACSEC_WINDOW]); in macsec_changelink_common()
3748 secy->protect_frames = !!nla_get_u8(data[IFLA_MACSEC_PROTECT]); in macsec_changelink_common()
3760 secy->replay_protect = !!nla_get_u8(data[IFLA_MACSEC_REPLAY_PROTECT]); in macsec_changelink_common()
3763 secy->validate_frames = nla_get_u8(data[IFLA_MACSEC_VALIDATION]); in macsec_changelink_common()
3769 secy->key_len = MACSEC_GCM_AES_128_SAK_LEN; in macsec_changelink_common()
3770 secy->xpn = false; in macsec_changelink_common()
3773 secy->key_len = MACSEC_GCM_AES_256_SAK_LEN; in macsec_changelink_common()
3774 secy->xpn = false; in macsec_changelink_common()
3777 secy->key_len = MACSEC_GCM_AES_128_SAK_LEN; in macsec_changelink_common()
3778 secy->xpn = true; in macsec_changelink_common()
3781 secy->key_len = MACSEC_GCM_AES_256_SAK_LEN; in macsec_changelink_common()
3782 secy->xpn = true; in macsec_changelink_common()
3798 struct macsec_secy secy; in macsec_changelink() local
3813 memcpy(&secy, &macsec->secy, sizeof(secy)); in macsec_changelink()
3814 memcpy(&tx_sc, &macsec->secy.tx_sc, sizeof(tx_sc)); in macsec_changelink()
3832 ctx.secy = &macsec->secy; in macsec_changelink()
3841 memcpy(&macsec->secy.tx_sc, &tx_sc, sizeof(tx_sc)); in macsec_changelink()
3842 memcpy(&macsec->secy, &secy, sizeof(secy)); in macsec_changelink()
3851 while (macsec->secy.rx_sc) { in macsec_del_dev()
3852 struct macsec_rx_sc *rx_sc = rtnl_dereference(macsec->secy.rx_sc); in macsec_del_dev()
3854 rcu_assign_pointer(macsec->secy.rx_sc, rx_sc->next); in macsec_del_dev()
3859 struct macsec_tx_sa *sa = rtnl_dereference(macsec->secy.tx_sc.sa[i]); in macsec_del_dev()
3862 RCU_INIT_POINTER(macsec->secy.tx_sc.sa[i], NULL); in macsec_del_dev()
3894 ctx.secy = &macsec->secy; in macsec_dellink()
3940 if (macsec->secy.sci == sci) in sci_exists()
3950 struct macsec_secy *secy = &macsec->secy; in macsec_add_dev() local
3956 secy->tx_sc.stats = netdev_alloc_pcpu_stats(struct pcpu_tx_sc_stats); in macsec_add_dev()
3957 if (!secy->tx_sc.stats) { in macsec_add_dev()
3965 secy->netdev = dev; in macsec_add_dev()
3966 secy->operational = true; in macsec_add_dev()
3967 secy->key_len = DEFAULT_SAK_LEN; in macsec_add_dev()
3968 secy->icv_len = icv_len; in macsec_add_dev()
3969 secy->validate_frames = MACSEC_VALIDATE_DEFAULT; in macsec_add_dev()
3970 secy->protect_frames = true; in macsec_add_dev()
3971 secy->replay_protect = false; in macsec_add_dev()
3972 secy->xpn = DEFAULT_XPN; in macsec_add_dev()
3974 secy->sci = sci; in macsec_add_dev()
3975 secy->tx_sc.active = true; in macsec_add_dev()
3976 secy->tx_sc.encoding_sa = DEFAULT_ENCODING_SA; in macsec_add_dev()
3977 secy->tx_sc.encrypt = DEFAULT_ENCRYPT; in macsec_add_dev()
3978 secy->tx_sc.send_sci = DEFAULT_SEND_SCI; in macsec_add_dev()
3979 secy->tx_sc.end_station = false; in macsec_add_dev()
3980 secy->tx_sc.scb = false; in macsec_add_dev()
4077 ctx.secy = &macsec->secy; in macsec_newlink()
4205 struct macsec_secy *secy = &macsec_priv(dev)->secy; in macsec_fill_info() local
4206 struct macsec_tx_sc *tx_sc = &secy->tx_sc; in macsec_fill_info()
4209 switch (secy->key_len) { in macsec_fill_info()
4211 csid = secy->xpn ? MACSEC_CIPHER_ID_GCM_AES_XPN_128 : MACSEC_DEFAULT_CIPHER_ID; in macsec_fill_info()
4214 csid = secy->xpn ? MACSEC_CIPHER_ID_GCM_AES_XPN_256 : MACSEC_CIPHER_ID_GCM_AES_256; in macsec_fill_info()
4220 if (nla_put_sci(skb, IFLA_MACSEC_SCI, secy->sci, in macsec_fill_info()
4222 nla_put_u8(skb, IFLA_MACSEC_ICV_LEN, secy->icv_len) || in macsec_fill_info()
4227 nla_put_u8(skb, IFLA_MACSEC_PROTECT, secy->protect_frames) || in macsec_fill_info()
4231 nla_put_u8(skb, IFLA_MACSEC_REPLAY_PROTECT, secy->replay_protect) || in macsec_fill_info()
4232 nla_put_u8(skb, IFLA_MACSEC_VALIDATION, secy->validate_frames) || in macsec_fill_info()
4236 if (secy->replay_protect) { in macsec_fill_info()
4237 if (nla_put_u32(skb, IFLA_MACSEC_WINDOW, secy->replay_window)) in macsec_fill_info()
4285 struct net_device *dev = m->secy.netdev; in macsec_notify()
4297 macsec_common_dellink(m->secy.netdev, &head); in macsec_notify()
4312 struct net_device *dev = m->secy.netdev; in macsec_notify()
4313 unsigned int mtu = real_dev->mtu - (m->secy.icv_len + in macsec_notify()