Skip to content

Commit 343917b

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== Netfilter/IPVS updates for net-next The following patchset contains Netfilter/IPVS updates for your net-next tree: 1) Introduce a hashtable to speed up object lookups, from Florian Westphal. 2) Make direct calls to built-in extension, also from Florian. 3) Call helper before confirming the conntrack as it used to be originally, from Florian. 4) Call request_module() to autoload br_netfilter when physdev is used to relax the dependency, also from Florian. 5) Allow to insert rules at a given position ID that is internal to the batch, from Phil Sutter. 6) Several patches to replace conntrack indirections by direct calls, and to reduce modularization, from Florian. This also includes several follow up patches to deal with minor fallout from this rework. 7) Use RCU from conntrack gre helper, from Florian. 8) GRE conntrack module becomes built-in into nf_conntrack, from Florian. 9) Replace nf_ct_invert_tuplepr() by calls to nf_ct_invert_tuple(), from Florian. 10) Unify sysctl handling at the core of nf_conntrack, from Florian. 11) Provide modparam to register conntrack hooks. 12) Allow to match on the interface kind string, from wenxu. 13) Remove several exported symbols, not required anymore now after a bit of de-modulatization work has been done, from Florian. 14) Remove built-in map support in the hash extension, this can be done with the existing userspace infrastructure, from laura. 15) Remove indirection to calculate checksums in IPVS, from Matteo Croce. 16) Use call wrappers for indirection in IPVS, also from Matteo. 17) Remove superfluous __percpu parameter in nft_counter, patch from Luc Van Oostenryck. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents bb7c778 + 83f5292 commit 343917b

61 files changed

Lines changed: 1178 additions & 1697 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎include/linux/netfilter/nf_conntrack_proto_gre.h‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,18 @@ struct nf_conn;
1919
struct nf_ct_gre_keymap {
2020
struct list_head list;
2121
struct nf_conntrack_tuple tuple;
22-
};
23-
24-
enum grep_conntrack {
25-
GRE_CT_UNREPLIED,
26-
GRE_CT_REPLIED,
27-
GRE_CT_MAX
28-
};
29-
30-
struct netns_proto_gre {
31-
struct nf_proto_net nf;
32-
rwlock_t keymap_lock;
33-
struct list_head keymap_list;
34-
unsigned int gre_timeouts[GRE_CT_MAX];
22+
struct rcu_head rcu;
3523
};
3624

3725
/* add new tuple->key_reply pair to keymap */
3826
int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir,
3927
struct nf_conntrack_tuple *t);
4028

29+
void nf_ct_gre_keymap_flush(struct net *net);
4130
/* delete keymap entries */
4231
void nf_ct_gre_keymap_destroy(struct nf_conn *ct);
4332

33+
bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
34+
struct net *net, struct nf_conntrack_tuple *tuple);
4435
#endif /* __KERNEL__ */
4536
#endif /* _CONNTRACK_PROTO_GRE_H */

