Skip to content

Commit 52a623b

Browse files
committed
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 Netfilter updates for your net-next tree. This batch contains connection tracking updates for the cleanup iteration path, patches from Florian Westphal: X) Skip unconfirmed conntracks in nf_ct_iterate_cleanup_net(), just set dying bit to let the CPU release them. X) Add nf_ct_iterate_destroy() to be used on module removal, to kill conntrack from all namespace. X) Restart iteration on hashtable resizing, since both may occur at the same time. X) Use the new nf_ct_iterate_destroy() to remove conntrack with NAT mapping on module removal. X) Use nf_ct_iterate_destroy() to remove conntrack entries helper module removal, from Liping Zhang. X) Use nf_ct_iterate_cleanup_net() to remove the timeout extension if user requests this, also from Liping. X) Add net_ns_barrier() and use it from FTP helper, so make sure no concurrent namespace removal happens at the same time while the helper module is being removed. X) Use NFPROTO_MAX in layer 3 conntrack protocol array, to reduce module size. Same thing in nf_tables. Updates for the nf_tables infrastructure: X) Prepare usage of the extended ACK reporting infrastructure for nf_tables. X) Remove unnecessary forward declaration in nf_tables hash set. X) Skip set size estimation if number of element is not specified. X) Changes to accomodate a (faster) unresizable hash set implementation, for anonymous sets and dynamic size fixed sets with no timeouts. X) Faster lookup function for unresizable hash table for 2 and 4 bytes key. And, finally, a bunch of asorted small updates and cleanups: X) Do not hold reference to netdev from ipt_CLUSTER, instead subscribe to device events and look up for index from the packet path, this is fixing an issue that is present since the very beginning, patch from Xin Long. X) Use nf_register_net_hook() in ipt_CLUSTER, from Florian Westphal. X) Use ebt_invalid_target() whenever possible in the ebtables tree, from Gao Feng. X) Calm down compilation warning in nf_dup infrastructure, patch from stephen hemminger. X) Statify functions in nftables rt expression, also from stephen. X) Update Makefile to use canonical method to specify nf_tables-objs. From Jike Song. X) Use nf_conntrack_helpers_register() in amanda and H323. X) Space cleanup for ctnetlink, from linzhang. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents fcce2fd + 04ba724 commit 52a623b

37 files changed

+945
-494
lines changed

include/linux/netfilter/nfnetlink.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef _NFNETLINK_H
22
#define _NFNETLINK_H
33

4-
54
#include <linux/netlink.h>
65
#include <linux/capability.h>
76
#include <net/netlink.h>
@@ -10,13 +9,16 @@
109
struct nfnl_callback {
1110
int (*call)(struct net *net, struct sock *nl, struct sk_buff *skb,
1211
const struct nlmsghdr *nlh,
13-
const struct nlattr * const cda[]);
12+
const struct nlattr * const cda[],
13+
struct netlink_ext_ack *extack);
1414
int (*call_rcu)(struct net *net, struct sock *nl, struct sk_buff *skb,
1515
const struct nlmsghdr *nlh,
16-
const struct nlattr * const cda[]);
16+
const struct nlattr * const cda[],
17+
struct netlink_ext_ack *extack);
1718
int (*call_batch)(struct net *net, struct sock *nl, struct sk_buff *skb,
1819
const struct nlmsghdr *nlh,
19-
const struct nlattr * const cda[]);
20+
const struct nlattr * const cda[],
21+
struct netlink_ext_ack *extack);
2022
const struct nla_policy *policy; /* netlink attribute policy */
2123
const u_int16_t attr_count; /* number of nlattr's */
2224
};

