Skip to content

Commit 0aac383

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== nf-next pull request The following patchset contains Netfilter/IPVS updates for your net-next tree. Regarding nf_tables, most updates focus on consolidating the NAT infrastructure and adding support for masquerading. More specifically, they are: 1) use __u8 instead of u_int8_t in arptables header, from Mike Frysinger. 2) Add support to match by skb->pkttype to the meta expression, from Ana Rey. 3) Add support to match by cpu to the meta expression, also from Ana Rey. 4) A smatch warning about IPSET_ATTR_MARKMASK validation, patch from Vytas Dauksa. 5) Fix netnet and netportnet hash types the range support for IPv4, from Sergey Popovich. 6) Fix missing-field-initializer warnings resolved, from Mark Rustad. 7) Dan Carperter reported possible integer overflows in ipset, from Jozsef Kadlecsick. 8) Filter out accounting objects in nfacct by type, so you can selectively reset quotas, from Alexey Perevalov. 9) Move specific NAT IPv4 functions to the core so x_tables and nf_tables can share the same NAT IPv4 engine. 10) Use the new NAT IPv4 functions from nft_chain_nat_ipv4. 11) Move specific NAT IPv6 functions to the core so x_tables and nf_tables can share the same NAT IPv4 engine. 12) Use the new NAT IPv6 functions from nft_chain_nat_ipv6. 13) Refactor code to add nft_delrule(), which can be reused in the enhancement of the NFT_MSG_DELTABLE to remove a table and its content, from Arturo Borrero. 14) Add a helper function to unregister chain hooks, from Arturo Borrero. 15) A cleanup to rename to nft_delrule_by_chain for consistency with the new nft_*() functions, also from Arturo. 16) Add support to match devgroup to the meta expression, from Ana Rey. 17) Reduce stack usage for IPVS socket option, from Julian Anastasov. 18) Remove unnecessary textsearch state initialization in xt_string, from Bojan Prtvar. 19) Add several helper functions to nf_tables, more work to prepare the enhancement of NFT_MSG_DELTABLE, again from Arturo Borrero. 20) Enhance NFT_MSG_DELTABLE to delete a table and its content, from Arturo Borrero. 21) Support NAT flags in the nat expression to indicate the flavour, eg. random fully, from Arturo. 22) Add missing audit code to ebtables when replacing tables, from Nicolas Dichtel. 23) Generalize the IPv4 masquerading code to allow its re-use from nf_tables, from Arturo. 24) Generalize the IPv6 masquerading code, also from Arturo. 25) Add the new masq expression to support IPv4/IPv6 masquerading from nf_tables, also from Arturo. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents b167a37 + 9ba1f72 commit 0aac383

45 files changed

Lines changed: 1759 additions & 1070 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/ipset/ip_set_list.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66

77
#define IP_SET_LIST_DEFAULT_SIZE 8
88
#define IP_SET_LIST_MIN_SIZE 4
9+
#define IP_SET_LIST_MAX_SIZE 65536
910

1011
#endif /* __IP_SET_LIST_H */
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef _NF_NAT_MASQUERADE_IPV4_H_
2+
#define _NF_NAT_MASQUERADE_IPV4_H_
3+
4+
#include <net/netfilter/nf_nat.h>
5+
6+
unsigned int
7+
nf_nat_masquerade_ipv4(struct sk_buff *skb, unsigned int hooknum,
8+
const struct nf_nat_range *range,
9+
const struct net_device *out);
10+
11+
void nf_nat_masquerade_ipv4_register_notifier(void);
12+
void nf_nat_masquerade_ipv4_unregister_notifier(void);
13+
14+
#endif /*_NF_NAT_MASQUERADE_IPV4_H_ */
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef _NF_NAT_MASQUERADE_IPV6_H_
2+
#define _NF_NAT_MASQUERADE_IPV6_H_
3+
4+
unsigned int
5+
nf_nat_masquerade_ipv6(struct sk_buff *skb, const struct nf_nat_range *range,
6+
const struct net_device *out);
7+
void nf_nat_masquerade_ipv6_register_notifier(void);
8+
void nf_nat_masquerade_ipv6_unregister_notifier(void);
9+
10+
#endif /* _NF_NAT_MASQUERADE_IPV6_H_ */

