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); \
107 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()
1400 struct macsec_secy *secy; in create_rx_sc() local
1403 if (find_rx_sc_rtnl(&macsec->secy, sci)) in create_rx_sc()
1421 secy = &macsec_priv(dev)->secy; in create_rx_sc()
1422 rcu_assign_pointer(rx_sc->next, secy->rx_sc); in create_rx_sc()
1423 rcu_assign_pointer(secy->rx_sc, rx_sc); in create_rx_sc()
1426 secy->n_rx_sc++; in create_rx_sc()
1512 struct macsec_secy *secy; in get_txsa_from_nl() local
1528 secy = &macsec_priv(dev)->secy; in get_txsa_from_nl()
1529 tx_sc = &secy->tx_sc; in get_txsa_from_nl()
1537 *secyp = secy; in get_txsa_from_nl()
1548 struct macsec_secy *secy; in get_rxsc_from_nl() local
1556 secy = &macsec_priv(dev)->secy; in get_rxsc_from_nl()
1562 rx_sc = find_rx_sc_rtnl(secy, sci); in get_rxsc_from_nl()
1566 *secyp = secy; in get_rxsc_from_nl()
1717 struct macsec_secy *secy; in macsec_add_rxsa() local
1739 rx_sc = get_rxsc_from_nl(genl_info_net(info), attrs, tb_rxsc, &dev, &secy); in macsec_add_rxsa()
1747 if (nla_len(tb_sa[MACSEC_SA_ATTR_KEY]) != secy->key_len) { in macsec_add_rxsa()
1749 nla_len(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len); in macsec_add_rxsa()
1754 pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN; in macsec_add_rxsa()
1763 if (secy->xpn) { in macsec_add_rxsa()
1791 secy->key_len, secy->icv_len); in macsec_add_rxsa()
1822 ctx.secy = secy; in macsec_add_rxsa()
1824 secy->key_len); in macsec_add_rxsa()
1827 memzero_explicit(ctx.sa.key, secy->key_len); in macsec_add_rxsa()
1832 if (secy->xpn) { in macsec_add_rxsa()
1871 struct macsec_secy *secy; in macsec_add_rxsc() local
1891 secy = &macsec_priv(dev)->secy; in macsec_add_rxsc()
1914 ctx.secy = secy; in macsec_add_rxsc()
1926 del_rx_sc(secy, sci); in macsec_add_rxsc()
1961 struct macsec_secy *secy; in macsec_add_txsa() local
1986 secy = &macsec_priv(dev)->secy; in macsec_add_txsa()
1987 tx_sc = &secy->tx_sc; in macsec_add_txsa()
1991 if (nla_len(tb_sa[MACSEC_SA_ATTR_KEY]) != secy->key_len) { in macsec_add_txsa()
1993 nla_len(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len); in macsec_add_txsa()
1998 pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN; in macsec_add_txsa()
2006 if (secy->xpn) { in macsec_add_txsa()
2034 secy->key_len, secy->icv_len); in macsec_add_txsa()
2048 was_operational = secy->operational; in macsec_add_txsa()
2050 secy->operational = true; in macsec_add_txsa()
2065 ctx.secy = secy; in macsec_add_txsa()
2067 secy->key_len); in macsec_add_txsa()
2070 memzero_explicit(ctx.sa.key, secy->key_len); in macsec_add_txsa()
2075 if (secy->xpn) { in macsec_add_txsa()
2089 secy->operational = was_operational; in macsec_add_txsa()
2099 struct macsec_secy *secy; in macsec_del_rxsa() local
2118 &dev, &secy, &rx_sc, &assoc_num); in macsec_del_rxsa()
2142 ctx.secy = secy; in macsec_del_rxsa()
2165 struct macsec_secy *secy; in macsec_del_rxsc() local
2187 secy = &macsec_priv(dev)->secy; in macsec_del_rxsc()
2190 rx_sc = del_rx_sc(secy, sci); in macsec_del_rxsc()
2208 ctx.secy = secy; in macsec_del_rxsc()
2228 struct macsec_secy *secy; in macsec_del_txsa() local
2243 &dev, &secy, &tx_sc, &assoc_num); in macsec_del_txsa()
2267 ctx.secy = secy; in macsec_del_txsa()
2313 struct macsec_secy *secy; in macsec_upd_txsa() local
2335 &dev, &secy, &tx_sc, &assoc_num); in macsec_upd_txsa()
2344 pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN; in macsec_upd_txsa()
2362 was_operational = secy->operational; in macsec_upd_txsa()
2364 secy->operational = tx_sa->active; in macsec_upd_txsa()
2379 ctx.secy = secy; in macsec_upd_txsa()
2397 secy->operational = was_operational; in macsec_upd_txsa()
2406 struct macsec_secy *secy; in macsec_upd_rxsa() local
2432 &dev, &secy, &rx_sc, &assoc_num); in macsec_upd_rxsa()
2441 pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN; in macsec_upd_rxsa()
2472 ctx.secy = secy; in macsec_upd_rxsa()
2497 struct macsec_secy *secy; in macsec_upd_rxsc() local
2514 rx_sc = get_rxsc_from_nl(genl_info_net(info), attrs, tb_rxsc, &dev, &secy); in macsec_upd_rxsc()
2521 prev_n_rx_sc = secy->n_rx_sc; in macsec_upd_rxsc()
2526 secy->n_rx_sc += new ? 1 : -1; in macsec_upd_rxsc()
2543 ctx.secy = secy; in macsec_upd_rxsc()
2555 secy->n_rx_sc = prev_n_rx_sc; in macsec_upd_rxsc()
2563 struct macsec_secy *secy = &macsec->secy; in macsec_is_configured() local
2564 struct macsec_tx_sc *tx_sc = &secy->tx_sc; in macsec_is_configured()
2567 if (secy->rx_sc) in macsec_is_configured()
2646 ctx.secy = &macsec->secy; in macsec_upd_offload()
2678 ctx.secy = &macsec_priv(dev)->secy; in get_tx_sa_stats()
2722 ctx.secy = &macsec_priv(dev)->secy; in get_rx_sa_stats()
2773 ctx.secy = &macsec_priv(dev)->secy; in get_rx_sc_stats()
2855 ctx.secy = &macsec_priv(dev)->secy; in get_tx_sc_stats()
2866 stats = per_cpu_ptr(macsec_priv(dev)->secy.tx_sc.stats, cpu); in get_tx_sc_stats()
2911 ctx.secy = &macsec_priv(dev)->secy; in get_secy_stats()
2970 static int nla_put_secy(struct macsec_secy *secy, struct sk_buff *skb) in nla_put_secy() argument
2972 struct macsec_tx_sc *tx_sc = &secy->tx_sc; in nla_put_secy()
2980 switch (secy->key_len) { in nla_put_secy()
2982 csid = secy->xpn ? MACSEC_CIPHER_ID_GCM_AES_XPN_128 : MACSEC_DEFAULT_CIPHER_ID; in nla_put_secy()
2985 csid = secy->xpn ? MACSEC_CIPHER_ID_GCM_AES_XPN_256 : MACSEC_CIPHER_ID_GCM_AES_256; in nla_put_secy()
2991 if (nla_put_sci(skb, MACSEC_SECY_ATTR_SCI, secy->sci, in nla_put_secy()
2995 nla_put_u8(skb, MACSEC_SECY_ATTR_ICV_LEN, secy->icv_len) || in nla_put_secy()
2996 nla_put_u8(skb, MACSEC_SECY_ATTR_OPER, secy->operational) || in nla_put_secy()
2997 nla_put_u8(skb, MACSEC_SECY_ATTR_PROTECT, secy->protect_frames) || in nla_put_secy()
2998 nla_put_u8(skb, MACSEC_SECY_ATTR_REPLAY, secy->replay_protect) || in nla_put_secy()
2999 nla_put_u8(skb, MACSEC_SECY_ATTR_VALIDATE, secy->validate_frames) || in nla_put_secy()
3007 if (secy->replay_protect) { in nla_put_secy()
3008 if (nla_put_u32(skb, MACSEC_SECY_ATTR_WINDOW, secy->replay_window)) in nla_put_secy()
3021 dump_secy(struct macsec_secy *secy, struct net_device *dev, in dump_secy() argument
3030 struct macsec_tx_sc *tx_sc = &secy->tx_sc; in dump_secy()
3054 if (nla_put_secy(secy, skb)) in dump_secy()
3112 if (secy->xpn) { in dump_secy()
3123 (secy->xpn && nla_put_ssci(skb, MACSEC_SA_ATTR_SSCI, tx_sa->ssci)) || in dump_secy()
3139 for_each_rxsc_rtnl(secy, rx_sc) { in dump_secy()
3217 if (secy->xpn) { in dump_secy()
3228 (secy->xpn && nla_put_ssci(skb, MACSEC_SA_ATTR_SSCI, rx_sa->ssci)) || in dump_secy()
3269 struct macsec_secy *secy; in macsec_dump_txsc() local
3277 secy = &macsec_priv(dev)->secy; in macsec_dump_txsc()
3278 if (dump_secy(secy, dev, skb, cb) < 0) in macsec_dump_txsc()
3374 struct macsec_secy *secy = &macsec->secy; in macsec_start_xmit() local
3384 if (!secy->protect_frames) { in macsec_start_xmit()
3396 if (!secy->operational) { in macsec_start_xmit()
3409 macsec_count_tx(skb, &macsec->secy.tx_sc, macsec_skb_cb(skb)->tx_sa); in macsec_start_xmit()
3507 ctx.secy = &macsec->secy; in macsec_dev_open()
3540 ctx.secy = &macsec->secy; in macsec_dev_stop()
3603 macsec->secy.sci = dev_to_sci(dev, MACSEC_PORT_ES); in macsec_set_mac_address()
3612 ctx.secy = &macsec->secy; in macsec_set_mac_address()
3623 unsigned int extra = macsec->secy.icv_len + macsec_extra_len(true); in macsec_change_mtu()
3691 free_percpu(macsec->secy.tx_sc.stats); in macsec_free_netdev()
3712 struct macsec_secy *secy; in macsec_changelink_common() local
3715 secy = &macsec_priv(dev)->secy; in macsec_changelink_common()
3716 tx_sc = &secy->tx_sc; in macsec_changelink_common()
3724 secy->operational = tx_sa && tx_sa->active; in macsec_changelink_common()
3731 secy->protect_frames = !!nla_get_u8(data[IFLA_MACSEC_PROTECT]); in macsec_changelink_common()
3743 secy->replay_protect = !!nla_get_u8(data[IFLA_MACSEC_REPLAY_PROTECT]); in macsec_changelink_common()
3746 secy->validate_frames = nla_get_u8(data[IFLA_MACSEC_VALIDATION]); in macsec_changelink_common()
3752 secy->key_len = MACSEC_GCM_AES_128_SAK_LEN; in macsec_changelink_common()
3753 secy->xpn = false; in macsec_changelink_common()
3756 secy->key_len = MACSEC_GCM_AES_256_SAK_LEN; in macsec_changelink_common()
3757 secy->xpn = false; in macsec_changelink_common()
3760 secy->key_len = MACSEC_GCM_AES_128_SAK_LEN; in macsec_changelink_common()
3761 secy->xpn = true; in macsec_changelink_common()
3764 secy->key_len = MACSEC_GCM_AES_256_SAK_LEN; in macsec_changelink_common()
3765 secy->xpn = true; in macsec_changelink_common()
3773 secy->replay_window = nla_get_u32(data[IFLA_MACSEC_WINDOW]); in macsec_changelink_common()
3777 if (secy->xpn && in macsec_changelink_common()
3778 secy->replay_window > MACSEC_XPN_MAX_REPLAY_WINDOW) in macsec_changelink_common()
3791 struct macsec_secy secy; in macsec_changelink() local
3806 memcpy(&secy, &macsec->secy, sizeof(secy)); in macsec_changelink()
3807 memcpy(&tx_sc, &macsec->secy.tx_sc, sizeof(tx_sc)); in macsec_changelink()
3824 ctx.secy = &macsec->secy; in macsec_changelink()
3833 memcpy(&macsec->secy.tx_sc, &tx_sc, sizeof(tx_sc)); in macsec_changelink()
3834 memcpy(&macsec->secy, &secy, sizeof(secy)); in macsec_changelink()
3843 while (macsec->secy.rx_sc) { in macsec_del_dev()
3844 struct macsec_rx_sc *rx_sc = rtnl_dereference(macsec->secy.rx_sc); in macsec_del_dev()
3846 rcu_assign_pointer(macsec->secy.rx_sc, rx_sc->next); in macsec_del_dev()
3851 struct macsec_tx_sa *sa = rtnl_dereference(macsec->secy.tx_sc.sa[i]); in macsec_del_dev()
3854 RCU_INIT_POINTER(macsec->secy.tx_sc.sa[i], NULL); in macsec_del_dev()
3872 ctx.secy = &macsec->secy; in macsec_common_dellink()
3932 if (macsec->secy.sci == sci) in sci_exists()
3942 struct macsec_secy *secy = &macsec->secy; in macsec_add_dev() local
3948 secy->tx_sc.stats = netdev_alloc_pcpu_stats(struct pcpu_tx_sc_stats); in macsec_add_dev()
3949 if (!secy->tx_sc.stats) { in macsec_add_dev()
3957 secy->netdev = dev; in macsec_add_dev()
3958 secy->operational = true; in macsec_add_dev()
3959 secy->key_len = DEFAULT_SAK_LEN; in macsec_add_dev()
3960 secy->icv_len = icv_len; in macsec_add_dev()
3961 secy->validate_frames = MACSEC_VALIDATE_DEFAULT; in macsec_add_dev()
3962 secy->protect_frames = true; in macsec_add_dev()
3963 secy->replay_protect = false; in macsec_add_dev()
3964 secy->xpn = DEFAULT_XPN; in macsec_add_dev()
3966 secy->sci = sci; in macsec_add_dev()
3967 secy->tx_sc.active = true; in macsec_add_dev()
3968 secy->tx_sc.encoding_sa = DEFAULT_ENCODING_SA; in macsec_add_dev()
3969 secy->tx_sc.encrypt = DEFAULT_ENCRYPT; in macsec_add_dev()
3970 secy->tx_sc.send_sci = DEFAULT_SEND_SCI; in macsec_add_dev()
3971 secy->tx_sc.end_station = false; in macsec_add_dev()
3972 secy->tx_sc.scb = false; in macsec_add_dev()
4078 ctx.secy = &macsec->secy; in macsec_newlink()
4206 struct macsec_secy *secy = &macsec_priv(dev)->secy; in macsec_fill_info() local
4207 struct macsec_tx_sc *tx_sc = &secy->tx_sc; in macsec_fill_info()
4210 switch (secy->key_len) { in macsec_fill_info()
4212 csid = secy->xpn ? MACSEC_CIPHER_ID_GCM_AES_XPN_128 : MACSEC_DEFAULT_CIPHER_ID; in macsec_fill_info()
4215 csid = secy->xpn ? MACSEC_CIPHER_ID_GCM_AES_XPN_256 : MACSEC_CIPHER_ID_GCM_AES_256; in macsec_fill_info()
4221 if (nla_put_sci(skb, IFLA_MACSEC_SCI, secy->sci, in macsec_fill_info()
4223 nla_put_u8(skb, IFLA_MACSEC_ICV_LEN, secy->icv_len) || in macsec_fill_info()
4228 nla_put_u8(skb, IFLA_MACSEC_PROTECT, secy->protect_frames) || in macsec_fill_info()
4232 nla_put_u8(skb, IFLA_MACSEC_REPLAY_PROTECT, secy->replay_protect) || in macsec_fill_info()
4233 nla_put_u8(skb, IFLA_MACSEC_VALIDATION, secy->validate_frames) || in macsec_fill_info()
4237 if (secy->replay_protect) { in macsec_fill_info()
4238 if (nla_put_u32(skb, IFLA_MACSEC_WINDOW, secy->replay_window)) in macsec_fill_info()
4286 struct net_device *dev = m->secy.netdev; in macsec_notify()
4298 macsec_common_dellink(m->secy.netdev, &head); in macsec_notify()
4313 struct net_device *dev = m->secy.netdev; in macsec_notify()
4314 unsigned int mtu = real_dev->mtu - (m->secy.icv_len + in macsec_notify()