-
Notifications
You must be signed in to change notification settings - Fork 0
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/ipvs updates for net-next The following patchset contains Netfilter updates for your net-next tree, this includes the NAT redirection support for nf_tables, the cgroup support for nft meta and conntrack zone support for the connlimit match. Coming after those, a bunch of sparse warning fixes, missing netns bits and cleanups. More specifically, they are: 1) Prepare IPv4 and IPv6 NAT redirect code to use it from nf_tables, patches from Arturo Borrero. 2) Introduce the nf_tables redir expression, from Arturo Borrero. 3) Remove an unnecessary assignment in ip_vs_xmit/__ip_vs_get_out_rt(). Patch from Alex Gartrell. 4) Add nft_log_dereference() macro to the nf_log infrastructure, patch from Marcelo Leitner. 5) Add some extra validation when registering logger families, also from Marcelo. 6) Some spelling cleanups from stephen hemminger. 7) Fix sparse warning in nf_logger_find_get(). 8) Add cgroup support to nf_tables meta, patch from Ana Rey. 9) A Kconfig fix for the new redir expression and fix sparse warnings in the new redir expression. 10) Fix several sparse warnings in the netfilter tree, from Florian Westphal. 11) Reduce verbosity when OOM in nfnetlink_log. User can basically do nothing when this situation occurs. 12) Add conntrack zone support to xt_connlimit, again from Florian. 13) Add netnamespace support to the h323 conntrack helper, contributed by Vasily Averin. 14) Remove unnecessary nul-pointer checks before free_percpu() and module_put(), from Markus Elfring. 15) Use pr_fmt in nfnetlink_log, again patch from Marcelo Leitner. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
38 changed files
with
636 additions
and
156 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _NF_NAT_REDIRECT_IPV4_H_ | ||
#define _NF_NAT_REDIRECT_IPV4_H_ | ||
|
||
unsigned int | ||
nf_nat_redirect_ipv4(struct sk_buff *skb, | ||
const struct nf_nat_ipv4_multi_range_compat *mr, | ||
unsigned int hooknum); | ||
|
||
#endif /* _NF_NAT_REDIRECT_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,8 @@ | ||
#ifndef _NF_NAT_REDIRECT_IPV6_H_ | ||
#define _NF_NAT_REDIRECT_IPV6_H_ | ||
|
||
unsigned int | ||
nf_nat_redirect_ipv6(struct sk_buff *skb, const struct nf_nat_range *range, | ||
unsigned int hooknum); | ||
|
||
#endif /* _NF_NAT_REDIRECT_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef _NFT_REDIR_H_ | ||
#define _NFT_REDIR_H_ | ||
|
||
struct nft_redir { | ||
enum nft_registers sreg_proto_min:8; | ||
enum nft_registers sreg_proto_max:8; | ||
u16 flags; | ||
}; | ||
|
||
extern const struct nla_policy nft_redir_policy[]; | ||
|
||
int nft_redir_init(const struct nft_ctx *ctx, | ||
const struct nft_expr *expr, | ||
const struct nlattr * const tb[]); | ||
|
||
int nft_redir_dump(struct sk_buff *skb, const struct nft_expr *expr); | ||
|
||
int nft_redir_validate(const struct nft_ctx *ctx, const struct nft_expr *expr, | ||
const struct nft_data **data); | ||
|
||
#endif /* _NFT_REDIR_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* (C) 1999-2001 Paul `Rusty' Russell | ||
* (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org> | ||
* Copyright (c) 2011 Patrick McHardy <kaber@trash.net> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* Based on Rusty Russell's IPv4 REDIRECT target. Development of IPv6 | ||
* NAT funded by Astaro. | ||
*/ | ||
|
||
#include <linux/if.h> | ||
#include <linux/inetdevice.h> | ||
#include <linux/ip.h> | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/netdevice.h> | ||
#include <linux/netfilter.h> | ||
#include <linux/types.h> | ||
#include <linux/netfilter_ipv4.h> | ||
#include <linux/netfilter/x_tables.h> | ||
#include <net/addrconf.h> | ||
#include <net/checksum.h> | ||
#include <net/protocol.h> | ||
#include <net/netfilter/nf_nat.h> | ||
#include <net/netfilter/ipv4/nf_nat_redirect.h> | ||
|
||
unsigned int | ||
nf_nat_redirect_ipv4(struct sk_buff *skb, | ||
const struct nf_nat_ipv4_multi_range_compat *mr, | ||
unsigned int hooknum) | ||
{ | ||
struct nf_conn *ct; | ||
enum ip_conntrack_info ctinfo; | ||
__be32 newdst; | ||
struct nf_nat_range newrange; | ||
|
||
NF_CT_ASSERT(hooknum == NF_INET_PRE_ROUTING || | ||
hooknum == NF_INET_LOCAL_OUT); | ||
|
||
ct = nf_ct_get(skb, &ctinfo); | ||
NF_CT_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED)); | ||
|
||
/* Local packets: make them go to loopback */ | ||
if (hooknum == NF_INET_LOCAL_OUT) { | ||
newdst = htonl(0x7F000001); | ||
} else { | ||
struct in_device *indev; | ||
struct in_ifaddr *ifa; | ||
|
||
newdst = 0; | ||
|
||
rcu_read_lock(); | ||
indev = __in_dev_get_rcu(skb->dev); | ||
if (indev != NULL) { | ||
ifa = indev->ifa_list; | ||
newdst = ifa->ifa_local; | ||
} | ||
rcu_read_unlock(); | ||
|
||
if (!newdst) | ||
return NF_DROP; | ||
} | ||
|
||
/* Transfer from original range. */ | ||
memset(&newrange.min_addr, 0, sizeof(newrange.min_addr)); | ||
memset(&newrange.max_addr, 0, sizeof(newrange.max_addr)); | ||
newrange.flags = mr->range[0].flags | NF_NAT_RANGE_MAP_IPS; | ||
newrange.min_addr.ip = newdst; | ||
newrange.max_addr.ip = newdst; | ||
newrange.min_proto = mr->range[0].min; | ||
newrange.max_proto = mr->range[0].max; | ||
|
||
/* Hand modified range to generic setup. */ | ||
return nf_nat_setup_info(ct, &newrange, NF_NAT_MANIP_DST); | ||
} | ||
EXPORT_SYMBOL_GPL(nf_nat_redirect_ipv4); | ||
|
||
MODULE_LICENSE("GPL"); | ||
MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); |
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,77 @@ | ||
/* | ||
* Copyright (c) 2014 Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/init.h> | ||
#include <linux/module.h> | ||
#include <linux/netlink.h> | ||
#include <linux/netfilter.h> | ||
#include <linux/netfilter/nf_tables.h> | ||
#include <net/netfilter/nf_tables.h> | ||
#include <net/netfilter/nf_nat.h> | ||
#include <net/netfilter/ipv4/nf_nat_redirect.h> | ||
#include <net/netfilter/nft_redir.h> | ||
|
||
static void nft_redir_ipv4_eval(const struct nft_expr *expr, | ||
struct nft_data data[NFT_REG_MAX + 1], | ||
const struct nft_pktinfo *pkt) | ||
{ | ||
struct nft_redir *priv = nft_expr_priv(expr); | ||
struct nf_nat_ipv4_multi_range_compat mr; | ||
unsigned int verdict; | ||
|
||
memset(&mr, 0, sizeof(mr)); | ||
if (priv->sreg_proto_min) { | ||
mr.range[0].min.all = (__force __be16) | ||
data[priv->sreg_proto_min].data[0]; | ||
mr.range[0].max.all = (__force __be16) | ||
data[priv->sreg_proto_max].data[0]; | ||
mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED; | ||
} | ||
|
||
mr.range[0].flags |= priv->flags; | ||
|
||
verdict = nf_nat_redirect_ipv4(pkt->skb, &mr, pkt->ops->hooknum); | ||
data[NFT_REG_VERDICT].verdict = verdict; | ||
} | ||
|
||
static struct nft_expr_type nft_redir_ipv4_type; | ||
static const struct nft_expr_ops nft_redir_ipv4_ops = { | ||
.type = &nft_redir_ipv4_type, | ||
.size = NFT_EXPR_SIZE(sizeof(struct nft_redir)), | ||
.eval = nft_redir_ipv4_eval, | ||
.init = nft_redir_init, | ||
.dump = nft_redir_dump, | ||
.validate = nft_redir_validate, | ||
}; | ||
|
||
static struct nft_expr_type nft_redir_ipv4_type __read_mostly = { | ||
.family = NFPROTO_IPV4, | ||
.name = "redir", | ||
.ops = &nft_redir_ipv4_ops, | ||
.policy = nft_redir_policy, | ||
.maxattr = NFTA_REDIR_MAX, | ||
.owner = THIS_MODULE, | ||
}; | ||
|
||
static int __init nft_redir_ipv4_module_init(void) | ||
{ | ||
return nft_register_expr(&nft_redir_ipv4_type); | ||
} | ||
|
||
static void __exit nft_redir_ipv4_module_exit(void) | ||
{ | ||
nft_unregister_expr(&nft_redir_ipv4_type); | ||
} | ||
|
||
module_init(nft_redir_ipv4_module_init); | ||
module_exit(nft_redir_ipv4_module_exit); | ||
|
||
MODULE_LICENSE("GPL"); | ||
MODULE_AUTHOR("Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>"); | ||
MODULE_ALIAS_NFT_AF_EXPR(AF_INET, "redir"); |
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.