aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/bridge/netfilter/Kconfig1
-rw-r--r--net/bridge/netfilter/nf_tables_bridge.c41
-rw-r--r--net/ipv4/netfilter/nf_tables_ipv4.c1
-rw-r--r--net/netfilter/nft_compat.c8
-rw-r--r--net/netfilter/nft_nat.c12
5 files changed, 52 insertions, 11 deletions
diff --git a/net/bridge/netfilter/Kconfig b/net/bridge/netfilter/Kconfig
index 68f8128147be..5ca74a0e595f 100644
--- a/net/bridge/netfilter/Kconfig
+++ b/net/bridge/netfilter/Kconfig
@@ -3,6 +3,7 @@
3# 3#
4# 4#
5config NF_TABLES_BRIDGE 5config NF_TABLES_BRIDGE
6 depends on NF_TABLES
6 tristate "Ethernet Bridge nf_tables support" 7 tristate "Ethernet Bridge nf_tables support"
7 8
8menuconfig BRIDGE_NF_EBTABLES 9menuconfig BRIDGE_NF_EBTABLES
diff --git a/net/bridge/netfilter/nf_tables_bridge.c b/net/bridge/netfilter/nf_tables_bridge.c
index e8cb016fa34d..cf54b22818c8 100644
--- a/net/bridge/netfilter/nf_tables_bridge.c
+++ b/net/bridge/netfilter/nf_tables_bridge.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net> 2 * Copyright (c) 2008 Patrick McHardy <kaber@trash.net>
3 * Copyright (c) 2013 Pablo Neira Ayuso <pablo@netfilter.org>
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 6 * it under the terms of the GNU General Public License version 2 as
@@ -47,14 +48,50 @@ static struct pernet_operations nf_tables_bridge_net_ops = {
47 .exit = nf_tables_bridge_exit_net, 48 .exit = nf_tables_bridge_exit_net,
48}; 49};
49 50
51static unsigned int
52nft_do_chain_bridge(const struct nf_hook_ops *ops,
53 struct sk_buff *skb,
54 const struct net_device *in,
55 const struct net_device *out,
56 int (*okfn)(struct sk_buff *))
57{
58 struct nft_pktinfo pkt;
59
60 nft_set_pktinfo(&pkt, ops, skb, in, out);
61
62 return nft_do_chain_pktinfo(&pkt, ops);
63}
64
65static struct nf_chain_type filter_bridge = {
66 .family = NFPROTO_BRIDGE,
67 .name = "filter",
68 .type = NFT_CHAIN_T_DEFAULT,
69 .hook_mask = (1 << NF_BR_LOCAL_IN) |
70 (1 << NF_BR_FORWARD) |
71 (1 << NF_BR_LOCAL_OUT),
72 .fn = {
73 [NF_BR_LOCAL_IN] = nft_do_chain_bridge,
74 [NF_BR_FORWARD] = nft_do_chain_bridge,
75 [NF_BR_LOCAL_OUT] = nft_do_chain_bridge,
76 },
77};
78
50static int __init nf_tables_bridge_init(void) 79static int __init nf_tables_bridge_init(void)
51{ 80{
52 return register_pernet_subsys(&nf_tables_bridge_net_ops); 81 int ret;
82
83 nft_register_chain_type(&filter_bridge);
84 ret = register_pernet_subsys(&nf_tables_bridge_net_ops);
85 if (ret < 0)
86 nft_unregister_chain_type(&filter_bridge);
87
88 return ret;
53} 89}
54 90
55static void __exit nf_tables_bridge_exit(void) 91static void __exit nf_tables_bridge_exit(void)
56{ 92{
57 return unregister_pernet_subsys(&nf_tables_bridge_net_ops); 93 unregister_pernet_subsys(&nf_tables_bridge_net_ops);
94 nft_unregister_chain_type(&filter_bridge);
58} 95}
59 96
60module_init(nf_tables_bridge_init); 97module_init(nf_tables_bridge_init);
diff --git a/net/ipv4/netfilter/nf_tables_ipv4.c b/net/ipv4/netfilter/nf_tables_ipv4.c
index 8f7536be1322..0f4cbfeb19bd 100644
--- a/net/ipv4/netfilter/nf_tables_ipv4.c
+++ b/net/ipv4/netfilter/nf_tables_ipv4.c
@@ -16,7 +16,6 @@
16#include <net/netfilter/nf_tables.h> 16#include <net/netfilter/nf_tables.h>
17#include <net/net_namespace.h> 17#include <net/net_namespace.h>
18#include <net/ip.h> 18#include <net/ip.h>
19#include <net/net_namespace.h>
20#include <net/netfilter/nf_tables_ipv4.h> 19#include <net/netfilter/nf_tables_ipv4.h>
21 20
22static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops, 21static unsigned int nft_ipv4_output(const struct nf_hook_ops *ops,
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 4811f762e060..a82667c64729 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -634,9 +634,9 @@ nft_match_select_ops(const struct nft_ctx *ctx,
634 634
635static void nft_match_release(void) 635static void nft_match_release(void)
636{ 636{
637 struct nft_xt *nft_match; 637 struct nft_xt *nft_match, *tmp;
638 638
639 list_for_each_entry(nft_match, &nft_match_list, head) 639 list_for_each_entry_safe(nft_match, tmp, &nft_match_list, head)
640 kfree(nft_match); 640 kfree(nft_match);
641} 641}
642 642
@@ -705,9 +705,9 @@ nft_target_select_ops(const struct nft_ctx *ctx,
705 705
706static void nft_target_release(void) 706static void nft_target_release(void)
707{ 707{
708 struct nft_xt *nft_target; 708 struct nft_xt *nft_target, *tmp;
709 709
710 list_for_each_entry(nft_target, &nft_target_list, head) 710 list_for_each_entry_safe(nft_target, tmp, &nft_target_list, head)
711 kfree(nft_target); 711 kfree(nft_target);
712} 712}
713 713
diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c
index b0b87b2d2411..d3b1ffe26181 100644
--- a/net/netfilter/nft_nat.c
+++ b/net/netfilter/nft_nat.c
@@ -47,8 +47,10 @@ static void nft_nat_eval(const struct nft_expr *expr,
47 memset(&range, 0, sizeof(range)); 47 memset(&range, 0, sizeof(range));
48 if (priv->sreg_addr_min) { 48 if (priv->sreg_addr_min) {
49 if (priv->family == AF_INET) { 49 if (priv->family == AF_INET) {
50 range.min_addr.ip = data[priv->sreg_addr_min].data[0]; 50 range.min_addr.ip = (__force __be32)
51 range.max_addr.ip = data[priv->sreg_addr_max].data[0]; 51 data[priv->sreg_addr_min].data[0];
52 range.max_addr.ip = (__force __be32)
53 data[priv->sreg_addr_max].data[0];
52 54
53 } else { 55 } else {
54 memcpy(range.min_addr.ip6, 56 memcpy(range.min_addr.ip6,
@@ -62,8 +64,10 @@ static void nft_nat_eval(const struct nft_expr *expr,
62 } 64 }
63 65
64 if (priv->sreg_proto_min) { 66 if (priv->sreg_proto_min) {
65 range.min_proto.all = data[priv->sreg_proto_min].data[0]; 67 range.min_proto.all = (__force __be16)
66 range.max_proto.all = data[priv->sreg_proto_max].data[0]; 68 data[priv->sreg_proto_min].data[0];
69 range.max_proto.all = (__force __be16)
70 data[priv->sreg_proto_max].data[0];
67 range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED; 71 range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
68 } 72 }
69 73