aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-03-10 12:48:47 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-10 12:48:47 -0400
commit515fb5c317db991e2f9877936b3b21a35c1d3190 (patch)
tree93f05ff9459d6cae977bd468a6ba5a1f59f477ad
parent59e33c2b021322db92ca27c4d9958e57630443b6 (diff)
parent1a4ba64d16a42c1b31d52b671accd7f9103e2626 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next
Pablo Neira Ayuso says: ==================== Netfilter fixes for net-next The following batch contains a couple of fixes to address some fallout from the previous pull request, they are: 1) Address link problems in the bridge code after e5de75b. Fix it by using rcu hook to address to avoid ifdef pollution and hard dependency between bridge and br_netfilter. 2) Address sparse warnings in the netfilter reject code, patch from Florian Westphal. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/netfilter/ipv4/nf_reject.h2
-rw-r--r--include/net/netfilter/ipv6/nf_reject.h2
-rw-r--r--net/bridge/br_device.c7
-rw-r--r--net/bridge/br_netfilter.c9
-rw-r--r--net/bridge/br_private.h10
-rw-r--r--net/bridge/netfilter/nft_reject_bridge.c2
-rw-r--r--net/ipv4/netfilter/nf_reject_ipv4.c2
-rw-r--r--net/ipv6/netfilter/nf_reject_ipv6.c2
8 files changed, 23 insertions, 13 deletions
diff --git a/include/net/netfilter/ipv4/nf_reject.h b/include/net/netfilter/ipv4/nf_reject.h
index 864127573c32..77862c3645f0 100644
--- a/include/net/netfilter/ipv4/nf_reject.h
+++ b/include/net/netfilter/ipv4/nf_reject.h
@@ -12,7 +12,7 @@ const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb,
12 struct tcphdr *_oth, int hook); 12 struct tcphdr *_oth, int hook);
13struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb, 13struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
14 const struct sk_buff *oldskb, 14 const struct sk_buff *oldskb,
15 __be16 protocol, int ttl); 15 __u8 protocol, int ttl);
16void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb, 16void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb,
17 const struct tcphdr *oth); 17 const struct tcphdr *oth);
18 18
diff --git a/include/net/netfilter/ipv6/nf_reject.h b/include/net/netfilter/ipv6/nf_reject.h
index 0ae445d3f217..0ea4fa37db16 100644
--- a/include/net/netfilter/ipv6/nf_reject.h
+++ b/include/net/netfilter/ipv6/nf_reject.h
@@ -13,7 +13,7 @@ const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
13 unsigned int *otcplen, int hook); 13 unsigned int *otcplen, int hook);
14struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb, 14struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
15 const struct sk_buff *oldskb, 15 const struct sk_buff *oldskb,
16 __be16 protocol, int hoplimit); 16 __u8 protocol, int hoplimit);
17void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb, 17void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
18 const struct sk_buff *oldskb, 18 const struct sk_buff *oldskb,
19 const struct tcphdr *oth, unsigned int otcplen); 19 const struct tcphdr *oth, unsigned int otcplen);
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 294cbcc49263..4ff77a16956c 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -25,6 +25,9 @@
25#define COMMON_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | \ 25#define COMMON_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | \
26 NETIF_F_GSO_MASK | NETIF_F_HW_CSUM) 26 NETIF_F_GSO_MASK | NETIF_F_HW_CSUM)
27 27
28const struct nf_br_ops __rcu *nf_br_ops __read_mostly;
29EXPORT_SYMBOL_GPL(nf_br_ops);
30
28/* net device transmit always called with BH disabled */ 31/* net device transmit always called with BH disabled */
29netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) 32netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
30{ 33{
@@ -33,10 +36,12 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
33 struct net_bridge_fdb_entry *dst; 36 struct net_bridge_fdb_entry *dst;
34 struct net_bridge_mdb_entry *mdst; 37 struct net_bridge_mdb_entry *mdst;
35 struct pcpu_sw_netstats *brstats = this_cpu_ptr(br->stats); 38 struct pcpu_sw_netstats *brstats = this_cpu_ptr(br->stats);
39 const struct nf_br_ops *nf_ops;
36 u16 vid = 0; 40 u16 vid = 0;
37 41
38 rcu_read_lock(); 42 rcu_read_lock();
39 if (br_nf_prerouting_finish_bridge(skb)) { 43 nf_ops = rcu_dereference(nf_br_ops);
44 if (nf_ops && nf_ops->br_dev_xmit_hook(skb)) {
40 rcu_read_unlock(); 45 rcu_read_unlock();
41 return NETDEV_TX_OK; 46 return NETDEV_TX_OK;
42 } 47 }
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index a8361c7cdf81..b260a97275db 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -914,7 +914,7 @@ static void br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb)
914 br_handle_frame_finish(skb); 914 br_handle_frame_finish(skb);
915} 915}
916 916
917int br_nf_prerouting_finish_bridge(struct sk_buff *skb) 917static int br_nf_dev_xmit(struct sk_buff *skb)
918{ 918{
919 if (skb->nf_bridge && (skb->nf_bridge->mask & BRNF_BRIDGED_DNAT)) { 919 if (skb->nf_bridge && (skb->nf_bridge->mask & BRNF_BRIDGED_DNAT)) {
920 br_nf_pre_routing_finish_bridge_slow(skb); 920 br_nf_pre_routing_finish_bridge_slow(skb);
@@ -922,7 +922,10 @@ int br_nf_prerouting_finish_bridge(struct sk_buff *skb)
922 } 922 }
923 return 0; 923 return 0;
924} 924}
925EXPORT_SYMBOL_GPL(br_nf_prerouting_finish_bridge); 925
926static const struct nf_br_ops br_ops = {
927 .br_dev_xmit_hook = br_nf_dev_xmit,
928};
926 929
927void br_netfilter_enable(void) 930void br_netfilter_enable(void)
928{ 931{
@@ -1061,12 +1064,14 @@ static int __init br_netfilter_init(void)
1061 return -ENOMEM; 1064 return -ENOMEM;
1062 } 1065 }
1063#endif 1066#endif
1067 RCU_INIT_POINTER(nf_br_ops, &br_ops);
1064 printk(KERN_NOTICE "Bridge firewalling registered\n"); 1068 printk(KERN_NOTICE "Bridge firewalling registered\n");
1065 return 0; 1069 return 0;
1066} 1070}
1067 1071
1068static void __exit br_netfilter_fini(void) 1072static void __exit br_netfilter_fini(void)
1069{ 1073{
1074 RCU_INIT_POINTER(nf_br_ops, NULL);
1070 nf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops)); 1075 nf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
1071#ifdef CONFIG_SYSCTL 1076#ifdef CONFIG_SYSCTL
1072 unregister_net_sysctl_table(brnf_sysctl_header); 1077 unregister_net_sysctl_table(brnf_sysctl_header);
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index f0a0438dbd6d..b46fa0c5b8ec 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -763,17 +763,17 @@ static inline int br_vlan_enabled(struct net_bridge *br)
763} 763}
764#endif 764#endif
765 765
766struct nf_br_ops {
767 int (*br_dev_xmit_hook)(struct sk_buff *skb);
768};
769extern const struct nf_br_ops __rcu *nf_br_ops;
770
766/* br_netfilter.c */ 771/* br_netfilter.c */
767#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) 772#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
768int br_nf_prerouting_finish_bridge(struct sk_buff *skb);
769int br_nf_core_init(void); 773int br_nf_core_init(void);
770void br_nf_core_fini(void); 774void br_nf_core_fini(void);
771void br_netfilter_rtable_init(struct net_bridge *); 775void br_netfilter_rtable_init(struct net_bridge *);
772#else 776#else
773static inline int br_nf_prerouting_finish_bridge(struct sk_buff *skb)
774{
775 return 0;
776}
777static inline int br_nf_core_init(void) { return 0; } 777static inline int br_nf_core_init(void) { return 0; }
778static inline void br_nf_core_fini(void) {} 778static inline void br_nf_core_fini(void) {}
779#define br_netfilter_rtable_init(x) 779#define br_netfilter_rtable_init(x)
diff --git a/net/bridge/netfilter/nft_reject_bridge.c b/net/bridge/netfilter/nft_reject_bridge.c
index 5c6c96585acd..54a2fdf0f457 100644
--- a/net/bridge/netfilter/nft_reject_bridge.c
+++ b/net/bridge/netfilter/nft_reject_bridge.c
@@ -99,7 +99,7 @@ static void nft_reject_br_send_v4_unreach(struct sk_buff *oldskb,
99 if (!pskb_may_pull(oldskb, len)) 99 if (!pskb_may_pull(oldskb, len))
100 return; 100 return;
101 101
102 if (pskb_trim_rcsum(oldskb, htons(ip_hdr(oldskb)->tot_len))) 102 if (pskb_trim_rcsum(oldskb, ntohs(ip_hdr(oldskb)->tot_len)))
103 return; 103 return;
104 104
105 if (ip_hdr(oldskb)->protocol == IPPROTO_TCP || 105 if (ip_hdr(oldskb)->protocol == IPPROTO_TCP ||
diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index b7405eb7f1ef..c5b794da51a9 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -43,7 +43,7 @@ EXPORT_SYMBOL_GPL(nf_reject_ip_tcphdr_get);
43 43
44struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb, 44struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
45 const struct sk_buff *oldskb, 45 const struct sk_buff *oldskb,
46 __be16 protocol, int ttl) 46 __u8 protocol, int ttl)
47{ 47{
48 struct iphdr *niph, *oiph = ip_hdr(oldskb); 48 struct iphdr *niph, *oiph = ip_hdr(oldskb);
49 49
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index 68e0bb4db1bf..3afdce03d94e 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -65,7 +65,7 @@ EXPORT_SYMBOL_GPL(nf_reject_ip6_tcphdr_get);
65 65
66struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb, 66struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
67 const struct sk_buff *oldskb, 67 const struct sk_buff *oldskb,
68 __be16 protocol, int hoplimit) 68 __u8 protocol, int hoplimit)
69{ 69{
70 struct ipv6hdr *ip6h; 70 struct ipv6hdr *ip6h;
71 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb); 71 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);