include/linux/netfilter_bridge/ebtables.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ extern unsigned int ebt_do_table(struct sk_buff *skb,
122122
#define BASE_CHAIN (par->hook_mask & (1 << NF_BR_NUMHOOKS))
123123
/* Clear the bit in the hook mask that tells if the rule is on a base chain */
124124
#define CLEAR_BASE_CHAIN_BIT (par->hook_mask &= ~(1 << NF_BR_NUMHOOKS))
125-
/* True if the target is not a standard target */
126-
#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0)
127125

128126
static inline bool ebt_invalid_target(int target)
129127
{

include/net/net_namespace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ extern struct net init_net;
158158
struct net *copy_net_ns(unsigned long flags, struct user_namespace *user_ns,
159159
struct net *old_net);
160160

161+
void net_ns_barrier(void);
161162
#else /* CONFIG_NET_NS */
162163
#include <linux/sched.h>
163164
#include <linux/nsproxy.h>
@@ -168,6 +169,8 @@ static inline struct net *copy_net_ns(unsigned long flags,
168169
return ERR_PTR(-EINVAL);
169170
return old_net;
170171
}
172+
173+
static inline void net_ns_barrier(void) {}
171174
#endif /* CONFIG_NET_NS */
172175

173176

include/net/netfilter/nf_conntrack.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,13 @@ extern s32 (*nf_ct_nat_offset)(const struct nf_conn *ct,
225225
u32 seq);
226226

227227
/* Iterate over all conntracks: if iter returns true, it's deleted. */
228-
void nf_ct_iterate_cleanup(struct net *net,
229-
int (*iter)(struct nf_conn *i, void *data),
230-
void *data, u32 portid, int report);
228+
void nf_ct_iterate_cleanup_net(struct net *net,
229+
int (*iter)(struct nf_conn *i, void *data),
230+
void *data, u32 portid, int report);
231+
232+
/* also set unconfirmed conntracks as dying. Only use in module exit path. */
233+
void nf_ct_iterate_destroy(int (*iter)(struct nf_conn *i, void *data),
234+
void *data);
231235

232236
struct nf_conntrack_zone;
233237

include/net/netfilter/nf_conntrack_l3proto.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct nf_conntrack_l3proto {
7171
struct module *me;
7272
};
7373

74-
extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX];
74+
extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[NFPROTO_NUMPROTO];
7575

7676
#ifdef CONFIG_SYSCTL
7777
/* Protocol pernet registration. */
@@ -100,7 +100,7 @@ extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic;
100100
static inline struct nf_conntrack_l3proto *
101101
__nf_ct_l3proto_find(u_int16_t l3proto)
102102
{
103-
if (unlikely(l3proto >= AF_MAX))
103+
if (unlikely(l3proto >= NFPROTO_NUMPROTO))
104104
return &nf_conntrack_l3proto_generic;
105105
return rcu_dereference(nf_ct_l3protos[l3proto]);
106106
}

include/net/netfilter/nf_tables.h

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,23 @@ struct nft_set_estimate {
281281
enum nft_set_class space;
282282
};
283283

284+
/**
285+
* struct nft_set_type - nf_tables set type
286+
*
287+
* @select_ops: function to select nft_set_ops
288+
* @ops: default ops, used when no select_ops functions is present
289+
* @list: used internally
290+
* @owner: module reference
291+
*/
292+
struct nft_set_type {
293+
const struct nft_set_ops *(*select_ops)(const struct nft_ctx *,
294+
const struct nft_set_desc *desc,
295+
u32 flags);
296+
const struct nft_set_ops *ops;
297+
struct list_head list;
298+
struct module *owner;
299+
};
300+
284301
struct nft_set_ext;
285302
struct nft_expr;
286303

@@ -297,8 +314,6 @@ struct nft_expr;
297314
* @privsize: function to return size of set private data
298315
* @init: initialize private data of new set instance
299316
* @destroy: destroy private data of set instance
300-
* @list: nf_tables_set_ops list node
301-
* @owner: module reference
302317
* @elemsize: element private size
303318
* @features: features supported by the implementation
304319
*/
@@ -336,7 +351,8 @@ struct nft_set_ops {
336351
struct nft_set *set,
337352
struct nft_set_iter *iter);
338353

339-
unsigned int (*privsize)(const struct nlattr * const nla[]);
354+
unsigned int (*privsize)(const struct nlattr * const nla[],
355+
const struct nft_set_desc *desc);
340356
bool (*estimate)(const struct nft_set_desc *desc,
341357
u32 features,
342358
struct nft_set_estimate *est);
@@ -345,14 +361,13 @@ struct nft_set_ops {
345361
const struct nlattr * const nla[]);
346362
void (*destroy)(const struct nft_set *set);
347363

348-
struct list_head list;
349-
struct module *owner;
350364
unsigned int elemsize;
351365
u32 features;
366+
const struct nft_set_type *type;
352367
};
353368

