Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1d10adb authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by David S. Miller
Browse files

[NETFILTER]: Add ctnetlink port for nf_conntrack

parent 205d67c7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ enum ctattr_l4proto {
	CTA_PROTO_ICMP_ID,
	CTA_PROTO_ICMP_TYPE,
	CTA_PROTO_ICMP_CODE,
	CTA_PROTO_ICMPV6_ID,
	CTA_PROTO_ICMPV6_TYPE,
	CTA_PROTO_ICMPV6_CODE,
	__CTA_PROTO_MAX
};
#define CTA_PROTO_MAX (__CTA_PROTO_MAX - 1)
+31 −0
Original line number Diff line number Diff line
@@ -94,6 +94,9 @@ struct nf_conn
	/* Current number of expected connections */
	unsigned int expecting;

	/* Unique ID that identifies this conntrack*/
	unsigned int id;

	/* Helper. if any */
	struct nf_conntrack_helper *helper;

@@ -140,6 +143,9 @@ struct nf_conntrack_expect
	/* Usage count. */
	atomic_t use;

	/* Unique ID */
	unsigned int id;

	/* Flags */
	unsigned int flags;

@@ -190,6 +196,31 @@ static inline void nf_ct_put(struct nf_conn *ct)
	nf_conntrack_put(&ct->ct_general);
}

extern struct nf_conntrack_tuple_hash *
__nf_conntrack_find(const struct nf_conntrack_tuple *tuple,
		    const struct nf_conn *ignored_conntrack);

extern void nf_conntrack_hash_insert(struct nf_conn *ct);

extern struct nf_conntrack_expect *
__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);

extern struct nf_conntrack_expect *
nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple);

extern void nf_ct_unlink_expect(struct nf_conntrack_expect *exp);

extern void nf_ct_remove_expectations(struct nf_conn *ct);

extern void nf_conntrack_flush(void);

extern struct nf_conntrack_helper *
nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple);
extern void nf_ct_helper_put(struct nf_conntrack_helper *helper);

extern struct nf_conntrack_helper *
__nf_conntrack_helper_find_byname(const char *name);

/* call to create an explicit dependency on nf_conntrack. */
extern void need_nf_conntrack(void);

+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ struct nf_conntrack_helper
		    unsigned int protoff,
		    struct nf_conn *ct,
		    enum ip_conntrack_info conntrackinfo);

	int (*to_nfattr)(struct sk_buff *skb, const struct nf_conn *ct);
};

extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
+14 −1
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
#include <linux/seq_file.h>
#include <net/netfilter/nf_conntrack.h>

struct nfattr;

struct nf_conntrack_l3proto
{
	/* Next pointer. */
@@ -70,6 +72,12 @@ struct nf_conntrack_l3proto

	u_int32_t (*get_features)(const struct nf_conntrack_tuple *tuple);

	int (*tuple_to_nfattr)(struct sk_buff *skb,
			       const struct nf_conntrack_tuple *t);

	int (*nfattr_to_tuple)(struct nfattr *tb[],
			       struct nf_conntrack_tuple *t);

	/* Module (if any) which this is connected to. */
	struct module *me;
};
@@ -81,11 +89,16 @@ extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);

static inline struct nf_conntrack_l3proto *
nf_ct_find_l3proto(u_int16_t l3proto)
__nf_ct_l3proto_find(u_int16_t l3proto)
{
	return nf_ct_l3protos[l3proto];
}

extern struct nf_conntrack_l3proto *
nf_ct_l3proto_find_get(u_int16_t l3proto);

extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p);

/* Existing built-in protocols */
extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
+25 −1
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <net/netfilter/nf_conntrack.h>

struct seq_file;
struct nfattr;

struct nf_conntrack_protocol
{
@@ -66,6 +67,18 @@ struct nf_conntrack_protocol
		     enum ip_conntrack_info *ctinfo,
		     int pf, unsigned int hooknum);

	/* convert protoinfo to nfnetink attributes */
	int (*to_nfattr)(struct sk_buff *skb, struct nfattr *nfa,
			 const struct nf_conn *ct);

	/* convert nfnetlink attributes to protoinfo */
	int (*from_nfattr)(struct nfattr *tb[], struct nf_conn *ct);

	int (*tuple_to_nfattr)(struct sk_buff *skb,
			       const struct nf_conntrack_tuple *t);
	int (*nfattr_to_tuple)(struct nfattr *tb[],
			       struct nf_conntrack_tuple *t);

	/* Module (if any) which this is connected to. */
	struct module *me;
};
@@ -80,12 +93,23 @@ extern struct nf_conntrack_protocol nf_conntrack_generic_protocol;
extern struct nf_conntrack_protocol **nf_ct_protos[PF_MAX];

extern struct nf_conntrack_protocol *
nf_ct_find_proto(u_int16_t l3proto, u_int8_t protocol);
__nf_ct_proto_find(u_int16_t l3proto, u_int8_t protocol);

extern struct nf_conntrack_protocol *
nf_ct_proto_find_get(u_int16_t l3proto, u_int8_t protocol);

extern void nf_ct_proto_put(struct nf_conntrack_protocol *p);

/* Protocol registration. */
extern int nf_conntrack_protocol_register(struct nf_conntrack_protocol *proto);
extern void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol *proto);

/* Generic netlink helpers */
extern int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb,
				      const struct nf_conntrack_tuple *tuple);
extern int nf_ct_port_nfattr_to_tuple(struct nfattr *tb[],
				      struct nf_conntrack_tuple *t);

/* Log invalid packets */
extern unsigned int nf_ct_log_invalid;

Loading