‎include/linux/netfilter_ipv4.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
2525
unsigned int dataoff, u_int8_t protocol);
2626
int nf_ip_route(struct net *net, struct dst_entry **dst, struct flowi *fl,
2727
bool strict);
28-
int nf_ip_reroute(struct sk_buff *skb, const struct nf_queue_entry *entry);
2928
#else
3029
static inline __sum16 nf_ip_checksum(struct sk_buff *skb, unsigned int hook,
3130
unsigned int dataoff, u_int8_t protocol)
@@ -37,11 +36,6 @@ static inline int nf_ip_route(struct net *net, struct dst_entry **dst,
3736
{
3837
return -EOPNOTSUPP;
3938
}
40-
static inline int nf_ip_reroute(struct sk_buff *skb,
41-
const struct nf_queue_entry *entry)
42-
{
43-
return -EOPNOTSUPP;
44-
}
4539
#endif /* CONFIG_INET */
4640

4741
#endif /*__LINUX_IP_NETFILTER_H*/

‎include/net/ip_vs.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,6 @@ struct ip_vs_protocol {
453453
int (*dnat_handler)(struct sk_buff *skb, struct ip_vs_protocol *pp,
454454
struct ip_vs_conn *cp, struct ip_vs_iphdr *iph);
455455

456-
int (*csum_check)(int af, struct sk_buff *skb,
457-
struct ip_vs_protocol *pp);
458-
459456
const char *(*state_name)(int state);
460457

461458
void (*state_transition)(struct ip_vs_conn *cp, int direction,

‎include/net/netfilter/br_netfilter.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)
4343
}
4444

4545
struct net_device *setup_pre_routing(struct sk_buff *skb);
46-
void br_netfilter_enable(void);
4746

4847
#if IS_ENABLED(CONFIG_IPV6)
4948
int br_validate_ipv6(struct net *net, struct sk_buff *skb);

‎include/net/netfilter/ipv4/nf_conntrack_ipv4.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ extern const struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp;
2222
#ifdef CONFIG_NF_CT_PROTO_UDPLITE
2323
extern const struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite;
2424
#endif
25+
#ifdef CONFIG_NF_CT_PROTO_GRE
26+
extern const struct nf_conntrack_l4proto nf_conntrack_l4proto_gre;
27+
#endif
2528

2629
#endif /*_NF_CONNTRACK_IPV4_H*/

‎include/net/netfilter/nf_conntrack.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ bool nf_ct_delete(struct nf_conn *ct, u32 pid, int report);
187187
bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff,
188188
u_int16_t l3num, struct net *net,
189189
struct nf_conntrack_tuple *tuple);
190-
bool nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
191-
const struct nf_conntrack_tuple *orig);
192190

193191
void __nf_ct_refresh_acct(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
194192
const struct sk_buff *skb,

‎include/net/netfilter/nf_conntrack_core.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int nf_conntrack_init_net(struct net *net);
2626
void nf_conntrack_cleanup_net(struct net *net);
2727
void nf_conntrack_cleanup_net_list(struct list_head *net_exit_list);
2828

29-
int nf_conntrack_proto_pernet_init(struct net *net);
29+
void nf_conntrack_proto_pernet_init(struct net *net);
3030
void nf_conntrack_proto_pernet_fini(struct net *net);
3131

3232
int nf_conntrack_proto_init(void);
@@ -39,8 +39,7 @@ void nf_conntrack_init_end(void);
3939
void nf_conntrack_cleanup_end(void);
4040

4141
bool nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
42-
const struct nf_conntrack_tuple *orig,
43-
const struct nf_conntrack_l4proto *l4proto);
42+
const struct nf_conntrack_tuple *orig);
4443

4544
/* Find a connection corresponding to a tuple. */
4645
struct nf_conntrack_tuple_hash *

‎include/net/netfilter/nf_conntrack_l4proto.h‎

Lines changed: 73 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,6 @@ struct nf_conntrack_l4proto {
2727
/* protoinfo nlattr size, closes a hole */
2828
u16 nlattr_size;
2929

30-
/* Try to fill in the third arg: dataoff is offset past network protocol
31-
hdr. Return true if possible. */
32-
bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int dataoff,
33-
struct net *net, struct nf_conntrack_tuple *tuple);
34-
35-
/* Invert the per-proto part of the tuple: ie. turn xmit into reply.
36-
* Only used by icmp, most protocols use a generic version.
37-
*/
38-
bool (*invert_tuple)(struct nf_conntrack_tuple *inverse,
39-
const struct nf_conntrack_tuple *orig);
40-
41-
/* Returns verdict for packet, or -1 for invalid. */
42-
int (*packet)(struct nf_conn *ct,
43-
struct sk_buff *skb,
44-
unsigned int dataoff,
45-
enum ip_conntrack_info ctinfo,
46-
const struct nf_hook_state *state);
47-
48-
/* Called when a conntrack entry is destroyed */
49-
void (*destroy)(struct nf_conn *ct);
50-
5130
/* called by gc worker if table is full */
5231
bool (*can_early_drop)(const struct nf_conn *ct);
5332

@@ -79,16 +58,22 @@ struct nf_conntrack_l4proto {
7958
/* Print out the private part of the conntrack. */
8059
void (*print_conntrack)(struct seq_file *s, struct nf_conn *);
8160
#endif
82-
unsigned int *net_id;
83-
/* Init l4proto pernet data */
84-
int (*init_net)(struct net *net);
61+
};
8562

