netfilter/ipvs updates for net-next
Subsystems (5)
Pablo Neira Ayuso
maintainercover netfilter/ipvs updates for net-next
Hi David,
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.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Thanks!
----------------------------------------------------------------
The following changes since commit b8901ac319768cdd3afa060787503e0c405f9607:
ipx: remove __inline__ in c file on static (2014-10-27 16:25:31 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git master
for you to fetch changes up to beacd3e8ef237e077c8707395440813feef16d3f:
netfilter: nfnetlink_log: Make use of pr_fmt where applicable (2014-11-20 14:09:01 +0100)
----------------------------------------------------------------
Alex Gartrell (1):
ipvs: remove unnecessary assignment in __ip_vs_get_out_rt
Ana Rey (1):
netfilter: nft_meta: add cgroup support
Arturo Borrero (3):
netfilter: refactor NAT redirect IPv4 to use it from nf_tables
netfilter: refactor NAT redirect IPv6 code to use it from nf_tables
netfilter: nf_tables: add new expression nft_redir
Florian Westphal (2):
netfilter: fix various sparse warnings
netfilter: xt_connlimit: honor conntrack zone if available
Marcelo Leitner (3):
netfilter: nf_log: Introduce nft_log_dereference() macro
netfilter: log: protect nf_log_register against double registering
netfilter: nfnetlink_log: Make use of pr_fmt where applicable
Markus Elfring (1):
netfilter: Deletion of unnecessary checks before two function calls
Pablo Neira Ayuso (5):
Merge branch 'ipvs-next'
netfilter: nf_log: fix sparse warning in nf_logger_find_get()
netfilter: fix unmet dependencies in NETFILTER_XT_TARGET_REDIRECT
netfilter: nft_redir: fix sparse warnings
netfilter: nfnetlink_log: remove unnecessary error messages
Vasily Averin (1):
netfilter: nf_conntrack_h323: lookup route from proper net namespace
stephen hemminger (1):
netfilter: fix spelling errors
include/net/netfilter/ipv4/nf_nat_redirect.h | 9 +++ include/net/netfilter/ipv6/nf_nat_redirect.h | 8 +++ include/net/netfilter/nft_redir.h | 21 ++++++ include/uapi/linux/netfilter/nf_tables.h | 18 +++++ net/bridge/br_netfilter.c | 1 + net/ipv4/netfilter/Kconfig | 15 ++++ net/ipv4/netfilter/Makefile | 2 + net/ipv4/netfilter/nf_log_arp.c | 24 +++++-- net/ipv4/netfilter/nf_log_ipv4.c | 12 +++- net/ipv4/netfilter/nf_nat_redirect_ipv4.c | 82 +++++++++++++++++++++ net/ipv4/netfilter/nf_reject_ipv4.c | 1 + net/ipv4/netfilter/nft_redir_ipv4.c | 77 ++++++++++++++++++++ net/ipv4/netfilter/nft_reject_ipv4.c | 7 +- net/ipv6/netfilter/Kconfig | 15 ++++ net/ipv6/netfilter/Makefile | 2 + net/ipv6/netfilter/nf_log_ipv6.c | 12 +++- net/ipv6/netfilter/nf_nat_redirect_ipv6.c | 75 +++++++++++++++++++ net/ipv6/netfilter/nf_reject_ipv6.c | 1 + net/ipv6/netfilter/nft_redir_ipv6.c | 77 ++++++++++++++++++++ net/ipv6/netfilter/nft_reject_ipv6.c | 7 +- net/netfilter/Kconfig | 11 +++ net/netfilter/Makefile | 1 + net/netfilter/core.c | 1 + net/netfilter/ipvs/ip_vs_ctl.c | 3 +- net/netfilter/ipvs/ip_vs_pe.c | 3 +- net/netfilter/ipvs/ip_vs_sched.c | 3 +- net/netfilter/ipvs/ip_vs_sync.c | 3 +- net/netfilter/ipvs/ip_vs_xmit.c | 1 - net/netfilter/nf_conntrack_h323_main.c | 14 ++-- net/netfilter/nf_conntrack_helper.c | 2 +- net/netfilter/nf_log.c | 40 ++++++----- net/netfilter/nf_tables_api.c | 5 +- net/netfilter/nfnetlink_log.c | 18 +++-- net/netfilter/nft_meta.c | 7 ++ net/netfilter/nft_redir.c | 99 ++++++++++++++++++++++++++ net/netfilter/xt_DSCP.c | 6 +- net/netfilter/xt_REDIRECT.c | 84 ++-------------------- net/netfilter/xt_connlimit.c | 25 ++++--- 38 files changed, 636 insertions(+), 156 deletions(-) create mode 100644 include/net/netfilter/ipv4/nf_nat_redirect.h create mode 100644 include/net/netfilter/ipv6/nf_nat_redirect.h create mode 100644 include/net/netfilter/nft_redir.h create mode 100644 net/ipv4/netfilter/nf_nat_redirect_ipv4.c create mode 100644 net/ipv4/netfilter/nft_redir_ipv4.c create mode 100644 net/ipv6/netfilter/nf_nat_redirect_ipv6.c create mode 100644 net/ipv6/netfilter/nft_redir_ipv6.c create mode 100644 net/netfilter/nft_redir.c
Pablo Neira Ayuso
maintainerPATCH 1/17 netfilter: refactor NAT redirect IPv4 to use it from nf_tables
From: Arturo Borrero <[email protected]>
This patch refactors the IPv4 code so it can be usable both from xt and nf_tables.
A similar patch follows-up to handle IPv6.
--- include/net/netfilter/ipv4/nf_nat_redirect.h | 9 +++ net/ipv4/netfilter/Kconfig | 6 ++ net/ipv4/netfilter/Makefile | 1 + net/ipv4/netfilter/nf_nat_redirect_ipv4.c | 82 ++++++++++++++++++++++++++ net/netfilter/Kconfig | 1 + net/netfilter/xt_REDIRECT.c | 44 +------------- 6 files changed, 101 insertions(+), 42 deletions(-) create mode 100644 include/net/netfilter/ipv4/nf_nat_redirect.h create mode 100644 net/ipv4/netfilter/nf_nat_redirect_ipv4.c
include/net/netfilter/ipv4/nf_nat_redirect.h new file +9 -0
@@ -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_ */
net/ipv4/netfilter/Kconfig +6 -0
@@ -104,6 +104,12 @@ config NF_NAT_MASQUERADE_IPV4 This is the kernel functionality to provide NAT in the masquerade flavour (automatic source address selection). +config NF_NAT_REDIRECT_IPV4 + tristate "IPv4 redirect support" + help + This is the kernel functionality to provide NAT in the redirect + flavour (redirect packets to local machine). + config NFT_MASQ_IPV4 tristate "IPv4 masquerading support for nf_tables" depends on NF_TABLES_IPV4
net/ipv4/netfilter/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o obj-$(CONFIG_NF_NAT_SNMP_BASIC) += nf_nat_snmp_basic.o obj-$(CONFIG_NF_NAT_MASQUERADE_IPV4) += nf_nat_masquerade_ipv4.o +obj-$(CONFIG_NF_NAT_REDIRECT_IPV4) += nf_nat_redirect_ipv4.o # NAT protocols (nf_nat) obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o
net/ipv4/netfilter/nf_nat_redirect_ipv4.c new file +82 -0
82 lines not on this page · raw message
net/netfilter/Kconfig +1 -0
@@ -835,6 +835,7 @@ config NETFILTER_XT_TARGET_RATEEST config NETFILTER_XT_TARGET_REDIRECT tristate "REDIRECT target support" depends on NF_NAT + select NF_NAT_REDIRECT_IPV4 ---help--- REDIRECT is a special case of NAT: all incoming connections are mapped onto the incoming interface's address, causing the packets to
net/netfilter/xt_REDIRECT.c +2 -42
56 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 2/17 netfilter: refactor NAT redirect IPv6 code to use it from nf_tables
In reply to Pablo Neira AyusoFrom: Arturo Borrero <[email protected]>
This patch refactors the IPv6 code so it can be usable both from xt and nf_tables.
--- include/net/netfilter/ipv6/nf_nat_redirect.h | 8 +++ net/ipv6/netfilter/Kconfig | 6 +++ net/ipv6/netfilter/Makefile | 1 + net/ipv6/netfilter/nf_nat_redirect_ipv6.c | 75 ++++++++++++++++++++++++++ net/netfilter/Kconfig | 1 + net/netfilter/xt_REDIRECT.c | 40 +------------- 6 files changed, 93 insertions(+), 38 deletions(-) create mode 100644 include/net/netfilter/ipv6/nf_nat_redirect.h create mode 100644 net/ipv6/netfilter/nf_nat_redirect_ipv6.c
include/net/netfilter/ipv6/nf_nat_redirect.h new file +8 -0
@@ -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_ */
net/ipv6/netfilter/Kconfig +6 -0
@@ -82,6 +82,12 @@ config NF_NAT_MASQUERADE_IPV6 This is the kernel functionality to provide NAT in the masquerade flavour (automatic source address selection) for IPv6. +config NF_NAT_REDIRECT_IPV6 + tristate "IPv6 redirect support" + help + This is the kernel functionality to provide NAT in the redirect + flavour (redirect packet to local machine) for IPv6. + config NFT_MASQ_IPV6 tristate "IPv6 masquerade support for nf_tables" depends on NF_TABLES_IPV6
net/ipv6/netfilter/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_NF_CONNTRACK_IPV6) += nf_conntrack_ipv6.o nf_nat_ipv6-y := nf_nat_l3proto_ipv6.o nf_nat_proto_icmpv6.o obj-$(CONFIG_NF_NAT_IPV6) += nf_nat_ipv6.o obj-$(CONFIG_NF_NAT_MASQUERADE_IPV6) += nf_nat_masquerade_ipv6.o +obj-$(CONFIG_NF_NAT_REDIRECT_IPV6) += nf_nat_redirect_ipv6.o # defrag nf_defrag_ipv6-y := nf_defrag_ipv6_hooks.o nf_conntrack_reasm.o
net/ipv6/netfilter/nf_nat_redirect_ipv6.c new file +75 -0
75 lines not on this page · raw message
net/netfilter/Kconfig +1 -0
@@ -836,6 +836,7 @@ config NETFILTER_XT_TARGET_REDIRECT tristate "REDIRECT target support" depends on NF_NAT select NF_NAT_REDIRECT_IPV4 + select NF_NAT_REDIRECT_IPV6 if IP6_NF_IPTABLES ---help--- REDIRECT is a special case of NAT: all incoming connections are mapped onto the incoming interface's address, causing the packets to
net/netfilter/xt_REDIRECT.c +2 -38
@@ -27,48 +27,12 @@#include <net/protocol.h> #include <net/netfilter/nf_nat.h> #include <net/netfilter/ipv4/nf_nat_redirect.h> - -static const struct in6_addr loopback_addr =IN6ADDR_LOOPBACK_INIT ; +#include <net/netfilter/ipv6/nf_nat_redirect.h> static unsigned int redirect_tg6 (struct sk_buff *skb,const struct xt_action_param *par) { -const struct nf_nat_range *range = par->targinfo; -struct nf_nat_range newrange; -struct in6_addr newdst; -enum ip_conntrack_info ctinfo; -struct nf_conn *ct; - - ct =nf_ct_get (skb, &ctinfo); -if (par->hooknum ==NF_INET_LOCAL_OUT ) - newdst = loopback_addr; -else { -struct inet6_dev *idev; -struct inet6_ifaddr *ifa; -bool addr = false; - -rcu_read_lock (); - idev =__in6_dev_get (skb->dev); -if (idev !=NULL ) { -list_for_each_entry (ifa, &idev->addr_list, if_list) { - newdst = ifa->addr; - addr = true; -break ; - } - } -rcu_read_unlock (); - -if (!addr) -return NF_DROP ; - } - - newrange.flags = range->flags |NF_NAT_RANGE_MAP_IPS ; - newrange.min_addr.in6 = newdst; - newrange.max_addr.in6 = newdst; - newrange.min_proto = range->min_proto; - newrange.max_proto = range->max_proto; - -return nf_nat_setup_info (ct, &newrange,NF_NAT_MANIP_DST ); +return nf_nat_redirect_ipv6 (skb, par->targinfo, par->hooknum); }static int redirect_tg6_checkentry (const struct xt_tgchk_param *par)
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 3/17 netfilter: nf_tables: add new expression nft_redir
In reply to Pablo Neira AyusoFrom: Arturo Borrero <[email protected]>
This new expression provides NAT in the redirect flavour, which is to redirect packets to local machine.
--- include/net/netfilter/nft_redir.h | 21 +++++++ include/uapi/linux/netfilter/nf_tables.h | 16 +++++ net/ipv4/netfilter/Kconfig | 9 +++ net/ipv4/netfilter/Makefile | 1 + net/ipv4/netfilter/nft_redir_ipv4.c | 77 +++++++++++++++++++++++ net/ipv6/netfilter/Kconfig | 9 +++ net/ipv6/netfilter/Makefile | 1 + net/ipv6/netfilter/nft_redir_ipv6.c | 77 +++++++++++++++++++++++ net/netfilter/Kconfig | 9 +++ net/netfilter/Makefile | 1 + net/netfilter/nft_redir.c | 98 ++++++++++++++++++++++++++++++ 11 files changed, 319 insertions(+) create mode 100644 include/net/netfilter/nft_redir.h create mode 100644 net/ipv4/netfilter/nft_redir_ipv4.c create mode 100644 net/ipv6/netfilter/nft_redir_ipv6.c create mode 100644 net/netfilter/nft_redir.c
include/net/netfilter/nft_redir.h new file +21 -0
@@ -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_ */
include/uapi/linux/netfilter/nf_tables.h +16 -0
@@ -838,6 +838,22 @@ enum nft_masq_attributes {#define NFTA_MASQ_MAX (__NFTA_MASQ_MAX - 1)/** +* enum nft_redir_attributes - nf_tables redirect expression netlink attributes +* +* @NFTA_REDIR_REG_PROTO_MIN: source register of proto range start (NLA_U32: nft_registers) +* @NFTA_REDIR_REG_PROTO_MAX: source register of proto range end (NLA_U32: nft_registers) +* @NFTA_REDIR_FLAGS: NAT flags (see NF_NAT_RANGE_* in linux/netfilter/nf_nat.h) (NLA_U32) +*/ +enum nft_redir_attributes { +NFTA_REDIR_UNSPEC , +NFTA_REDIR_REG_PROTO_MIN , +NFTA_REDIR_REG_PROTO_MAX , +NFTA_REDIR_FLAGS , + __NFTA_REDIR_MAX +}; +#define NFTA_REDIR_MAX (__NFTA_REDIR_MAX - 1) + +/** * enum nft_gen_attributes - nf_tables ruleset generation attributes * * @NFTA_GEN_ID: Ruleset generation ID (NLA_U32)
net/ipv4/netfilter/Kconfig +9 -0
@@ -119,6 +119,15 @@ config NFT_MASQ_IPV4 This is the expression that provides IPv4 masquerading support for nf_tables. +config NFT_REDIR_IPV4 + tristate "IPv4 redirect support for nf_tables" + depends on NF_TABLES_IPV4 + depends on NFT_REDIR + select NF_NAT_REDIRECT_IPV4 + help + This is the expression that provides IPv4 redirect support for + nf_tables. + config NF_NAT_SNMP_BASIC tristate "Basic SNMP-ALG support" depends on NF_CONNTRACK_SNMP
net/ipv4/netfilter/Makefile +1 -0
@@ -41,6 +41,7 @@ obj-$(CONFIG_NFT_CHAIN_ROUTE_IPV4) += nft_chain_route_ipv4.o obj-$(CONFIG_NFT_CHAIN_NAT_IPV4) += nft_chain_nat_ipv4.o obj-$(CONFIG_NFT_REJECT_IPV4) += nft_reject_ipv4.o obj-$(CONFIG_NFT_MASQ_IPV4) += nft_masq_ipv4.o +obj-$(CONFIG_NFT_REDIR_IPV4) += nft_redir_ipv4.o obj-$(CONFIG_NF_TABLES_ARP) += nf_tables_arp.o # generic IP tables
net/ipv4/netfilter/nft_redir_ipv4.c new file +77 -0
77 lines not on this page · raw message
net/ipv6/netfilter/Kconfig +9 -0
@@ -97,6 +97,15 @@ config NFT_MASQ_IPV6 This is the expression that provides IPv4 masquerading support for nf_tables. +config NFT_REDIR_IPV6 + tristate "IPv6 redirect support for nf_tables" + depends on NF_TABLES_IPV6 + depends on NFT_REDIR + select NF_NAT_REDIRECT_IPV6 + help + This is the expression that provides IPv4 redirect support for + nf_tables. + endif # NF_NAT_IPV6 config IP6_NF_IPTABLES
net/ipv6/netfilter/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_NFT_CHAIN_ROUTE_IPV6) += nft_chain_route_ipv6.o obj-$(CONFIG_NFT_CHAIN_NAT_IPV6) += nft_chain_nat_ipv6.o obj-$(CONFIG_NFT_REJECT_IPV6) += nft_reject_ipv6.o obj-$(CONFIG_NFT_MASQ_IPV6) += nft_masq_ipv6.o +obj-$(CONFIG_NFT_REDIR_IPV6) += nft_redir_ipv6.o # matches obj-$(CONFIG_IP6_NF_MATCH_AH) += ip6t_ah.o
net/ipv6/netfilter/nft_redir_ipv6.c new file +77 -0
77 lines not on this page · raw message
net/netfilter/Kconfig +9 -0
@@ -505,6 +505,15 @@ config NFT_MASQ This option adds the "masquerade" expression that you can use to perform NAT in the masquerade flavour. +config NFT_REDIR + depends on NF_TABLES + depends on NF_CONNTRACK + depends on NF_NAT + tristate "Netfilter nf_tables redirect support" + help + This options adds the "redirect" expression that you can use + to perform NAT in the redirect flavour. + config NFT_NAT depends on NF_TABLES depends on NF_CONNTRACK
net/netfilter/Makefile +1 -0
@@ -88,6 +88,7 @@ obj-$(CONFIG_NFT_HASH) += nft_hash.o obj-$(CONFIG_NFT_COUNTER) += nft_counter.o obj-$(CONFIG_NFT_LOG) += nft_log.o obj-$(CONFIG_NFT_MASQ) += nft_masq.o +obj-$(CONFIG_NFT_REDIR) += nft_redir.o # generic X tables obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o
net/netfilter/nft_redir.c new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 5/17 netfilter: nf_log: Introduce nft_log_dereference() macro
In reply to Pablo Neira AyusoFrom: Marcelo Leitner <[email protected]>
Wrap up a common call pattern in an easier to handle call.
--- net/netfilter/nf_log.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
net/netfilter/nf_log.c +9 -12
@@ -19,6 +19,9 @@static struct nf_logger __rcu *loggers[NFPROTO_NUMPROTO ][NF_LOG_TYPE_MAX ]__read_mostly ;static DEFINE_MUTEX (nf_log_mutex); +#define nft_log_dereference (logger) \ + rcu_dereference_protected(logger, lockdep_is_held(&nf_log_mutex)) +static struct nf_logger *__find_logger (int pf,const char *str_logger) {struct nf_logger *log;
@@ -28,8 +31,7 @@ static struct nf_logger *__find_logger(int pf, const char *str_logger)if (loggers[pf][i] ==NULL )continue ; - log =rcu_dereference_protected (loggers[pf][i], -lockdep_is_held (&nf_log_mutex)); + log =nft_log_dereference (loggers[pf][i]);if (!strncasecmp (str_logger, log->name,strlen (log->name)))return log; }
@@ -45,8 +47,7 @@ void nf_log_set(struct net *net, u_int8_t pf, const struct nf_logger *logger)return ;mutex_lock (&nf_log_mutex); - log =rcu_dereference_protected (net->nf.nf_loggers[pf], -lockdep_is_held (&nf_log_mutex)); + log =nft_log_dereference (net->nf.nf_loggers[pf]);if (log ==NULL )rcu_assign_pointer (net->nf.nf_loggers[pf], logger);
@@ -61,8 +62,7 @@ void nf_log_unset(struct net *net, const struct nf_logger *logger)mutex_lock (&nf_log_mutex);for (i =0 ; i <NFPROTO_NUMPROTO ; i++) { - log =rcu_dereference_protected (net->nf.nf_loggers[i], -lockdep_is_held (&nf_log_mutex)); + log =nft_log_dereference (net->nf.nf_loggers[i]);if (log == logger)RCU_INIT_POINTER (net->nf.nf_loggers[i],NULL ); }
@@ -297,8 +297,7 @@ static int seq_show(struct seq_file *s, void *v)int i, ret;struct net *net =seq_file_net (s); - logger =rcu_dereference_protected (net->nf.nf_loggers[*pos], -lockdep_is_held (&nf_log_mutex)); + logger =nft_log_dereference (net->nf.nf_loggers[*pos]);if (!logger) ret =seq_printf (s,"%2lld NONE (" , *pos);
@@ -312,8 +311,7 @@ static int seq_show(struct seq_file *s, void *v)if (loggers[*pos][i] ==NULL )continue ; - logger =rcu_dereference_protected (loggers[*pos][i], -lockdep_is_held (&nf_log_mutex)); + logger =nft_log_dereference (loggers[*pos][i]); ret =seq_printf (s,"%s" , logger->name);if (ret <0 )return ret;
@@ -385,8 +383,7 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,mutex_unlock (&nf_log_mutex); }else {mutex_lock (&nf_log_mutex); - logger =rcu_dereference_protected (net->nf.nf_loggers[tindex], -lockdep_is_held (&nf_log_mutex)); + logger =nft_log_dereference (net->nf.nf_loggers[tindex]);if (!logger) table->data ="NONE" ;else
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 4/17 ipvs: remove unnecessary assignment in __ip_vs_get_out_rt
In reply to Pablo Neira AyusoFrom: Alex Gartrell <[email protected]>
It is a precondition of the function that daddr be equal to dest->addr.ip if dest is non-NULL, so this additional assignment is just confusing for stupid engineers like me.
--- net/netfilter/ipvs/ip_vs_xmit.c | 1 - 1 file changed, 1 deletion(-)
net/netfilter/ipvs/ip_vs_xmit.c +0 -1
@@ -293,7 +293,6 @@ __ip_vs_get_out_rt(int skb_af, struct sk_buff *skb, struct ip_vs_dest *dest, &dest->addr.ip, &dest_dst->dst_saddr.ip, atomic_read(&rt->dst.__refcnt)); } - daddr = dest->addr.ip;if (ret_saddr) *ret_saddr = dest_dst->dst_saddr.ip; }else {
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 6/17 netfilter: log: protect nf_log_register against double registering
In reply to Pablo Neira AyusoFrom: Marcelo Leitner <[email protected]>
Currently, despite the comment right before the function, nf_log_register allows registering two loggers on with the same type and end up overwriting the previous register.
Not a real issue today as current tree doesn't have two loggers for the same type but it's better to get this protected.
Also make sure that all of its callers do error checking.
--- net/ipv4/netfilter/nf_log_arp.c | 12 +++++++++++- net/ipv4/netfilter/nf_log_ipv4.c | 12 +++++++++++- net/ipv6/netfilter/nf_log_ipv6.c | 12 +++++++++++- net/netfilter/nf_log.c | 16 +++++++++++++--- 4 files changed, 46 insertions(+), 6 deletions(-)
net/ipv4/netfilter/nf_log_arp.c +11 -1
@@ -10,6 +10,7 @@* it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/module.h> #include <linux/spinlock.h>
@@ -130,8 +131,17 @@ static int __init nf_log_arp_init(void)if (ret <0 )return ret; -nf_log_register (NFPROTO_ARP , &nf_arp_logger); + ret =nf_log_register (NFPROTO_ARP , &nf_arp_logger); +if (ret <0 ) { +pr_err ("failed to register logger\n" ); + goto err1; + } +return 0 ; + +err1: +unregister_pernet_subsys (&nf_log_arp_net_ops); +return ret; } static void __exit nf_log_arp_exit(void)
net/ipv4/netfilter/nf_log_ipv4.c +11 -1
@@ -5,6 +5,7 @@* it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/module.h> #include <linux/spinlock.h>
@@ -366,8 +367,17 @@ static int __init nf_log_ipv4_init(void)if (ret <0 )return ret; -nf_log_register (NFPROTO_IPV4 , &nf_ip_logger); + ret =nf_log_register (NFPROTO_IPV4 , &nf_ip_logger); +if (ret <0 ) { +pr_err ("failed to register logger\n" ); + goto err1; + } +return 0 ; + +err1: +unregister_pernet_subsys (&nf_log_ipv4_net_ops); +return ret; } static void __exit nf_log_ipv4_exit(void)
net/ipv6/netfilter/nf_log_ipv6.c +11 -1
@@ -5,6 +5,7 @@* it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/module.h> #include <linux/spinlock.h>
@@ -398,8 +399,17 @@ static int __init nf_log_ipv6_init(void)if (ret <0 )return ret; -nf_log_register (NFPROTO_IPV6 , &nf_ip6_logger); + ret =nf_log_register (NFPROTO_IPV6 , &nf_ip6_logger); +if (ret <0 ) { +pr_err ("failed to register logger\n" ); + goto err1; + } +return 0 ; + +err1: +unregister_pernet_subsys (&nf_log_ipv6_net_ops); +return ret; } static void __exit nf_log_ipv6_exit(void)
net/netfilter/nf_log.c +13 -3
@@ -75,6 +75,7 @@ EXPORT_SYMBOL(nf_log_unset);int nf_log_register (u_int8_t pf,struct nf_logger *logger) {int i; +int ret =0 ;if (pf >=ARRAY_SIZE (init_net.nf.nf_loggers))return -EINVAL ;
@@ -82,16 +83,25 @@ int nf_log_register(u_int8_t pf, struct nf_logger *logger)mutex_lock (&nf_log_mutex);if (pf ==NFPROTO_UNSPEC ) { +for (i =NFPROTO_UNSPEC ; i <NFPROTO_NUMPROTO ; i++) { +if (rcu_access_pointer (loggers[i][logger->type])) { + ret = -EEXIST ; + goto unlock; + } + }for (i =NFPROTO_UNSPEC ; i <NFPROTO_NUMPROTO ; i++)rcu_assign_pointer (loggers[i][logger->type], logger); }else { -/* register at end of list to honor first register win */ +if (rcu_access_pointer (loggers[pf][logger->type])) { + ret = -EEXIST ; + goto unlock; + }rcu_assign_pointer (loggers[pf][logger->type], logger); } +unlock:mutex_unlock (&nf_log_mutex); - -return 0 ; +return ret; }EXPORT_SYMBOL (nf_log_register);
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 7/17 netfilter: fix spelling errors
In reply to Pablo Neira AyusoFrom: stephen hemminger <[email protected]>
--- net/netfilter/nf_conntrack_helper.c | 2 +- net/netfilter/nf_tables_api.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_helper.c +1 -1
@@ -250,7 +250,7 @@ out: }EXPORT_SYMBOL_GPL (__nf_ct_try_assign_helper); -/* appropiate ct lock protecting must be taken by caller */ +/* appropriate ct lock protecting must be taken by caller */ static inline int unhelp (struct nf_conntrack_tuple_hash *i,const struct nf_conntrack_helper *me) {
net/netfilter/nf_tables_api.c +1 -1
@@ -2477,7 +2477,7 @@ static int nf_tables_getset(struct sock *nlsk, struct sk_buff *skb,const struct nfgenmsg *nfmsg =nlmsg_data (nlh);int err; -/* Verify existance before starting dump */ +/* Verify existence before starting dump */ err =nft_ctx_init_from_setattr (&ctx, skb, nlh, nla);if (err <0 )return err;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 8/17 netfilter: nf_log: fix sparse warning in nf_logger_find_get()
In reply to Pablo Neira Ayusonet/netfilter/nf_log.c:157:16: warning: incorrect type in assignment (different address spaces)net/netfilter/nf_log.c:157:16: expected struct nf_logger *loggernet/netfilter/nf_log.c:157:16: got struct nf_logger [noderef] <asn:4>*<noident>
--- net/netfilter/nf_log.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/netfilter/nf_log.c +1 -2
@@ -154,8 +154,7 @@ int nf_logger_find_get(int pf, enum nf_log_type type)struct nf_logger *logger;int ret = -ENOENT ; - logger = loggers[pf][type]; -if (logger ==NULL ) +if (rcu_access_pointer (loggers[pf][type]) ==NULL )request_module ("nf-logger-%u-%u" , pf, type);rcu_read_lock ();
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 9/17 netfilter: nft_meta: add cgroup support
In reply to Pablo Neira AyusoFrom: Ana Rey <[email protected]>
This allows you to filter traffic by process control group (cgroup).
--- include/uapi/linux/netfilter/nf_tables.h | 2 ++ net/netfilter/nft_meta.c | 7 +++++++ 2 files changed, 9 insertions(+)
include/uapi/linux/netfilter/nf_tables.h +2 -0
@@ -579,6 +579,7 @@ enum nft_exthdr_attributes {* @NFT_META_CPU: cpu id through smp_processor_id() * @NFT_META_IIFGROUP: packet input interface group * @NFT_META_OIFGROUP: packet output interface group +* @NFT_META_CGROUP: socket control group (skb->sk->sk_classid) */ enum nft_meta_keys {NFT_META_LEN ,
@@ -604,6 +605,7 @@ enum nft_meta_keys {NFT_META_CPU ,NFT_META_IIFGROUP ,NFT_META_OIFGROUP , + NFT_META_CGROUP, };/**
net/netfilter/nft_meta.c +7 -0
@@ -165,6 +165,12 @@ void nft_meta_get_eval(const struct nft_expr *expr, goto err; dest->data[0 ] = out->group;break ; +case NFT_META_CGROUP : +if (skb->sk ==NULL ) +break ; + + dest->data[0 ] = skb->sk->sk_classid; +break ;default :WARN_ON (1 ); goto err;
@@ -240,6 +246,7 @@ int nft_meta_get_init(const struct nft_ctx *ctx,case NFT_META_CPU :case NFT_META_IIFGROUP :case NFT_META_OIFGROUP : +case NFT_META_CGROUP :break ;default :return -EOPNOTSUPP ;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 10/17 netfilter: fix unmet dependencies in NETFILTER_XT_TARGET_REDIRECT
In reply to Pablo Neira Ayusowarning: (NETFILTER_XT_TARGET_REDIRECT) selects NF_NAT_REDIRECT_IPV4 which has unmet direct dependencies (NET && INET && NETFILTER && NF_NAT_IPV4)
warning: (NETFILTER_XT_TARGET_REDIRECT) selects NF_NAT_REDIRECT_IPV6 which has unmet direct dependencies (NET && INET && IPV6 && NETFILTER && NF_NAT_IPV6)
--- net/netfilter/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/Kconfig +2 -2
@@ -844,8 +844,8 @@ config NETFILTER_XT_TARGET_RATEEST config NETFILTER_XT_TARGET_REDIRECT tristate "REDIRECT target support" depends on NF_NAT - select NF_NAT_REDIRECT_IPV4 - select NF_NAT_REDIRECT_IPV6 if IP6_NF_IPTABLES + select NF_NAT_REDIRECT_IPV4 if NF_NAT_IPV4 + select NF_NAT_REDIRECT_IPV6 if NF_NAT_IPV6 ---help--- REDIRECT is a special case of NAT: all incoming connections are mapped onto the incoming interface's address, causing the packets to
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 11/17 netfilter: nft_redir: fix sparse warnings
In reply to Pablo Neira AyusoQuoted 1 line
Quoted 1 line
net/netfilter/nft_redir.c:39:26: sparse: incorrect type in assignment (different base types)
net/netfilter/nft_redir.c:39:26: expected unsigned int [unsigned] [usertype] nla_be32
net/netfilter/nft_redir.c:39:26: got restricted __be32
Quoted 7 lines
Quoted 7 lines
net/netfilter/nft_redir.c:40:40: sparse: cast to restricted__be32net/netfilter/nft_redir.c:40:40: sparse: cast to restricted__be32net/netfilter/nft_redir.c:40:40: sparse: cast to restricted__be32net/netfilter/nft_redir.c:40:40: sparse: cast to restricted__be32net/netfilter/nft_redir.c:40:40: sparse: cast to restricted__be32net/netfilter/nft_redir.c:40:40: sparse: cast to restricted__be32net/netfilter/nft_redir.c:46:34: sparse: incorrect type in assignment (different base types)
net/netfilter/nft_redir.c:46:34: expected unsigned int [unsigned] [usertype] nla_be32
net/netfilter/nft_redir.c:46:34: got restricted __be32
Quoted 6 lines
Quoted 6 lines
net/netfilter/nft_redir.c:47:48: sparse: cast to restricted__be32net/netfilter/nft_redir.c:47:48: sparse: cast to restricted__be32net/netfilter/nft_redir.c:47:48: sparse: cast to restricted__be32net/netfilter/nft_redir.c:47:48: sparse: cast to restricted__be32net/netfilter/nft_redir.c:47:48: sparse: cast to restricted__be32net/netfilter/nft_redir.c:47:48: sparse: cast to restricted__be32
--- net/netfilter/nft_redir.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/netfilter/nft_redir.c +6 -5
@@ -28,7 +28,6 @@ int nft_redir_init(const struct nft_ctx *ctx, const struct nlattr * const tb[]) {struct nft_redir *priv =nft_expr_priv (expr); -u32 nla_be32;int err; err =nft_chain_validate_dependency (ctx->chain,NFT_CHAIN_T_NAT );
@@ -36,15 +35,17 @@ int nft_redir_init(const struct nft_ctx *ctx,return err;if (tb[NFTA_REDIR_REG_PROTO_MIN ]) { - nla_be32 =nla_get_be32 (tb[NFTA_REDIR_REG_PROTO_MIN ]); - priv->sreg_proto_min =ntohl (nla_be32); + priv->sreg_proto_min = +ntohl (nla_get_be32 (tb[NFTA_REDIR_REG_PROTO_MIN ])); + err =nft_validate_input_register (priv->sreg_proto_min);if (err <0 )return err;if (tb[NFTA_REDIR_REG_PROTO_MAX ]) { - nla_be32 =nla_get_be32 (tb[NFTA_REDIR_REG_PROTO_MAX ]); - priv->sreg_proto_max =ntohl (nla_be32); + priv->sreg_proto_max = +ntohl (nla_get_be32 (tb[NFTA_REDIR_REG_PROTO_MAX ])); + err =nft_validate_input_register (priv->sreg_proto_max);if (err <0 )return err;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 12/17 netfilter: fix various sparse warnings
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
net/bridge/br_netfilter.c:870:6: symbol 'br_netfilter_enable' was not declared. Should it be static?
no; add includenet/ipv4/netfilter/nft_reject_ipv4.c:22:6: symbol 'nft_reject_ipv4_eval' was not declared. Should it be static?
yesnet/ipv6/netfilter/nf_reject_ipv6.c:16:6: symbol 'nf_send_reset6' was not declared. Should it be static?
no; add includenet/ipv6/netfilter/nft_reject_ipv6.c:22:6: symbol 'nft_reject_ipv6_eval' was not declared. Should it be static?
yesnet/netfilter/core.c:33:32: symbol 'nf_ipv6_ops' was not declared. Should it be static?
no; add includenet/netfilter/xt_DSCP.c:40:57: cast truncates bits from constant value (ffffff03 becomes 3) net/netfilter/xt_DSCP.c:57:59: cast truncates bits from constant value (ffffff03 becomes 3)
add __force, 3 is what we want.net/ipv4/netfilter/nf_log_arp.c:77:6: symbol 'nf_log_arp_packet' was not declared. Should it be static?
yesnet/ipv4/netfilter/nf_reject_ipv4.c:17:6: symbol 'nf_send_reset' was not declared. Should it be static?
no; add include
--- net/bridge/br_netfilter.c | 1 + net/ipv4/netfilter/nf_log_arp.c | 12 ++++++------ net/ipv4/netfilter/nf_reject_ipv4.c | 1 + net/ipv4/netfilter/nft_reject_ipv4.c | 7 +++---- net/ipv6/netfilter/nf_reject_ipv6.c | 1 + net/ipv6/netfilter/nft_reject_ipv6.c | 7 +++---- net/netfilter/core.c | 1 + net/netfilter/xt_DSCP.c | 6 ++++-- 8 files changed, 20 insertions(+), 16 deletions(-)
net/bridge/br_netfilter.c +1 -0
@@ -35,6 +35,7 @@#include <net/ip.h> #include <net/ipv6.h> #include <net/route.h> +#include <net/netfilter/br_netfilter.h> #include <asm/uaccess.h> #include "br_private.h"
net/ipv4/netfilter/nf_log_arp.c +6 -6
@@ -75,12 +75,12 @@ static void dump_arp_packet(struct nf_log_buf *m, ap->mac_src, ap->ip_src, ap->mac_dst, ap->ip_dst); } -void nf_log_arp_packet (struct net *net,u_int8_t pf, -unsigned int hooknum,const struct sk_buff *skb, -const struct net_device *in, -const struct net_device *out, -const struct nf_loginfo *loginfo, -const char *prefix) +static void nf_log_arp_packet (struct net *net,u_int8_t pf, +unsigned int hooknum,const struct sk_buff *skb, +const struct net_device *in, +const struct net_device *out, +const struct nf_loginfo *loginfo, +const char *prefix) {struct nf_log_buf *m;
net/ipv4/netfilter/nf_reject_ipv4.c +1 -0
@@ -11,6 +11,7 @@#include <net/tcp.h> #include <net/route.h> #include <net/dst.h> +#include <net/netfilter/ipv4/nf_reject.h> #include <linux/netfilter_ipv4.h> /* Send RST reply */
net/ipv4/netfilter/nft_reject_ipv4.c +3 -4
@@ -19,9 +19,9 @@#include <net/netfilter/ipv4/nf_reject.h> #include <net/netfilter/nft_reject.h> -void nft_reject_ipv4_eval (const struct nft_expr *expr, -struct nft_data data[NFT_REG_MAX +1 ], -const struct nft_pktinfo *pkt) +static void nft_reject_ipv4_eval (const struct nft_expr *expr, +struct nft_data data[NFT_REG_MAX +1 ], +const struct nft_pktinfo *pkt) {struct nft_reject *priv =nft_expr_priv (expr);
@@ -36,7 +36,6 @@ void nft_reject_ipv4_eval(const struct nft_expr *expr, data[NFT_REG_VERDICT ].verdict =NF_DROP ; } -EXPORT_SYMBOL_GPL (nft_reject_ipv4_eval);static struct nft_expr_type nft_reject_ipv4_type;static const struct nft_expr_ops nft_reject_ipv4_ops = {
net/ipv6/netfilter/nf_reject_ipv6.c +1 -0
@@ -11,6 +11,7 @@#include <net/ip6_route.h> #include <net/ip6_fib.h> #include <net/ip6_checksum.h> +#include <net/netfilter/ipv6/nf_reject.h> #include <linux/netfilter_ipv6.h> void nf_send_reset6 (struct net *net,struct sk_buff *oldskb,int hook)
net/ipv6/netfilter/nft_reject_ipv6.c +3 -4
@@ -19,9 +19,9 @@#include <net/netfilter/nft_reject.h> #include <net/netfilter/ipv6/nf_reject.h> -void nft_reject_ipv6_eval (const struct nft_expr *expr, -struct nft_data data[NFT_REG_MAX +1 ], -const struct nft_pktinfo *pkt) +static void nft_reject_ipv6_eval (const struct nft_expr *expr, +struct nft_data data[NFT_REG_MAX +1 ], +const struct nft_pktinfo *pkt) {struct nft_reject *priv =nft_expr_priv (expr);struct net *net =dev_net ((pkt->in !=NULL ) ? pkt->in : pkt->out);
@@ -38,7 +38,6 @@ void nft_reject_ipv6_eval(const struct nft_expr *expr, data[NFT_REG_VERDICT ].verdict =NF_DROP ; } -EXPORT_SYMBOL_GPL (nft_reject_ipv6_eval);static struct nft_expr_type nft_reject_ipv6_type;static const struct nft_expr_ops nft_reject_ipv6_ops = {
net/netfilter/core.c +1 -0
@@ -17,6 +17,7 @@#include <linux/interrupt.h> #include <linux/if.h> #include <linux/netdevice.h> +#include <linux/netfilter_ipv6.h> #include <linux/inetdevice.h> #include <linux/proc_fs.h> #include <linux/mutex.h>
net/netfilter/xt_DSCP.c +4 -2
@@ -37,7 +37,8 @@ dscp_tg(struct sk_buff *skb, const struct xt_action_param *par)if (!skb_make_writable (skb,sizeof (struct iphdr )))return NF_DROP ; -ipv4_change_dsfield (ip_hdr (skb), (__u8)(~XT_DSCP_MASK ), +ipv4_change_dsfield (ip_hdr (skb), + (__force __u8)(~XT_DSCP_MASK ), dinfo->dscp <<XT_DSCP_SHIFT ); }
@@ -54,7 +55,8 @@ dscp_tg6(struct sk_buff *skb, const struct xt_action_param *par)if (!skb_make_writable (skb,sizeof (struct ipv6hdr )))return NF_DROP ; -ipv6_change_dsfield (ipv6_hdr (skb), (__u8)(~XT_DSCP_MASK ), +ipv6_change_dsfield (ipv6_hdr (skb), + (__force __u8)(~XT_DSCP_MASK ), dinfo->dscp <<XT_DSCP_SHIFT ); }return XT_CONTINUE ;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 13/17 netfilter: nfnetlink_log: remove unnecessary error messages
In reply to Pablo Neira AyusoIn case of OOM, there's nothing userspace can do.
If there's no room to put the payload in __build_packet_message(), jump to nla_put_failure which already performs the corresponding error reporting.
--- net/netfilter/nfnetlink_log.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
net/netfilter/nfnetlink_log.c +2 -7
@@ -334,9 +334,6 @@ nfulnl_alloc_skb(struct net *net, u32 peer_portid, unsigned int inst_size, skb =nfnetlink_alloc_skb (net, pkt_size, peer_portid,GFP_ATOMIC ); -if (!skb) -pr_err ("nfnetlink_log: can't even alloc %u bytes\n" , - pkt_size); } }
@@ -568,10 +565,8 @@ __build_packet_message(struct nfnl_log_net *log,struct nlattr *nla;int size =nla_attr_size (data_len); -if (skb_tailroom (inst->skb) <nla_total_size (data_len)) { -printk (KERN_WARNING "nfnetlink_log: no tailroom!\n" ); -return -1 ; - } +if (skb_tailroom (inst->skb) <nla_total_size (data_len)) + goto nla_put_failure; nla = (struct nlattr *)skb_put (inst->skb,nla_total_size (data_len)); nla->nla_type =NFULA_PAYLOAD ;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 14/17 netfilter: xt_connlimit: honor conntrack zone if available
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
Currently all the conntrack lookups are done using default zone. In case the skb has a ct attached (e.g. template) we should use this zone for lookups instead. This makes connlimit work with connections assigned to other zones.
--- net/netfilter/xt_connlimit.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
net/netfilter/xt_connlimit.c +14 -11
@@ -134,6 +134,7 @@ static bool add_hlist(struct hlist_head *head,static unsigned int check_hlist (struct net *net,struct hlist_head *head,const struct nf_conntrack_tuple *tuple, +u16 zone,bool *addit) {const struct nf_conntrack_tuple_hash *found;
@@ -147,8 +148,7 @@ static unsigned int check_hlist(struct net *net,/* check the saved connections */ hlist_for_each_entry_safe (conn, n, head, node) { - found =nf_conntrack_find_get (net,NF_CT_DEFAULT_ZONE , - &conn->tuple); + found =nf_conntrack_find_get (net, zone, &conn->tuple);if (found ==NULL ) {hlist_del (&conn->node);kmem_cache_free (connlimit_conn_cachep, conn);
@@ -201,7 +201,7 @@ static unsigned int count_tree(struct net *net, struct rb_root *root, const struct nf_conntrack_tuple *tuple, const union nf_inet_addr *addr, const union nf_inet_addr *mask, - u8 family) + u8 family, u16 zone) { struct xt_connlimit_rb *gc_nodes[CONNLIMIT_GC_MAX_NODES];struct rb_node **rbnode, *parent;
@@ -229,7 +229,7 @@ count_tree(struct net *net, struct rb_root *root, }else {/* same source network -> be counted! */ unsigned int count; - count =check_hlist (net, &rbconn->hhead, tuple, &addit); + count =check_hlist (net, &rbconn->hhead, tuple, zone, &addit);tree_nodes_free (root, gc_nodes, gc_count);if (!addit)
@@ -245,7 +245,7 @@ count_tree(struct net *net, struct rb_root *root,continue ;/* only used for GC on hhead, retval and 'addit' ignored */ -check_hlist (net, &rbconn->hhead, tuple, &addit); +check_hlist (net, &rbconn->hhead, tuple, zone, &addit);if (hlist_empty (&rbconn->hhead)) gc_nodes[gc_count++] = rbconn; }
@@ -290,7 +290,7 @@ static int count_them(struct net *net,const struct nf_conntrack_tuple *tuple, const union nf_inet_addr *addr, const union nf_inet_addr *mask, - u_int8_t family) + u_int8_t family, u16 zone) { struct rb_root *root;int count;
@@ -306,7 +306,7 @@ static int count_them(struct net *net,spin_lock_bh (&xt_connlimit_locks[hash %CONNLIMIT_LOCK_SLOTS ]); - count =count_tree (net, root, tuple, addr, mask, family); + count =count_tree (net, root, tuple, addr, mask, family, zone);spin_unlock_bh (&xt_connlimit_locks[hash %CONNLIMIT_LOCK_SLOTS ]);
@@ -324,13 +324,16 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)enum ip_conntrack_info ctinfo;const struct nf_conn *ct;unsigned int connections; +u16 zone =NF_CT_DEFAULT_ZONE ; ct =nf_ct_get (skb, &ctinfo); -if (ct !=NULL ) +if (ct !=NULL ) { tuple_ptr = &ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple; -else if (!nf_ct_get_tuplepr (skb,skb_network_offset (skb), - par->family, &tuple)) + zone =nf_ct_zone (ct); + }else if (!nf_ct_get_tuplepr (skb,skb_network_offset (skb), + par->family, &tuple)) { goto hotdrop; + }if (par->family ==NFPROTO_IPV6 ) {const struct ipv6hdr *iph =ipv6_hdr (skb);
@@ -343,7 +346,7 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par) } connections =count_them (net, info->data, tuple_ptr, &addr, - &info->mask, par->family); + &info->mask, par->family, zone);if (connections ==0 )/* kmalloc failed, drop it entirely */ goto hotdrop;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 15/17 netfilter: nf_conntrack_h323: lookup route from proper net namespace
In reply to Pablo Neira AyusoFrom: Vasily Averin <[email protected]>
--- net/netfilter/nf_conntrack_h323_main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
net/netfilter/nf_conntrack_h323_main.c +8 -6
@@ -728,7 +728,8 @@ static int expect_h245(struct sk_buff *skb, struct nf_conn *ct,/* If the calling party is on the same side of the forward-to party, * we don't need to track the second call */ -static int callforward_do_filter (const union nf_inet_addr *src, +static int callforward_do_filter (struct net *net, +const union nf_inet_addr *src,const union nf_inet_addr *dst,u_int8_t family) {
@@ -750,9 +751,9 @@ static int callforward_do_filter(const union nf_inet_addr *src,memset (&fl2,0 ,sizeof (fl2)); fl2.daddr = dst->ip; -if (!afinfo->route (&init_net, (struct dst_entry **)&rt1, +if (!afinfo->route (net, (struct dst_entry **)&rt1,flowi4_to_flowi (&fl1), false)) { -if (!afinfo->route (&init_net, (struct dst_entry **)&rt2, +if (!afinfo->route (net, (struct dst_entry **)&rt2,flowi4_to_flowi (&fl2), false)) { if (rt_nexthop(rt1, fl1.daddr) == rt_nexthop(rt2, fl2.daddr) &&
@@ -774,9 +775,9 @@ static int callforward_do_filter(const union nf_inet_addr *src,memset (&fl2,0 ,sizeof (fl2)); fl2.daddr = dst->in6; -if (!afinfo->route (&init_net, (struct dst_entry **)&rt1, +if (!afinfo->route (net, (struct dst_entry **)&rt1,flowi6_to_flowi (&fl1), false)) { -if (!afinfo->route (&init_net, (struct dst_entry **)&rt2, +if (!afinfo->route (net, (struct dst_entry **)&rt2,flowi6_to_flowi (&fl2), false)) { if (ipv6_addr_equal(rt6_nexthop(rt1), rt6_nexthop(rt2)) &&
@@ -807,6 +808,7 @@ static int expect_callforwarding(struct sk_buff *skb,__be16 port;union nf_inet_addr addr;struct nf_conntrack_expect *exp; +struct net *net =nf_ct_net (ct);typeof (nat_callforwarding_hook) nat_callforwarding;/* Read alternativeAddress */
@@ -816,7 +818,7 @@ static int expect_callforwarding(struct sk_buff *skb,/* If the calling party is on the same side of the forward-to party, * we don't need to track the second call */ if (callforward_filter && -callforward_do_filter (&addr, &ct->tuplehash[!dir].tuple.src.u3, +callforward_do_filter (net, &addr, &ct->tuplehash[!dir].tuple.src.u3,nf_ct_l3num (ct))) {pr_debug ("nf_ct_q931: Call Forwarding not tracked\n" );return 0 ;
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 16/17 netfilter: Deletion of unnecessary checks before two function calls
In reply to Pablo Neira AyusoFrom: Markus Elfring <[email protected]>
The functions free_percpu() and module_put() test whether their argument is NULL and then return immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- net/netfilter/ipvs/ip_vs_ctl.c | 3 +-- net/netfilter/ipvs/ip_vs_pe.c | 3 +-- net/netfilter/ipvs/ip_vs_sched.c | 3 +-- net/netfilter/ipvs/ip_vs_sync.c | 3 +-- net/netfilter/nf_tables_api.c | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-)
net/netfilter/ipvs/ip_vs_ctl.c +1 -2
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)static void ip_vs_service_free (struct ip_vs_service *svc) { -if (svc->stats.cpustats) -free_percpu (svc->stats.cpustats); +free_percpu (svc->stats.cpustats);kfree (svc); }
net/netfilter/ipvs/ip_vs_pe.c +1 -2
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)rcu_read_unlock ();return pe; } -if (pe->module) -module_put (pe->module); +module_put (pe->module); }rcu_read_unlock ();
net/netfilter/ipvs/ip_vs_sched.c +1 -2
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)mutex_unlock (&ip_vs_sched_mutex);return sched; } -if (sched->module) -module_put (sched->module); +module_put (sched->module); }mutex_unlock (&ip_vs_sched_mutex);
net/netfilter/ipvs/ip_vs_sync.c +1 -2
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc, p->pe_data =kmemdup (pe_data, pe_data_len,GFP_ATOMIC );if (!p->pe_data) { -if (p->pe->module) -module_put (p->pe->module); +module_put (p->pe->module);return -ENOMEM ; } p->pe_data_len = pe_data_len;
net/netfilter/nf_tables_api.c +1 -2
@@ -3674,8 +3674,7 @@ static int nf_tables_abort(struct sk_buff *skb)break ;case NFT_MSG_NEWCHAIN :if (nft_trans_chain_update (trans)) { -if (nft_trans_chain_stats (trans)) -free_percpu (nft_trans_chain_stats (trans)); +free_percpu (nft_trans_chain_stats (trans));nft_trans_destroy (trans); }else {
Signature · 1 line
1.7.10.4
Pablo Neira Ayuso
maintainerPATCH 17/17 netfilter: nfnetlink_log: Make use of pr_fmt where applicable
In reply to Pablo Neira AyusoFrom: Marcelo Leitner <[email protected]>
--- net/netfilter/nfnetlink_log.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/netfilter/nfnetlink_log.c +6 -3
@@ -12,6 +12,9 @@* it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/module.h> #include <linux/skbuff.h> #include <linux/if_arp.h>
@@ -1063,19 +1066,19 @@ static int __init nfnetlink_log_init(void)netlink_register_notifier (&nfulnl_rtnl_notifier); status =nfnetlink_subsys_register (&nfulnl_subsys);if (status <0 ) { -pr_err ("log: failed to create netlink socket\n" ); +pr_err ("failed to create netlink socket\n" ); goto cleanup_netlink_notifier; } status =nf_log_register (NFPROTO_UNSPEC , &nfulnl_logger);if (status <0 ) { -pr_err ("log: failed to register logger\n" ); +pr_err ("failed to register logger\n" ); goto cleanup_subsys; } status =register_pernet_subsys (&nfnl_log_net_ops);if (status <0 ) { -pr_err ("log: failed to register pernet ops\n" ); +pr_err ("failed to register pernet ops\n" ); goto cleanup_logger; }return status;
Signature · 1 line
1.7.10.4
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Mon, 24 Nov 2014 14:27:37 +0100
Quoted 5 lines
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:
...
Quoted 3 lines
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Pulled, thanks Pablo.