aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2010-05-04 11:27:05 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2010-05-04 11:29:05 -0400
commit5306293c9cd2caf41849cc909281bda628bb989e (patch)
tree3be4e8231e2772c8a43ddbef5c6a72c20b3054bb /net/bridge
parentdbd65a7e44fff4741a0b2c84bd6bace85d22c242 (diff)
parent66f41d4c5c8a5deed66fdcc84509376c9a0bf9d8 (diff)
Merge commit 'v2.6.34-rc6'
Conflicts: fs/nfsd/nfs4callback.c
Diffstat (limited to 'net/bridge')
-rw-r--r--net/bridge/Kconfig1
-rw-r--r--net/bridge/br_device.c2
-rw-r--r--net/bridge/br_fdb.c1
-rw-r--r--net/bridge/br_forward.c19
-rw-r--r--net/bridge/br_if.c1
-rw-r--r--net/bridge/br_input.c5
-rw-r--r--net/bridge/br_ioctl.c1
-rw-r--r--net/bridge/br_multicast.c47
-rw-r--r--net/bridge/br_netfilter.c1
-rw-r--r--net/bridge/br_netlink.c1
-rw-r--r--net/bridge/br_private.h10
-rw-r--r--net/bridge/br_stp_bpdu.c1
-rw-r--r--net/bridge/netfilter/ebt_ulog.c1
-rw-r--r--net/bridge/netfilter/ebtables.c1
14 files changed, 63 insertions, 29 deletions
diff --git a/net/bridge/Kconfig b/net/bridge/Kconfig
index 19a6b9629c51..d115d5cea5b6 100644
--- a/net/bridge/Kconfig
+++ b/net/bridge/Kconfig
@@ -35,6 +35,7 @@ config BRIDGE
35config BRIDGE_IGMP_SNOOPING 35config BRIDGE_IGMP_SNOOPING
36 bool "IGMP snooping" 36 bool "IGMP snooping"
37 depends on BRIDGE 37 depends on BRIDGE
38 depends on INET
38 default y 39 default y
39 ---help--- 40 ---help---
40 If you say Y here, then the Ethernet bridge will be able selectively 41 If you say Y here, then the Ethernet bridge will be able selectively
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index eb7062d2e9e5..90a9024e5c1e 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -40,7 +40,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
40 goto out; 40 goto out;
41 41
42 mdst = br_mdb_get(br, skb); 42 mdst = br_mdb_get(br, skb);
43 if (mdst || BR_INPUT_SKB_CB(skb)->mrouters_only) 43 if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb))
44 br_multicast_deliver(mdst, skb); 44 br_multicast_deliver(mdst, skb);
45 else 45 else
46 br_flood_deliver(br, skb); 46 br_flood_deliver(br, skb);
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 3b8e038ab32c..9101a4e56201 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -20,6 +20,7 @@
20#include <linux/etherdevice.h> 20#include <linux/etherdevice.h>
21#include <linux/jhash.h> 21#include <linux/jhash.h>
22#include <linux/random.h> 22#include <linux/random.h>
23#include <linux/slab.h>
23#include <asm/atomic.h> 24#include <asm/atomic.h>
24#include <asm/unaligned.h> 25#include <asm/unaligned.h>
25#include "br_private.h" 26#include "br_private.h"
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index d61e6f741125..7a241c396981 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/slab.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/netdevice.h> 17#include <linux/netdevice.h>
17#include <linux/skbuff.h> 18#include <linux/skbuff.h>
@@ -19,6 +20,11 @@
19#include <linux/netfilter_bridge.h> 20#include <linux/netfilter_bridge.h>
20#include "br_private.h" 21#include "br_private.h"
21 22
23static int deliver_clone(const struct net_bridge_port *prev,
24 struct sk_buff *skb,
25 void (*__packet_hook)(const struct net_bridge_port *p,
26 struct sk_buff *skb));
27
22/* Don't forward packets to originating port or forwarding diasabled */ 28/* Don't forward packets to originating port or forwarding diasabled */
23static inline int should_deliver(const struct net_bridge_port *p, 29static inline int should_deliver(const struct net_bridge_port *p,
24 const struct sk_buff *skb) 30 const struct sk_buff *skb)
@@ -94,17 +100,22 @@ void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
94} 100}
95 101
96/* called with rcu_read_lock */ 102/* called with rcu_read_lock */
97void br_forward(const struct net_bridge_port *to, struct sk_buff *skb) 103void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0)
98{ 104{
99 if (should_deliver(to, skb)) { 105 if (should_deliver(to, skb)) {
100 __br_forward(to, skb); 106 if (skb0)
107 deliver_clone(to, skb, __br_forward);
108 else
109 __br_forward(to, skb);
101 return; 110 return;
102 } 111 }
103 112
104 kfree_skb(skb); 113 if (!skb0)
114 kfree_skb(skb);
105} 115}
106 116
107static int deliver_clone(struct net_bridge_port *prev, struct sk_buff *skb, 117static int deliver_clone(const struct net_bridge_port *prev,
118 struct sk_buff *skb,
108 void (*__packet_hook)(const struct net_bridge_port *p, 119 void (*__packet_hook)(const struct net_bridge_port *p,
109 struct sk_buff *skb)) 120 struct sk_buff *skb))
110{ 121{
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index b6a3872f5681..0b6b1f2ff7ac 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -19,6 +19,7 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/rtnetlink.h> 20#include <linux/rtnetlink.h>
21#include <linux/if_ether.h> 21#include <linux/if_ether.h>
22#include <linux/slab.h>
22#include <net/sock.h> 23#include <net/sock.h>
23 24
24#include "br_private.h" 25#include "br_private.h"
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 53b39851d87d..a82dde2d2ead 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -11,6 +11,7 @@
11 * 2 of the License, or (at your option) any later version. 11 * 2 of the License, or (at your option) any later version.
12 */ 12 */
13 13
14#include <linux/slab.h>
14#include <linux/kernel.h> 15#include <linux/kernel.h>
15#include <linux/netdevice.h> 16#include <linux/netdevice.h>
16#include <linux/etherdevice.h> 17#include <linux/etherdevice.h>
@@ -70,7 +71,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
70 71
71 if (is_multicast_ether_addr(dest)) { 72 if (is_multicast_ether_addr(dest)) {
72 mdst = br_mdb_get(br, skb); 73 mdst = br_mdb_get(br, skb);
73 if (mdst || BR_INPUT_SKB_CB(skb)->mrouters_only) { 74 if (mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) {
74 if ((mdst && !hlist_unhashed(&mdst->mglist)) || 75 if ((mdst && !hlist_unhashed(&mdst->mglist)) ||
75 br_multicast_is_router(br)) 76 br_multicast_is_router(br))
76 skb2 = skb; 77 skb2 = skb;
@@ -90,7 +91,7 @@ int br_handle_frame_finish(struct sk_buff *skb)
90 91
91 if (skb) { 92 if (skb) {
92 if (dst) 93 if (dst)
93 br_forward(dst->dst, skb); 94 br_forward(dst->dst, skb, skb2);
94 else 95 else
95 br_flood_forward(br, skb, skb2); 96 br_flood_forward(br, skb, skb2);
96 } 97 }
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c
index 2af6e4a90262..995afc4b04dc 100644
--- a/net/bridge/br_ioctl.c
+++ b/net/bridge/br_ioctl.c
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/if_bridge.h> 16#include <linux/if_bridge.h>
17#include <linux/netdevice.h> 17#include <linux/netdevice.h>
18#include <linux/slab.h>
18#include <linux/times.h> 19#include <linux/times.h>
19#include <net/net_namespace.h> 20#include <net/net_namespace.h>
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 2559fb539836..eaa0e1bae49b 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -38,7 +38,7 @@ static struct net_bridge_mdb_entry *__br_mdb_ip_get(
38 struct net_bridge_mdb_entry *mp; 38 struct net_bridge_mdb_entry *mp;
39 struct hlist_node *p; 39 struct hlist_node *p;
40 40
41 hlist_for_each_entry(mp, p, &mdb->mhash[hash], hlist[mdb->ver]) { 41 hlist_for_each_entry_rcu(mp, p, &mdb->mhash[hash], hlist[mdb->ver]) {
42 if (dst == mp->addr) 42 if (dst == mp->addr)
43 return mp; 43 return mp;
44 } 44 }
@@ -49,22 +49,23 @@ static struct net_bridge_mdb_entry *__br_mdb_ip_get(
49static struct net_bridge_mdb_entry *br_mdb_ip_get( 49static struct net_bridge_mdb_entry *br_mdb_ip_get(
50 struct net_bridge_mdb_htable *mdb, __be32 dst) 50 struct net_bridge_mdb_htable *mdb, __be32 dst)
51{ 51{
52 if (!mdb)
53 return NULL;
54
52 return __br_mdb_ip_get(mdb, dst, br_ip_hash(mdb, dst)); 55 return __br_mdb_ip_get(mdb, dst, br_ip_hash(mdb, dst));
53} 56}
54 57
55struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br, 58struct net_bridge_mdb_entry *br_mdb_get(struct net_bridge *br,
56 struct sk_buff *skb) 59 struct sk_buff *skb)
57{ 60{
58 struct net_bridge_mdb_htable *mdb = br->mdb; 61 if (br->multicast_disabled)
59
60 if (!mdb || br->multicast_disabled)
61 return NULL; 62 return NULL;
62 63
63 switch (skb->protocol) { 64 switch (skb->protocol) {
64 case htons(ETH_P_IP): 65 case htons(ETH_P_IP):
65 if (BR_INPUT_SKB_CB(skb)->igmp) 66 if (BR_INPUT_SKB_CB(skb)->igmp)
66 break; 67 break;
67 return br_mdb_ip_get(mdb, ip_hdr(skb)->daddr); 68 return br_mdb_ip_get(br->mdb, ip_hdr(skb)->daddr);
68 } 69 }
69 70
70 return NULL; 71 return NULL;
@@ -627,8 +628,8 @@ static void br_multicast_port_query_expired(unsigned long data)
627 struct net_bridge *br = port->br; 628 struct net_bridge *br = port->br;
628 629
629 spin_lock(&br->multicast_lock); 630 spin_lock(&br->multicast_lock);
630 if (port && (port->state == BR_STATE_DISABLED || 631 if (port->state == BR_STATE_DISABLED ||
631 port->state == BR_STATE_BLOCKING)) 632 port->state == BR_STATE_BLOCKING)
632 goto out; 633 goto out;
633 634
634 if (port->multicast_startup_queries_sent < 635 if (port->multicast_startup_queries_sent <
@@ -722,11 +723,11 @@ static int br_multicast_igmp3_report(struct net_bridge *br,
722 if (!pskb_may_pull(skb, len)) 723 if (!pskb_may_pull(skb, len))
723 return -EINVAL; 724 return -EINVAL;
724 725
725 grec = (void *)(skb->data + len); 726 grec = (void *)(skb->data + len - sizeof(*grec));
726 group = grec->grec_mca; 727 group = grec->grec_mca;
727 type = grec->grec_type; 728 type = grec->grec_type;
728 729
729 len += grec->grec_nsrcs * 4; 730 len += ntohs(grec->grec_nsrcs) * 4;
730 if (!pskb_may_pull(skb, len)) 731 if (!pskb_may_pull(skb, len))
731 return -EINVAL; 732 return -EINVAL;
732 733
@@ -823,6 +824,7 @@ static int br_multicast_query(struct net_bridge *br,
823 unsigned long max_delay; 824 unsigned long max_delay;
824 unsigned long now = jiffies; 825 unsigned long now = jiffies;
825 __be32 group; 826 __be32 group;
827 int err = 0;
826 828
827 spin_lock(&br->multicast_lock); 829 spin_lock(&br->multicast_lock);
828 if (!netif_running(br->dev) || 830 if (!netif_running(br->dev) ||
@@ -841,15 +843,17 @@ static int br_multicast_query(struct net_bridge *br,
841 group = 0; 843 group = 0;
842 } 844 }
843 } else { 845 } else {
844 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) 846 if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) {
845 return -EINVAL; 847 err = -EINVAL;
848 goto out;
849 }
846 850
847 ih3 = igmpv3_query_hdr(skb); 851 ih3 = igmpv3_query_hdr(skb);
848 if (ih3->nsrcs) 852 if (ih3->nsrcs)
849 return 0; 853 goto out;
850 854
851 max_delay = ih3->code ? 1 : 855 max_delay = ih3->code ?
852 IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE); 856 IGMPV3_MRC(ih3->code) * (HZ / IGMP_TIMER_SCALE) : 1;
853 } 857 }
854 858
855 if (!group) 859 if (!group)
@@ -876,7 +880,7 @@ static int br_multicast_query(struct net_bridge *br,
876 880
877out: 881out:
878 spin_unlock(&br->multicast_lock); 882 spin_unlock(&br->multicast_lock);
879 return 0; 883 return err;
880} 884}
881 885
882static void br_multicast_leave_group(struct net_bridge *br, 886static void br_multicast_leave_group(struct net_bridge *br,
@@ -953,9 +957,6 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
953 unsigned offset; 957 unsigned offset;
954 int err; 958 int err;
955 959
956 BR_INPUT_SKB_CB(skb)->igmp = 0;
957 BR_INPUT_SKB_CB(skb)->mrouters_only = 0;
958
959 /* We treat OOM as packet loss for now. */ 960 /* We treat OOM as packet loss for now. */
960 if (!pskb_may_pull(skb, sizeof(*iph))) 961 if (!pskb_may_pull(skb, sizeof(*iph)))
961 return -EINVAL; 962 return -EINVAL;
@@ -987,7 +988,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
987 988
988 err = pskb_trim_rcsum(skb2, len); 989 err = pskb_trim_rcsum(skb2, len);
989 if (err) 990 if (err)
990 return err; 991 goto err_out;
991 } 992 }
992 993
993 len -= ip_hdrlen(skb2); 994 len -= ip_hdrlen(skb2);
@@ -1009,7 +1010,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
1009 case CHECKSUM_NONE: 1010 case CHECKSUM_NONE:
1010 skb2->csum = 0; 1011 skb2->csum = 0;
1011 if (skb_checksum_complete(skb2)) 1012 if (skb_checksum_complete(skb2))
1012 return -EINVAL; 1013 goto out;
1013 } 1014 }
1014 1015
1015 err = 0; 1016 err = 0;
@@ -1036,6 +1037,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br,
1036 1037
1037out: 1038out:
1038 __skb_push(skb2, offset); 1039 __skb_push(skb2, offset);
1040err_out:
1039 if (skb2 != skb) 1041 if (skb2 != skb)
1040 kfree_skb(skb2); 1042 kfree_skb(skb2);
1041 return err; 1043 return err;
@@ -1044,6 +1046,9 @@ out:
1044int br_multicast_rcv(struct net_bridge *br, struct net_bridge_port *port, 1046int br_multicast_rcv(struct net_bridge *br, struct net_bridge_port *port,
1045 struct sk_buff *skb) 1047 struct sk_buff *skb)
1046{ 1048{
1049 BR_INPUT_SKB_CB(skb)->igmp = 0;
1050 BR_INPUT_SKB_CB(skb)->mrouters_only = 0;
1051
1047 if (br->multicast_disabled) 1052 if (br->multicast_disabled)
1048 return 0; 1053 return 0;
1049 1054
@@ -1135,7 +1140,7 @@ void br_multicast_stop(struct net_bridge *br)
1135 1140
1136 if (mdb->old) { 1141 if (mdb->old) {
1137 spin_unlock_bh(&br->multicast_lock); 1142 spin_unlock_bh(&br->multicast_lock);
1138 synchronize_rcu_bh(); 1143 rcu_barrier_bh();
1139 spin_lock_bh(&br->multicast_lock); 1144 spin_lock_bh(&br->multicast_lock);
1140 WARN_ON(mdb->old); 1145 WARN_ON(mdb->old);
1141 } 1146 }
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 268e2e725888..4c4977d12fd6 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/slab.h>
26#include <linux/ip.h> 27#include <linux/ip.h>
27#include <linux/netdevice.h> 28#include <linux/netdevice.h>
28#include <linux/skbuff.h> 29#include <linux/skbuff.h>
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index fcffb3fb1177..aa56ac2c8829 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/slab.h>
14#include <net/rtnetlink.h> 15#include <net/rtnetlink.h>
15#include <net/net_namespace.h> 16#include <net/net_namespace.h>
16#include <net/sock.h> 17#include <net/sock.h>
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index fef0384e3c0b..846d7d1e2075 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -206,12 +206,20 @@ struct net_bridge
206 206
207struct br_input_skb_cb { 207struct br_input_skb_cb {
208 struct net_device *brdev; 208 struct net_device *brdev;
209#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
209 int igmp; 210 int igmp;
210 int mrouters_only; 211 int mrouters_only;
212#endif
211}; 213};
212 214
213#define BR_INPUT_SKB_CB(__skb) ((struct br_input_skb_cb *)(__skb)->cb) 215#define BR_INPUT_SKB_CB(__skb) ((struct br_input_skb_cb *)(__skb)->cb)
214 216
217#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
218# define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (BR_INPUT_SKB_CB(__skb)->mrouters_only)
219#else
220# define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb) (0)
221#endif
222
215extern struct notifier_block br_device_notifier; 223extern struct notifier_block br_device_notifier;
216extern const u8 br_group_address[ETH_ALEN]; 224extern const u8 br_group_address[ETH_ALEN];
217 225
@@ -252,7 +260,7 @@ extern void br_deliver(const struct net_bridge_port *to,
252 struct sk_buff *skb); 260 struct sk_buff *skb);
253extern int br_dev_queue_push_xmit(struct sk_buff *skb); 261extern int br_dev_queue_push_xmit(struct sk_buff *skb);
254extern void br_forward(const struct net_bridge_port *to, 262extern void br_forward(const struct net_bridge_port *to,
255 struct sk_buff *skb); 263 struct sk_buff *skb, struct sk_buff *skb0);
256extern int br_forward_finish(struct sk_buff *skb); 264extern int br_forward_finish(struct sk_buff *skb);
257extern void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb); 265extern void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb);
258extern void br_flood_forward(struct net_bridge *br, struct sk_buff *skb, 266extern void br_flood_forward(struct net_bridge *br, struct sk_buff *skb,
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 81ae40b3f655..d66cce11f3bf 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -15,6 +15,7 @@
15#include <linux/netfilter_bridge.h> 15#include <linux/netfilter_bridge.h>
16#include <linux/etherdevice.h> 16#include <linux/etherdevice.h>
17#include <linux/llc.h> 17#include <linux/llc.h>
18#include <linux/slab.h>
18#include <net/net_namespace.h> 19#include <net/net_namespace.h>
19#include <net/llc.h> 20#include <net/llc.h>
20#include <net/llc_pdu.h> 21#include <net/llc_pdu.h>
diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index c6ac657074a6..f9560f3dbdc7 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -29,6 +29,7 @@
29 */ 29 */
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h>
32#include <linux/spinlock.h> 33#include <linux/spinlock.h>
33#include <linux/socket.h> 34#include <linux/socket.h>
34#include <linux/skbuff.h> 35#include <linux/skbuff.h>
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index dfb58056a89a..f0865fd1e3ec 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -23,6 +23,7 @@
23#include <linux/netfilter_bridge/ebtables.h> 23#include <linux/netfilter_bridge/ebtables.h>
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/slab.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27#include <linux/smp.h> 28#include <linux/smp.h>
28#include <linux/cpumask.h> 29#include <linux/cpumask.h>