forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== Netfilter updates for net-next This is second pull request includes the conflict resolution patch that resulted from the updates that we got for the conntrack template through kmalloc. No changes with regards to the previously sent 15 patches. The following patchset contains Netfilter updates for your net-next tree, they are: 1) Rework the existing nf_tables counter expression to make it per-cpu. 2) Prepare and factor out common packet duplication code from the TEE target so it can be reused from the new dup expression. 3) Add the new dup expression for the nf_tables IPv4 and IPv6 families. 4) Convert the nf_tables limit expression to use a token-based approach with 64-bits precision. 5) Enhance the nf_tables limit expression to support limiting at packet byte. This comes after several preparation patches. 6) Add a burst parameter to indicate the amount of packets or bytes that can exceed the limiting. 7) Add netns support to nfacct, from Andreas Schultz. 8) Pass the nf_conn_zone structure instead of the zone ID in nf_tables to allow accessing more zone specific information, from Daniel Borkmann. 9) Allow to define zone per-direction to support netns containers with overlapping network addressing, also from Daniel. 10) Extend the CT target to allow setting the zone based on the skb->mark as a way to support simple mappings from iptables, also from Daniel. 11) Make the nf_tables payload expression aware of the fact that VLAN offload may have removed a vlan header, from Florian Westphal. ==================== Signed-off-by: David S. Miller <[email protected]>
- Loading branch information
Showing
44 changed files
with
1,319 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef _NF_DUP_IPV4_H_ | ||
#define _NF_DUP_IPV4_H_ | ||
|
||
void nf_dup_ipv4(struct sk_buff *skb, unsigned int hooknum, | ||
const struct in_addr *gw, int oif); | ||
|
||
#endif /* _NF_DUP_IPV4_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef _NF_DUP_IPV6_H_ | ||
#define _NF_DUP_IPV6_H_ | ||
|
||
void nf_dup_ipv6(struct sk_buff *skb, unsigned int hooknum, | ||
const struct in6_addr *gw, int oif); | ||
|
||
#endif /* _NF_DUP_IPV6_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,106 @@ | ||
#ifndef _NF_CONNTRACK_ZONES_H | ||
#define _NF_CONNTRACK_ZONES_H | ||
|
||
#define NF_CT_DEFAULT_ZONE 0 | ||
#include <linux/netfilter/nf_conntrack_tuple_common.h> | ||
|
||
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
#include <net/netfilter/nf_conntrack_extend.h> | ||
#define NF_CT_DEFAULT_ZONE_ID 0 | ||
|
||
#define NF_CT_ZONE_DIR_ORIG (1 << IP_CT_DIR_ORIGINAL) | ||
#define NF_CT_ZONE_DIR_REPL (1 << IP_CT_DIR_REPLY) | ||
|
||
#define NF_CT_DEFAULT_ZONE_DIR (NF_CT_ZONE_DIR_ORIG | NF_CT_ZONE_DIR_REPL) | ||
|
||
#define NF_CT_FLAG_MARK 1 | ||
|
||
struct nf_conntrack_zone { | ||
u16 id; | ||
u8 flags; | ||
u8 dir; | ||
}; | ||
|
||
static inline u16 nf_ct_zone(const struct nf_conn *ct) | ||
extern const struct nf_conntrack_zone nf_ct_zone_dflt; | ||
|
||
#if IS_ENABLED(CONFIG_NF_CONNTRACK) | ||
#include <net/netfilter/nf_conntrack_extend.h> | ||
|
||
static inline const struct nf_conntrack_zone * | ||
nf_ct_zone(const struct nf_conn *ct) | ||
{ | ||
const struct nf_conntrack_zone *nf_ct_zone = NULL; | ||
|
||
#ifdef CONFIG_NF_CONNTRACK_ZONES | ||
struct nf_conntrack_zone *nf_ct_zone; | ||
nf_ct_zone = nf_ct_ext_find(ct, NF_CT_EXT_ZONE); | ||
if (nf_ct_zone) | ||
return nf_ct_zone->id; | ||
#endif | ||
return NF_CT_DEFAULT_ZONE; | ||
return nf_ct_zone ? nf_ct_zone : &nf_ct_zone_dflt; | ||
} | ||
|
||
static inline const struct nf_conntrack_zone * | ||
nf_ct_zone_init(struct nf_conntrack_zone *zone, u16 id, u8 dir, u8 flags) | ||
{ | ||
zone->id = id; | ||
zone->flags = flags; | ||
zone->dir = dir; | ||
|
||
return zone; | ||
} | ||
|
||
static inline const struct nf_conntrack_zone * | ||
nf_ct_zone_tmpl(const struct nf_conn *tmpl, const struct sk_buff *skb, | ||
struct nf_conntrack_zone *tmp) | ||
{ | ||
const struct nf_conntrack_zone *zone; | ||
|
||
if (!tmpl) | ||
return &nf_ct_zone_dflt; | ||
|
||
zone = nf_ct_zone(tmpl); | ||
if (zone->flags & NF_CT_FLAG_MARK) | ||
zone = nf_ct_zone_init(tmp, skb->mark, zone->dir, 0); | ||
|
||
return zone; | ||
} | ||
|
||
static inline int nf_ct_zone_add(struct nf_conn *ct, gfp_t flags, | ||
const struct nf_conntrack_zone *info) | ||
{ | ||
#ifdef CONFIG_NF_CONNTRACK_ZONES | ||
struct nf_conntrack_zone *nf_ct_zone; | ||
|
||
nf_ct_zone = nf_ct_ext_add(ct, NF_CT_EXT_ZONE, flags); | ||
if (!nf_ct_zone) | ||
return -ENOMEM; | ||
|
||
nf_ct_zone_init(nf_ct_zone, info->id, info->dir, | ||
info->flags); | ||
#endif | ||
return 0; | ||
} | ||
|
||
#endif /* CONFIG_NF_CONNTRACK || CONFIG_NF_CONNTRACK_MODULE */ | ||
static inline bool nf_ct_zone_matches_dir(const struct nf_conntrack_zone *zone, | ||
enum ip_conntrack_dir dir) | ||
{ | ||
return zone->dir & (1 << dir); | ||
} | ||
|
||
static inline u16 nf_ct_zone_id(const struct nf_conntrack_zone *zone, | ||
enum ip_conntrack_dir dir) | ||
{ | ||
return nf_ct_zone_matches_dir(zone, dir) ? | ||
zone->id : NF_CT_DEFAULT_ZONE_ID; | ||
} | ||
|
||
static inline bool nf_ct_zone_equal(const struct nf_conn *a, | ||
const struct nf_conntrack_zone *b, | ||
enum ip_conntrack_dir dir) | ||
{ | ||
return nf_ct_zone_id(nf_ct_zone(a), dir) == | ||
nf_ct_zone_id(b, dir); | ||
} | ||
|
||
static inline bool nf_ct_zone_equal_any(const struct nf_conn *a, | ||
const struct nf_conntrack_zone *b) | ||
{ | ||
return nf_ct_zone(a)->id == b->id; | ||
} | ||
#endif /* IS_ENABLED(CONFIG_NF_CONNTRACK) */ | ||
#endif /* _NF_CONNTRACK_ZONES_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _NFT_DUP_H_ | ||
#define _NFT_DUP_H_ | ||
|
||
struct nft_dup_inet { | ||
enum nft_registers sreg_addr:8; | ||
enum nft_registers sreg_dev:8; | ||
}; | ||
|
||
#endif /* _NFT_DUP_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.