86-
/* Return the per-net protocol part. */
87-
struct nf_proto_net *(*get_net_proto)(struct net *net);
63+
bool icmp_pkt_to_tuple(const struct sk_buff *skb,
64+
unsigned int dataoff,
65+
struct net *net,
66+
struct nf_conntrack_tuple *tuple);
8867

89-
/* Module (if any) which this is connected to. */
90-
struct module *me;
91-
};
68+
bool icmpv6_pkt_to_tuple(const struct sk_buff *skb,
69+
unsigned int dataoff,
70+
struct net *net,
71+
struct nf_conntrack_tuple *tuple);
72+
73+
bool nf_conntrack_invert_icmp_tuple(struct nf_conntrack_tuple *tuple,
74+
const struct nf_conntrack_tuple *orig);
75+
bool nf_conntrack_invert_icmpv6_tuple(struct nf_conntrack_tuple *tuple,
76+
const struct nf_conntrack_tuple *orig);
9277

9378
int nf_conntrack_icmpv4_error(struct nf_conn *tmpl,
9479
struct sk_buff *skb,
@@ -99,31 +84,63 @@ int nf_conntrack_icmpv6_error(struct nf_conn *tmpl,
9984
struct sk_buff *skb,
10085
unsigned int dataoff,
10186
const struct nf_hook_state *state);
87+
88+
int nf_conntrack_icmp_packet(struct nf_conn *ct,
89+
struct sk_buff *skb,
90+
enum ip_conntrack_info ctinfo,
91+
const struct nf_hook_state *state);
92+
93+
int nf_conntrack_icmpv6_packet(struct nf_conn *ct,
94+
struct sk_buff *skb,
95+
enum ip_conntrack_info ctinfo,
96+
const struct nf_hook_state *state);
97+
98+
int nf_conntrack_udp_packet(struct nf_conn *ct,
99+
struct sk_buff *skb,
100+
unsigned int dataoff,
101+
enum ip_conntrack_info ctinfo,
102+
const struct nf_hook_state *state);
103+
int nf_conntrack_udplite_packet(struct nf_conn *ct,
104+
struct sk_buff *skb,
105+
unsigned int dataoff,
106+
enum ip_conntrack_info ctinfo,
107+
const struct nf_hook_state *state);
108+
int nf_conntrack_tcp_packet(struct nf_conn *ct,
109+
struct sk_buff *skb,
110+
unsigned int dataoff,
111+
enum ip_conntrack_info ctinfo,
112+
const struct nf_hook_state *state);
113+
int nf_conntrack_dccp_packet(struct nf_conn *ct,
114+
struct sk_buff *skb,
115+
unsigned int dataoff,
116+
enum ip_conntrack_info ctinfo,
117+
const struct nf_hook_state *state);
118+
int nf_conntrack_sctp_packet(struct nf_conn *ct,
119+
struct sk_buff *skb,
120+
unsigned int dataoff,
121+
enum ip_conntrack_info ctinfo,
122+
const struct nf_hook_state *state);
123+
int nf_conntrack_gre_packet(struct nf_conn *ct,
124+
struct sk_buff *skb,
125+
unsigned int dataoff,
126+
enum ip_conntrack_info ctinfo,
127+
const struct nf_hook_state *state);
128+
129+
void nf_conntrack_generic_init_net(struct net *net);
130+
void nf_conntrack_tcp_init_net(struct net *net);
131+
void nf_conntrack_udp_init_net(struct net *net);
132+
void nf_conntrack_gre_init_net(struct net *net);
133+
void nf_conntrack_dccp_init_net(struct net *net);
134+
void nf_conntrack_sctp_init_net(struct net *net);
135+
void nf_conntrack_icmp_init_net(struct net *net);
136+
void nf_conntrack_icmpv6_init_net(struct net *net);
137+
102138
/* Existing built-in generic protocol */
103139
extern const struct nf_conntrack_l4proto nf_conntrack_l4proto_generic;
104140

105141
#define MAX_NF_CT_PROTO IPPROTO_UDPLITE
106142

107-
const struct nf_conntrack_l4proto *__nf_ct_l4proto_find(u8 l4proto);
108-
109-
const struct nf_conntrack_l4proto *nf_ct_l4proto_find_get(u8 l4proto);
110-
void nf_ct_l4proto_put(const struct nf_conntrack_l4proto *p);
111-
112-
/* Protocol pernet registration. */
113-
int nf_ct_l4proto_pernet_register_one(struct net *net,
114-
const struct nf_conntrack_l4proto *proto);
115-
void nf_ct_l4proto_pernet_unregister_one(struct net *net,
116-
const struct nf_conntrack_l4proto *proto);
117-
int nf_ct_l4proto_pernet_register(struct net *net,
118-
const struct nf_conntrack_l4proto *const proto[],
119-
unsigned int num_proto);
120-
void nf_ct_l4proto_pernet_unregister(struct net *net,
121-
const struct nf_conntrack_l4proto *const proto[],
122-
unsigned int num_proto);
123-
124-
/* Protocol global registration. */
125-
int nf_ct_l4proto_register_one(const struct nf_conntrack_l4proto *proto);
126-
void nf_ct_l4proto_unregister_one(const struct nf_conntrack_l4proto *proto);
143+
const struct nf_conntrack_l4proto *nf_ct_l4proto_find(u8 l4proto);
127144

128145
/* Generic netlink helpers */
129146
int nf_ct_port_tuple_to_nlattr(struct sk_buff *skb,
@@ -192,4 +209,11 @@ static inline struct nf_sctp_net *nf_sctp_pernet(struct net *net)
192209
}
193210
#endif
194211

212+
#ifdef CONFIG_NF_CT_PROTO_GRE
213+
static inline struct nf_gre_net *nf_gre_pernet(struct net *net)
214+
{
215+
return &net->ct.nf_ct_proto.gre;
216+
}
217+
#endif
218+
195219
#endif /*_NF_CONNTRACK_PROTOCOL_H*/

‎include/net/netfilter/nf_nat.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ extern unsigned int nf_nat_alloc_null_binding(struct nf_conn *ct,
4747

4848
struct nf_conn_nat *nf_ct_nat_ext_add(struct nf_conn *ct);
4949

50-
/* Is this tuple already taken? (not by us)*/
51-
int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
52-
const struct nf_conn *ignored_conntrack);
53-
5450
static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
5551
{
5652
#if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE)

‎include/net/netfilter/nf_tables.h‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,22 +1011,33 @@ void nft_unregister_expr(struct nft_expr_type *);
10111011
int nft_verdict_dump(struct sk_buff *skb, int type,
10121012
const struct nft_verdict *v);
10131013

1014+
/**
1015+
* struct nft_object_hash_key - key to lookup nft_object
1016+
*
1017+
* @name: name of the stateful object to look up
1018+
* @table: table the object belongs to
1019+
*/
1020+
struct nft_object_hash_key {
1021+
const char *name;
1022+
const struct nft_table *table;
1023+
};
1024+
10141025
/**
10151026
* struct nft_object - nf_tables stateful object
10161027
*
10171028
* @list: table stateful object list node
1018-
* @table: table this object belongs to
1019-
* @name: name of this stateful object
1029+
* @key: keys that identify this object
1030+
* @rhlhead: nft_objname_ht node
10201031
* @genmask: generation mask
10211032
* @use: number of references to this stateful object
10221033
* @handle: unique object handle
10231034
* @ops: object operations
1024-
* @data: object data, layout depends on type
1035+
* @data: object data, layout depends on type
10251036
*/
10261037
struct nft_object {
10271038
struct list_head list;
1028-
char *name;
1029-
struct nft_table *table;
1039+
struct rhlist_head rhlhead;
1040+
struct nft_object_hash_key key;
10301041
u32 genmask:2,
10311042
use:30;
10321043
u64 handle;
@@ -1043,11 +1054,12 @@ static inline void *nft_obj_data(const struct nft_object *obj)
10431054

10441055
#define nft_expr_obj(expr) *((struct nft_object **)nft_expr_priv(expr))
10451056

1046-
struct nft_object *nft_obj_lookup(const struct nft_table *table,
1057+
struct nft_object *nft_obj_lookup(const struct net *net,
1058+
const struct nft_table *table,
10471059
const struct nlattr *nla, u32 objtype,
10481060
u8 genmask);
10491061

1050-
void nft_obj_notify(struct net *net, struct nft_table *table,
1062+
void nft_obj_notify(struct net *net, const struct nft_table *table,
10511063
struct nft_object *obj, u32 portid, u32 seq,
10521064
int event, int family, int report, gfp_t gfp);
10531065

0 commit comments

Comments
 (0)