include/net/netfilter/nf_conntrack_expect.h

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

File Facts

System
Linux kernel
Corpus path
include/net/netfilter/nf_conntrack_expect.h
Extension
.h
Size
4528 bytes
Lines
158
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 nf_conntrack_expect {
	/* Conntrack expectation list member */
	struct hlist_node lnode;

	/* Hash member */
	struct hlist_node hnode;

	/* Network namespace */
	possible_net_t net;

	/* We expect this tuple, with the following mask */
	struct nf_conntrack_tuple tuple;
	struct nf_conntrack_tuple_mask mask;

#ifdef CONFIG_NF_CONNTRACK_ZONES
	struct nf_conntrack_zone zone;
#endif
	/* Usage count. */
	refcount_t use;

	/* Flags */
	unsigned int flags;

	/* Expectation class */
	unsigned int class;

	/* Function to call after setup and insertion */
	void (*expectfn)(struct nf_conn *new,
			 struct nf_conntrack_expect *this);

	/* Helper that created this expectation */
	struct nf_conntrack_helper __rcu *helper;

	/* Helper to assign to new connection */
	struct nf_conntrack_helper __rcu *assign_helper;

	/* The conntrack of the master connection */
	struct nf_conn *master;

	/* Timer function; deletes the expectation. */
	struct timer_list timeout;

#if IS_ENABLED(CONFIG_NF_NAT)
	union nf_inet_addr saved_addr;
	/* This is the original per-proto part, used to map the
	 * expected connection the way the recipient expects. */
	union nf_conntrack_man_proto saved_proto;
	/* Direction relative to the master connection. */
	enum ip_conntrack_dir dir;
#endif

	struct rcu_head rcu;
};

static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)
{
	return read_pnet(&exp->net);
}

static inline bool nf_ct_exp_zone_equal_any(const struct nf_conntrack_expect *a,
					    const struct nf_conntrack_zone *b)
{
#ifdef CONFIG_NF_CONNTRACK_ZONES
	return a->zone.id == b->id;
#else
	return true;
#endif
}

#define NF_CT_EXP_POLICY_NAME_LEN	16

struct nf_conntrack_expect_policy {
	unsigned int	max_expected;
	unsigned int	timeout;
	char		name[NF_CT_EXP_POLICY_NAME_LEN];
};

#define NF_CT_EXPECT_CLASS_DEFAULT	0
#define NF_CT_EXPECT_MAX_CNT		255

/* Allow to reuse expectations with the same tuples from different master
 * conntracks.
 */
#define NF_CT_EXP_F_SKIP_MASTER	0x1

int nf_conntrack_expect_pernet_init(struct net *net);
void nf_conntrack_expect_pernet_fini(struct net *net);

int nf_conntrack_expect_init(void);
void nf_conntrack_expect_fini(void);

Annotation

Implementation Notes