‎include/net/netfilter/nf_nat_l3proto.h‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,83 @@ const struct nf_nat_l3proto *__nf_nat_l3proto_find(u8 l3proto);
4242
int nf_nat_icmp_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
4343
enum ip_conntrack_info ctinfo,
4444
unsigned int hooknum);
45+
46+
unsigned int nf_nat_ipv4_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
47+
const struct net_device *in,
48+
const struct net_device *out,
49+
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
50+
struct sk_buff *skb,
51+
const struct net_device *in,
52+
const struct net_device *out,
53+
struct nf_conn *ct));
54+
55+
unsigned int nf_nat_ipv4_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
56+
const struct net_device *in,
57+
const struct net_device *out,
58+
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
59+
struct sk_buff *skb,
60+
const struct net_device *in,
61+
const struct net_device *out,
62+
struct nf_conn *ct));
63+
64+
unsigned int nf_nat_ipv4_local_fn(const struct nf_hook_ops *ops,
65+
struct sk_buff *skb,
66+
const struct net_device *in,
67+
const struct net_device *out,
68+
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
69+
struct sk_buff *skb,
70+
const struct net_device *in,
71+
const struct net_device *out,
72+
struct nf_conn *ct));
73+
74+
unsigned int nf_nat_ipv4_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
75+
const struct net_device *in,
76+
const struct net_device *out,
77+
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
78+
struct sk_buff *skb,
79+
const struct net_device *in,
80+
const struct net_device *out,
81+
struct nf_conn *ct));
82+
4583
int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, struct nf_conn *ct,
4684
enum ip_conntrack_info ctinfo,
4785
unsigned int hooknum, unsigned int hdrlen);
4886

87+
unsigned int nf_nat_ipv6_in(const struct nf_hook_ops *ops, struct sk_buff *skb,
88+
const struct net_device *in,
89+
const struct net_device *out,
90+
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
91+
struct sk_buff *skb,
92+
const struct net_device *in,
93+
const struct net_device *out,
94+
struct nf_conn *ct));
95+
96+
unsigned int nf_nat_ipv6_out(const struct nf_hook_ops *ops, struct sk_buff *skb,
97+
const struct net_device *in,
98+
const struct net_device *out,
99+
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
100+
struct sk_buff *skb,
101+
const struct net_device *in,
102+
const struct net_device *out,
103+
struct nf_conn *ct));
104+
105+
unsigned int nf_nat_ipv6_local_fn(const struct nf_hook_ops *ops,
106+
struct sk_buff *skb,
107+
const struct net_device *in,
108+
const struct net_device *out,
109+
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
110+
struct sk_buff *skb,
111+
const struct net_device *in,
112+
const struct net_device *out,
113+
struct nf_conn *ct));
114+
115+
unsigned int nf_nat_ipv6_fn(const struct nf_hook_ops *ops, struct sk_buff *skb,
116+
const struct net_device *in,
117+
const struct net_device *out,
118+
unsigned int (*do_chain)(const struct nf_hook_ops *ops,
119+
struct sk_buff *skb,
120+
const struct net_device *in,
121+
const struct net_device *out,
122+
struct nf_conn *ct));
123+
49124
#endif /* _NF_NAT_L3PROTO_H */

‎include/net/netfilter/nft_masq.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef _NFT_MASQ_H_
2+
#define _NFT_MASQ_H_
3+
4+
struct nft_masq {
5+
u32 flags;
6+
};
7+
8+
extern const struct nla_policy nft_masq_policy[];
9+
10+
int nft_masq_init(const struct nft_ctx *ctx,
11+
const struct nft_expr *expr,
12+
const struct nlattr * const tb[]);
13+
14+
int nft_masq_dump(struct sk_buff *skb, const struct nft_expr *expr);
15+
16+
#endif /* _NFT_MASQ_H_ */

‎include/uapi/linux/netfilter/nf_nat.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
#define NF_NAT_RANGE_PROTO_RANDOM_ALL \
1414
(NF_NAT_RANGE_PROTO_RANDOM | NF_NAT_RANGE_PROTO_RANDOM_FULLY)
1515

