include/net/tcp_ao.h

Source file repositories/reference/linux-study-clean/include/net/tcp_ao.h

File Facts

System
Linux kernel
Corpus path
include/net/tcp_ao.h
Extension
.h
Size
11929 bytes
Lines
373
Domain
Networking Core
Bucket
Sockets, Protocols, Packet Path, And Network Policy
Inferred role
Networking Core: implementation source
Status
source implementation candidate

Why This File Exists

Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.

Dependency Surface

Detected Declarations

Annotated Snippet

struct tcp_ao_hdr {
	u8	kind;
	u8	length;
	u8	keyid;
	u8	rnext_keyid;
};

static inline u8 tcp_ao_hdr_maclen(const struct tcp_ao_hdr *aoh)
{
	return aoh->length - sizeof(struct tcp_ao_hdr);
}

struct tcp_ao_counters {
	atomic64_t	pkt_good;
	atomic64_t	pkt_bad;
	atomic64_t	key_not_found;
	atomic64_t	ao_required;
	atomic64_t	dropped_icmp;
};

enum tcp_ao_algo_id {
	TCP_AO_ALGO_HMAC_SHA1 = 1, /* specified by RFC 5926 */
	TCP_AO_ALGO_HMAC_SHA256, /* Linux extension */
	TCP_AO_ALGO_AES_128_CMAC, /* specified by RFC 5926 */
};

/*
 * This is the maximum untruncated MAC length, in bytes.  Note that the MACs
 * actually get truncated to 20 or fewer bytes to fit in the TCP options space.
 */
#define TCP_AO_MAX_MAC_LEN		SHA256_DIGEST_SIZE

#define TCP_AO_MAX_TRAFFIC_KEY_LEN	SHA256_DIGEST_SIZE

struct tcp_ao_mac_ctx;

struct tcp_ao_key {
	struct hlist_node	node;
	union tcp_ao_addr	addr;
	u8			key[TCP_AO_MAXKEYLEN];
	enum tcp_ao_algo_id	algo;
	unsigned int		digest_size;
	int			l3index;
	u8			prefixlen;
	u8			family;
	u8			keylen;
	u8			keyflags;
	u8			sndid;
	u8			rcvid;
	u8			maclen;
	struct rcu_head		rcu;
	atomic64_t		pkt_good;
	atomic64_t		pkt_bad;
	u8			traffic_keys[];
};

static inline u8 *rcv_other_key(struct tcp_ao_key *key)
{
	return key->traffic_keys;
}

static inline u8 *snd_other_key(struct tcp_ao_key *key)
{
	return key->traffic_keys + key->digest_size;
}

static inline int tcp_ao_maclen(const struct tcp_ao_key *key)
{
	return key->maclen;
}

/* Use tcp_ao_len_aligned() for TCP header calculations */
static inline int tcp_ao_len(const struct tcp_ao_key *key)
{
	return tcp_ao_maclen(key) + sizeof(struct tcp_ao_hdr);
}

static inline int tcp_ao_len_aligned(const struct tcp_ao_key *key)
{
	return round_up(tcp_ao_len(key), 4);
}

static inline unsigned int tcp_ao_digest_size(struct tcp_ao_key *key)
{
	return key->digest_size;
}

static inline int tcp_ao_sizeof_key(const struct tcp_ao_key *key)
{
	return sizeof(struct tcp_ao_key) + (key->digest_size << 1);

Annotation

Implementation Notes