354-
int nft_register_set(struct nft_set_ops *ops);
355-
void nft_unregister_set(struct nft_set_ops *ops);
369+
int nft_register_set(struct nft_set_type *type);
370+
void nft_unregister_set(struct nft_set_type *type);
356371

357372
/**
358373
* struct nft_set - nf_tables set instance

net/bridge/netfilter/ebt_dnat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int ebt_dnat_tg_check(const struct xt_tgchk_param *par)
6161
(strcmp(par->table, "broute") != 0 ||
6262
hook_mask & ~(1 << NF_BR_BROUTING)))
6363
return -EINVAL;
64-
if (INVALID_TARGET)
64+
if (ebt_invalid_target(info->target))
6565
return -EINVAL;
6666
return 0;
6767
}

net/bridge/netfilter/ebt_mark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static int ebt_mark_tg_check(const struct xt_tgchk_param *par)
4444
tmp = info->target | ~EBT_VERDICT_BITS;
4545
if (BASE_CHAIN && tmp == EBT_RETURN)
4646
return -EINVAL;
47-
if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
47+
if (ebt_invalid_target(tmp))
4848
return -EINVAL;
4949
tmp = info->target & ~EBT_VERDICT_BITS;
5050
if (tmp != MARK_SET_VALUE && tmp != MARK_OR_VALUE &&

net/bridge/netfilter/ebt_redirect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int ebt_redirect_tg_check(const struct xt_tgchk_param *par)
4747
(strcmp(par->table, "broute") != 0 ||
4848
hook_mask & ~(1 << NF_BR_BROUTING)))
4949
return -EINVAL;
50-
if (INVALID_TARGET)
50+
if (ebt_invalid_target(info->target))
5151
return -EINVAL;
5252
return 0;
5353
}

net/bridge/netfilter/ebt_snat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int ebt_snat_tg_check(const struct xt_tgchk_param *par)
5151
if (BASE_CHAIN && tmp == EBT_RETURN)
5252
return -EINVAL;
5353

54-
if (tmp < -NUM_STANDARD_TARGETS || tmp >= 0)
54+
if (ebt_invalid_target(tmp))
5555
return -EINVAL;
5656
tmp = info->target | EBT_VERDICT_BITS;
5757
if ((tmp & ~NAT_ARP_BIT) != ~NAT_ARP_BIT)

net/core/net_namespace.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,23 @@ static void cleanup_net(struct work_struct *work)
501501
net_drop_ns(net);
502502
}
503503
}
504+
505+
/**
506+
* net_ns_barrier - wait until concurrent net_cleanup_work is done
507+
*
508+
* cleanup_net runs from work queue and will first remove namespaces
509+
* from the global list, then run net exit functions.
510+
*
511+
* Call this in module exit path to make sure that all netns
512+
* ->exit ops have been invoked before the function is removed.
513+
*/
514+
void net_ns_barrier(void)
515+
{
516+
mutex_lock(&net_mutex);
517+
mutex_unlock(&net_mutex);
518+
}
519+
EXPORT_SYMBOL(net_ns_barrier);
520+
504521
static DECLARE_WORK(net_cleanup_work, cleanup_net);
505522

506523
void __put_net(struct net *net)

0 commit comments

Comments
 (0)