16+
#define NF_NAT_RANGE_MASK \
17+
(NF_NAT_RANGE_MAP_IPS | NF_NAT_RANGE_PROTO_SPECIFIED | \
18+
NF_NAT_RANGE_PROTO_RANDOM | NF_NAT_RANGE_PERSISTENT | \
19+
NF_NAT_RANGE_PROTO_RANDOM_FULLY)
20+
1621
struct nf_nat_ipv4_range {
1722
unsigned int flags;
1823
__be32 min_ip;

‎include/uapi/linux/netfilter/nf_tables.h‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ enum nft_exthdr_attributes {
571571
* @NFT_META_L4PROTO: layer 4 protocol number
572572
* @NFT_META_BRI_IIFNAME: packet input bridge interface name
573573
* @NFT_META_BRI_OIFNAME: packet output bridge interface name
574+
* @NFT_META_PKTTYPE: packet type (skb->pkt_type), special handling for loopback
575+
* @NFT_META_CPU: cpu id through smp_processor_id()
576+
* @NFT_META_IIFGROUP: packet input interface group
577+
* @NFT_META_OIFGROUP: packet output interface group
574578
*/
575579
enum nft_meta_keys {
576580
NFT_META_LEN,
@@ -592,6 +596,10 @@ enum nft_meta_keys {
592596
NFT_META_L4PROTO,
593597
NFT_META_BRI_IIFNAME,
594598
NFT_META_BRI_OIFNAME,
599+
NFT_META_PKTTYPE,
600+
NFT_META_CPU,
601+
NFT_META_IIFGROUP,
602+
NFT_META_OIFGROUP,
595603
};
596604

597605
/**
@@ -777,6 +785,7 @@ enum nft_nat_types {
777785
* @NFTA_NAT_REG_ADDR_MAX: source register of address range end (NLA_U32: nft_registers)
778786
* @NFTA_NAT_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers)
779787
* @NFTA_NAT_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers)
788+
* @NFTA_NAT_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
780789
*/
781790
enum nft_nat_attributes {
782791
NFTA_NAT_UNSPEC,
@@ -786,8 +795,20 @@ enum nft_nat_attributes {
786795
NFTA_NAT_REG_ADDR_MAX,
787796
NFTA_NAT_REG_PROTO_MIN,
788797
NFTA_NAT_REG_PROTO_MAX,
798+
NFTA_NAT_FLAGS,
789799
__NFTA_NAT_MAX
790800
};
791801
#define NFTA_NAT_MAX (__NFTA_NAT_MAX - 1)
792802

803+
/**
804+
* enum nft_masq_attributes - nf_tables masquerade expression attributes
805+
*
806+
* @NFTA_MASQ_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32)
807+
*/
808+
enum nft_masq_attributes {
809+
NFTA_MASQ_FLAGS,
810+
__NFTA_MASQ_MAX
811+
};
812+
#define NFTA_MASQ_MAX (__NFTA_MASQ_MAX - 1)
813+
793814
#endif /* _LINUX_NF_TABLES_H */

‎include/uapi/linux/netfilter/nfnetlink_acct.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ enum nfnl_acct_type {
2828
NFACCT_USE,
2929
NFACCT_FLAGS,
3030
NFACCT_QUOTA,
31+
NFACCT_FILTER,
3132
__NFACCT_MAX
3233
};
3334
#define NFACCT_MAX (__NFACCT_MAX - 1)
3435

36+
enum nfnl_attr_filter_type {
37+
NFACCT_FILTER_UNSPEC,
38+
NFACCT_FILTER_MASK,
39+
NFACCT_FILTER_VALUE,
40+
__NFACCT_FILTER_MAX
41+
};
42+
#define NFACCT_FILTER_MAX (__NFACCT_FILTER_MAX - 1)
3543

3644
#endif /* _UAPI_NFNL_ACCT_H_ */

‎include/uapi/linux/netfilter_arp/arpt_mangle.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct arpt_mangle
1313
union {
1414
struct in_addr tgt_ip;
1515
} u_t;
16-
u_int8_t flags;
16+
__u8 flags;
1717
int target;
1818
};
1919

‎net/bridge/netfilter/ebtables.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <asm/uaccess.h>
2727
#include <linux/smp.h>
2828
#include <linux/cpumask.h>
29+
#include <linux/audit.h>
2930
#include <net/sock.h>
3031
/* needed for logical [in,out]-dev filtering */
3132
#include "../br_private.h"
@@ -1058,6 +1059,20 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
10581059
vfree(table);
10591060

10601061
vfree(counterstmp);
1062+
1063+
#ifdef CONFIG_AUDIT
1064+
if (audit_enabled) {
1065+
struct audit_buffer *ab;
1066+
1067+
ab = audit_log_start(current->audit_context, GFP_KERNEL,
1068+
AUDIT_NETFILTER_CFG);
1069+
if (ab) {
1070+
audit_log_format(ab, "table=%s family=%u entries=%u",
1071+
repl->name, AF_BRIDGE, repl->nentries);
1072+
audit_log_end(ab);
1073+
}
1074+
}
1075+
#endif
10611076
return ret;
10621077

10631078
free_unlock:

0 commit comments

Comments
 (0)