Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says:
====================
Netfilter updates for net-next
The following patchset contains a second batch of Netfilter updates for
your net-next tree. This includes a rework of the core hook
infrastructure that improves Netfilter performance by ~15% according to
synthetic benchmarks. Then, a large batch with ipset updates, including
a new hash:ipmac set type, via Jozsef Kadlecsik. This also includes a
couple of assorted updates.
Regarding the core hook infrastructure rework to improve performance,
using this simple drop-all packets ruleset from ingress:
nft add table netdev x
nft add chain netdev x y { type filter hook ingress device eth0 priority 0\; }
nft add rule netdev x y drop
And generating traffic through Jesper Brouer's
samples/pktgen/pktgen_bench_xmit_mode_netif_receive.sh script using -i
option. perf report shows nf_tables calls in its top 10:
17.30% kpktgend_0 [nf_tables] [k] nft_do_chain
15.75% kpktgend_0 [kernel.vmlinux] [k] __netif_receive_skb_core
10.39% kpktgend_0 [nf_tables_netdev] [k] nft_do_chain_netdev
I'm measuring here an improvement of ~15% in performance with this
patchset, so we got +2.5Mpps more. I have used my old laptop Intel(R)
Core(TM) i5-3320M CPU @ 2.60GHz 4-cores.
This rework contains more specifically, in strict order, these patches:
1) Remove compile-time debugging from core.
2) Remove obsolete comments that predate the rcu era. These days it is
well known that a Netfilter hook always runs under rcu_read_lock().
3) Remove threshold handling, this is only used by br_netfilter too.
We already have specific code to handle this from br_netfilter,
so remove this code from the core path.
4) Deprecate NF_STOP, as this is only used by br_netfilter.
5) Place nf_state_hook pointer into xt_action_param structure, so
this structure fits into one single cacheline according to pahole.
This also implicit affects nftables since it also relies on the
xt_action_param structure.
6) Move state->hook_entries into nf_queue entry. The hook_entries
pointer is only required by nf_queue(), so we can store this in the
queue entry instead.
7) use switch() statement to handle verdict cases.
8) Remove hook_entries field from nf_hook_state structure, this is only
required by nf_queue, so store it in nf_queue_entry structure.
9) Merge nf_iterate() into nf_hook_slow() that results in a much more
simple and readable function.
10) Handle NF_REPEAT away from the core, so far the only client is
nf_conntrack_in() and we can restart the packet processing using a
simple goto to jump back there when the TCP requires it.
This update required a second pass to fix fallout, fix from
Arnd Bergmann.
11) Set random seed from nft_hash when no seed is specified from
userspace.
12) Simplify nf_tables expression registration, in a much smarter way
to save lots of boiler plate code, by Liping Zhang.
13) Simplify layer 4 protocol conntrack tracker registration, from
Davide Caratti.
14) Missing CONFIG_NF_SOCKET_IPV4 dependency for udp4_lib_lookup, due
to recent generalization of the socket infrastructure, from Arnd
Bergmann.
15) Then, the ipset batch from Jozsef, he describes it as it follows:
* Cleanup: Remove extra whitespaces in ip_set.h
* Cleanup: Mark some of the helpers arguments as const in ip_set.h
* Cleanup: Group counter helper functions together in ip_set.h
* struct ip_set_skbinfo is introduced instead of open coded fields
in skbinfo get/init helper funcions.
* Use kmalloc() in comment extension helper instead of kzalloc()
because it is unnecessary to zero out the area just before
explicit initialization.
* Cleanup: Split extensions into separate files.
* Cleanup: Separate memsize calculation code into dedicated function.
* Cleanup: group ip_set_put_extensions() and ip_set_get_extensions()
together.
* Add element count to hash headers by Eric B Munson.
* Add element count to all set types header for uniform output
across all set types.
* Count non-static extension memory into memsize calculation for
userspace.
* Cleanup: Remove redundant mtype_expire() arguments, because
they can be get from other parameters.
* Cleanup: Simplify mtype_expire() for hash types by removing
one level of intendation.
* Make NLEN compile time constant for hash types.
* Make sure element data size is a multiple of u32 for the hash set
types.
* Optimize hash creation routine, exit as early as possible.
* Make struct htype per ipset family so nets array becomes fixed size
and thus simplifies the struct htype allocation.
* Collapse same condition body into a single one.
* Fix reported memory size for hash:* types, base hash bucket structure
was not taken into account.
* hash:ipmac type support added to ipset by Tomasz Chilinski.
* Use setup_timer() and mod_timer() instead of init_timer()
by Muhammad Falak R Wani, individually for the set type families.
16) Remove useless connlabel field in struct netns_ct, patch from
Florian Westphal.
17) xt_find_table_lock() doesn't return ERR_PTR() anymore, so simplify
{ip,ip6,arp}tables code that uses this.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -125,14 +125,24 @@ struct nf_conntrack_l4proto *nf_ct_l4proto_find_get(u_int16_t l3proto,
|
||||
void nf_ct_l4proto_put(struct nf_conntrack_l4proto *p);
|
||||
|
||||
/* Protocol pernet registration. */
|
||||
int nf_ct_l4proto_pernet_register_one(struct net *net,
|
||||
struct nf_conntrack_l4proto *proto);
|
||||
void nf_ct_l4proto_pernet_unregister_one(struct net *net,
|
||||
struct nf_conntrack_l4proto *proto);
|
||||
int nf_ct_l4proto_pernet_register(struct net *net,
|
||||
struct nf_conntrack_l4proto *proto);
|
||||
struct nf_conntrack_l4proto *proto[],
|
||||
unsigned int num_proto);
|
||||
void nf_ct_l4proto_pernet_unregister(struct net *net,
|
||||
struct nf_conntrack_l4proto *proto);
|
||||
struct nf_conntrack_l4proto *proto[],
|
||||
unsigned int num_proto);
|
||||
|
||||
/* Protocol global registration. */
|
||||
int nf_ct_l4proto_register(struct nf_conntrack_l4proto *proto);
|
||||
void nf_ct_l4proto_unregister(struct nf_conntrack_l4proto *proto);
|
||||
int nf_ct_l4proto_register_one(struct nf_conntrack_l4proto *proto);
|
||||
void nf_ct_l4proto_unregister_one(struct nf_conntrack_l4proto *proto);
|
||||
int nf_ct_l4proto_register(struct nf_conntrack_l4proto *proto[],
|
||||
unsigned int num_proto);
|
||||
void nf_ct_l4proto_unregister(struct nf_conntrack_l4proto *proto[],
|
||||
unsigned int num_proto);
|
||||
|
||||
/* Generic netlink helpers */
|
||||
int nf_ct_port_tuple_to_nlattr(struct sk_buff *skb,
|
||||
|
||||
@@ -12,6 +12,7 @@ struct nf_queue_entry {
|
||||
unsigned int id;
|
||||
|
||||
struct nf_hook_state state;
|
||||
struct nf_hook_entry *hook;
|
||||
u16 size; /* sizeof(entry) + saved route keys */
|
||||
|
||||
/* extra space to store route keys */
|
||||
|
||||
@@ -14,27 +14,43 @@
|
||||
|
||||
struct nft_pktinfo {
|
||||
struct sk_buff *skb;
|
||||
struct net *net;
|
||||
const struct net_device *in;
|
||||
const struct net_device *out;
|
||||
u8 pf;
|
||||
u8 hook;
|
||||
bool tprot_set;
|
||||
u8 tprot;
|
||||
/* for x_tables compatibility */
|
||||
struct xt_action_param xt;
|
||||
};
|
||||
|
||||
static inline struct net *nft_net(const struct nft_pktinfo *pkt)
|
||||
{
|
||||
return pkt->xt.state->net;
|
||||
}
|
||||
|
||||
static inline unsigned int nft_hook(const struct nft_pktinfo *pkt)
|
||||
{
|
||||
return pkt->xt.state->hook;
|
||||
}
|
||||
|
||||
static inline u8 nft_pf(const struct nft_pktinfo *pkt)
|
||||
{
|
||||
return pkt->xt.state->pf;
|
||||
}
|
||||
|
||||
static inline const struct net_device *nft_in(const struct nft_pktinfo *pkt)
|
||||
{
|
||||
return pkt->xt.state->in;
|
||||
}
|
||||
|
||||
static inline const struct net_device *nft_out(const struct nft_pktinfo *pkt)
|
||||
{
|
||||
return pkt->xt.state->out;
|
||||
}
|
||||
|
||||
static inline void nft_set_pktinfo(struct nft_pktinfo *pkt,
|
||||
struct sk_buff *skb,
|
||||
const struct nf_hook_state *state)
|
||||
{
|
||||
pkt->skb = skb;
|
||||
pkt->net = pkt->xt.net = state->net;
|
||||
pkt->in = pkt->xt.in = state->in;
|
||||
pkt->out = pkt->xt.out = state->out;
|
||||
pkt->hook = pkt->xt.hooknum = state->hook;
|
||||
pkt->pf = pkt->xt.family = state->pf;
|
||||
pkt->xt.state = state;
|
||||
}
|
||||
|
||||
static inline void nft_set_pktinfo_proto_unspec(struct nft_pktinfo *pkt,
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
#ifndef _NET_NF_TABLES_CORE_H
|
||||
#define _NET_NF_TABLES_CORE_H
|
||||
|
||||
extern struct nft_expr_type nft_imm_type;
|
||||
extern struct nft_expr_type nft_cmp_type;
|
||||
extern struct nft_expr_type nft_lookup_type;
|
||||
extern struct nft_expr_type nft_bitwise_type;
|
||||
extern struct nft_expr_type nft_byteorder_type;
|
||||
extern struct nft_expr_type nft_payload_type;
|
||||
extern struct nft_expr_type nft_dynset_type;
|
||||
extern struct nft_expr_type nft_range_type;
|
||||
|
||||
int nf_tables_core_module_init(void);
|
||||
void nf_tables_core_module_exit(void);
|
||||
|
||||
int nft_immediate_module_init(void);
|
||||
void nft_immediate_module_exit(void);
|
||||
|
||||
struct nft_cmp_fast_expr {
|
||||
u32 data;
|
||||
enum nft_registers sreg:8;
|
||||
@@ -25,24 +31,6 @@ static inline u32 nft_cmp_fast_mask(unsigned int len)
|
||||
|
||||
extern const struct nft_expr_ops nft_cmp_fast_ops;
|
||||
|
||||
int nft_cmp_module_init(void);
|
||||
void nft_cmp_module_exit(void);
|
||||
|
||||
int nft_range_module_init(void);
|
||||
void nft_range_module_exit(void);
|
||||
|
||||
int nft_lookup_module_init(void);
|
||||
void nft_lookup_module_exit(void);
|
||||
|
||||
int nft_dynset_module_init(void);
|
||||
void nft_dynset_module_exit(void);
|
||||
|
||||
int nft_bitwise_module_init(void);
|
||||
void nft_bitwise_module_exit(void);
|
||||
|
||||
int nft_byteorder_module_init(void);
|
||||
void nft_byteorder_module_exit(void);
|
||||
|
||||
struct nft_payload {
|
||||
enum nft_payload_bases base:8;
|
||||
u8 offset;
|
||||
@@ -62,7 +50,4 @@ struct nft_payload_set {
|
||||
extern const struct nft_expr_ops nft_payload_fast_ops;
|
||||
extern struct static_key_false nft_trace_enabled;
|
||||
|
||||
int nft_payload_module_init(void);
|
||||
void nft_payload_module_exit(void);
|
||||
|
||||
#endif /* _NET_NF_TABLES_CORE_H */
|
||||
|
||||
@@ -91,7 +91,6 @@ struct netns_ct {
|
||||
struct nf_ip_net nf_ct_proto;
|
||||
#if defined(CONFIG_NF_CONNTRACK_LABELS)
|
||||
unsigned int labels_used;
|
||||
u8 label_words;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user