2525
2626#include <uapi/linux/if_macsec.h>
2727
28- #define MACSEC_SCI_LEN 8
29-
3028/* SecTAG length = macsec_eth_header without the optional SCI */
3129#define MACSEC_TAG_LEN 6
3230
@@ -47,20 +45,10 @@ struct macsec_eth_header {
4745 u8 secure_channel_id [8 ]; /* optional */
4846} __packed ;
4947
50- #define MACSEC_TCI_VERSION 0x80
51- #define MACSEC_TCI_ES 0x40 /* end station */
52- #define MACSEC_TCI_SC 0x20 /* SCI present */
53- #define MACSEC_TCI_SCB 0x10 /* epon */
54- #define MACSEC_TCI_E 0x08 /* encryption */
55- #define MACSEC_TCI_C 0x04 /* changed text */
56- #define MACSEC_AN_MASK 0x03 /* association number */
57- #define MACSEC_TCI_CONFID (MACSEC_TCI_E | MACSEC_TCI_C)
58-
5948/* minimum secure data length deemed "not short", see IEEE 802.1AE-2006 9.7 */
6049#define MIN_NON_SHORT_LEN 48
6150
6251#define GCM_AES_IV_LEN 12
63- #define DEFAULT_ICV_LEN 16
6452
6553#define for_each_rxsc (secy , sc ) \
6654 for (sc = rcu_dereference_bh(secy->rx_sc); \
@@ -244,7 +232,6 @@ static struct macsec_cb *macsec_skb_cb(struct sk_buff *skb)
244232 return (struct macsec_cb * )skb -> cb ;
245233}
246234
247- #define MACSEC_PORT_ES (htons(0x0001))
248235#define MACSEC_PORT_SCB (0x0000)
249236#define MACSEC_UNDEF_SCI ((__force sci_t)0xffffffffffffffffULL)
250237#define MACSEC_UNDEF_SSCI ((__force ssci_t)0xffffffff)
@@ -259,14 +246,6 @@ static struct macsec_cb *macsec_skb_cb(struct sk_buff *skb)
259246#define DEFAULT_ENCODING_SA 0
260247#define MACSEC_XPN_MAX_REPLAY_WINDOW (((1 << 30) - 1))
261248
262- static bool send_sci (const struct macsec_secy * secy )
263- {
264- const struct macsec_tx_sc * tx_sc = & secy -> tx_sc ;
265-
266- return tx_sc -> send_sci ||
267- (secy -> n_rx_sc > 1 && !tx_sc -> end_station && !tx_sc -> scb );
268- }
269-
270249static sci_t make_sci (const u8 * addr , __be16 port )
271250{
272251 sci_t sci ;
@@ -331,7 +310,7 @@ static void macsec_fill_sectag(struct macsec_eth_header *h,
331310 /* with GCM, C/E clear for !encrypt, both set for encrypt */
332311 if (tx_sc -> encrypt )
333312 h -> tci_an |= MACSEC_TCI_CONFID ;
334- else if (secy -> icv_len != DEFAULT_ICV_LEN )
313+ else if (secy -> icv_len != MACSEC_DEFAULT_ICV_LEN )
335314 h -> tci_an |= MACSEC_TCI_C ;
336315
337316 h -> tci_an |= tx_sc -> encoding_sa ;
@@ -655,7 +634,7 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
655634
656635 unprotected_len = skb -> len ;
657636 eth = eth_hdr (skb );
658- sci_present = send_sci (secy );
637+ sci_present = macsec_send_sci (secy );
659638 hh = skb_push (skb , macsec_extra_len (sci_present ));
660639 memmove (hh , eth , 2 * ETH_ALEN );
661640
@@ -1303,7 +1282,7 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
13031282 /* 10.6.1 if the SC is not found */
13041283 cbit = !!(hdr -> tci_an & MACSEC_TCI_C );
13051284 if (!cbit )
1306- macsec_finalize_skb (skb , DEFAULT_ICV_LEN ,
1285+ macsec_finalize_skb (skb , MACSEC_DEFAULT_ICV_LEN ,
13071286 macsec_extra_len (macsec_skb_cb (skb )-> has_sci ));
13081287
13091288 list_for_each_entry_rcu (macsec , & rxd -> secys , secys ) {
@@ -4067,7 +4046,7 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
40674046{
40684047 struct macsec_dev * macsec = macsec_priv (dev );
40694048 rx_handler_func_t * rx_handler ;
4070- u8 icv_len = DEFAULT_ICV_LEN ;
4049+ u8 icv_len = MACSEC_DEFAULT_ICV_LEN ;
40714050 struct net_device * real_dev ;
40724051 int err , mtu ;
40734052 sci_t sci ;
@@ -4191,7 +4170,7 @@ static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[],
41914170 struct netlink_ext_ack * extack )
41924171{
41934172 u64 csid = MACSEC_DEFAULT_CIPHER_ID ;
4194- u8 icv_len = DEFAULT_ICV_LEN ;
4173+ u8 icv_len = MACSEC_DEFAULT_ICV_LEN ;
41954174 int flag ;
41964175 bool es , scb , sci ;
41974176
@@ -4203,7 +4182,7 @@ static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[],
42034182
42044183 if (data [IFLA_MACSEC_ICV_LEN ]) {
42054184 icv_len = nla_get_u8 (data [IFLA_MACSEC_ICV_LEN ]);
4206- if (icv_len != DEFAULT_ICV_LEN ) {
4185+ if (icv_len != MACSEC_DEFAULT_ICV_LEN ) {
42074186 char dummy_key [DEFAULT_SAK_LEN ] = { 0 };
42084187 struct crypto_aead * dummy_tfm ;
42094188
0 commit comments