kernel: bridge, multicast-to-unicast: fix echoes on STA
authorFelix Fietkau <nbd@openwrt.org>
Wed, 2 Sep 2015 09:23:59 +0000 (09:23 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 2 Sep 2015 09:23:59 +0000 (09:23 +0000)
Currently, multicast packets from an STA are sent to any according
multicast listener directly through the bridge multicast-to-unicast
feature. Unfortunately, so far this includes the originating STA, too,
resulting in multicast packets being echo'ed back to the originating STA
if it itself is a multicast listener for that group.

This behaviour breaks IPv6 duplicate address detection: An IPv6 Neighbor
Solicitation for IPv6 Duplicate Address Detection is being echo'ed back,
resulting in the host falsely detecting an address collision, which
makes the node unable to claim an IPv6 address and use IPv6 in general.

Mac80211 unfortunately only prevents the echoes for us for multicast
frames. For the multicast frames cast to a unicast destination we'll
need to take care of excluding the originator ourselves.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
SVN-Revision: 46765

target/linux/generic/patches-3.18/645-bridge_multicast_to_unicast.patch
target/linux/generic/patches-4.1/645-bridge_multicast_to_unicast.patch

index 1e070d9d9c27fa01293ba000e120da6fc40e98a8..a40abb5c68c776550bad9da429f376aa79402399 100644 (file)
                if (err)
                        break;
        }
-@@ -1407,7 +1433,8 @@ br_multicast_leave_group(struct net_brid
+@@ -1406,7 +1432,8 @@ br_multicast_leave_group(struct net_brid
                         struct net_bridge_port *port,
                         struct br_ip *group,
                         struct bridge_mcast_other_query *other_query,
  {
        struct net_bridge_mdb_htable *mdb;
        struct net_bridge_mdb_entry *mp;
-@@ -1457,7 +1484,7 @@ br_multicast_leave_group(struct net_brid
+@@ -1456,7 +1483,7 @@ br_multicast_leave_group(struct net_brid
                for (pp = &mp->ports;
                     (p = mlock_dereference(*pp, br)) != NULL;
                     pp = &p->next) {
                                continue;
  
                        rcu_assign_pointer(*pp, p->next);
-@@ -1491,7 +1518,7 @@ br_multicast_leave_group(struct net_brid
+@@ -1490,7 +1517,7 @@ br_multicast_leave_group(struct net_brid
        for (p = mlock_dereference(mp->ports, br);
             p != NULL;
             p = mlock_dereference(p->next, br)) {
                        continue;
  
                if (!hlist_unhashed(&p->mglist) &&
-@@ -1509,8 +1536,8 @@ out:
+@@ -1508,8 +1535,8 @@ out:
  
  static void br_ip4_multicast_leave_group(struct net_bridge *br,
                                         struct net_bridge_port *port,
  {
        struct br_ip br_group;
        struct bridge_mcast_own_query *own_query;
-@@ -1525,14 +1552,14 @@ static void br_ip4_multicast_leave_group
+@@ -1524,14 +1551,14 @@ static void br_ip4_multicast_leave_group
        br_group.vid = vid;
  
        br_multicast_leave_group(br, port, &br_group, &br->ip4_other_query,
  {
        struct br_ip br_group;
        struct bridge_mcast_own_query *own_query;
-@@ -1547,7 +1574,7 @@ static void br_ip6_multicast_leave_group
+@@ -1546,7 +1573,7 @@ static void br_ip6_multicast_leave_group
        br_group.vid = vid;
  
        br_multicast_leave_group(br, port, &br_group, &br->ip6_other_query,
  }
  #endif
  
-@@ -1556,6 +1583,7 @@ static int br_multicast_ipv4_rcv(struct
+@@ -1555,6 +1582,7 @@ static int br_multicast_ipv4_rcv(struct
                                 struct sk_buff *skb,
                                 u16 vid)
  {
        struct sk_buff *skb2 = skb;
        const struct iphdr *iph;
        struct igmphdr *ih;
-@@ -1629,7 +1657,8 @@ static int br_multicast_ipv4_rcv(struct
+@@ -1628,7 +1656,8 @@ static int br_multicast_ipv4_rcv(struct
        case IGMP_HOST_MEMBERSHIP_REPORT:
        case IGMPV2_HOST_MEMBERSHIP_REPORT:
                BR_INPUT_SKB_CB(skb)->mrouters_only = 1;
                break;
        case IGMPV3_HOST_MEMBERSHIP_REPORT:
                err = br_ip4_multicast_igmp3_report(br, port, skb2, vid);
-@@ -1638,7 +1667,8 @@ static int br_multicast_ipv4_rcv(struct
+@@ -1637,7 +1666,8 @@ static int br_multicast_ipv4_rcv(struct
                err = br_ip4_multicast_query(br, port, skb2, vid);
                break;
        case IGMP_HOST_LEAVE_MESSAGE:
                break;
        }
  
-@@ -1656,6 +1686,7 @@ static int br_multicast_ipv6_rcv(struct
+@@ -1655,6 +1685,7 @@ static int br_multicast_ipv6_rcv(struct
                                 struct sk_buff *skb,
                                 u16 vid)
  {
        struct sk_buff *skb2;
        const struct ipv6hdr *ip6h;
        u8 icmp6_type;
-@@ -1765,7 +1796,9 @@ static int br_multicast_ipv6_rcv(struct
+@@ -1764,7 +1795,9 @@ static int br_multicast_ipv6_rcv(struct
                }
                mld = (struct mld_msg *)skb_transport_header(skb2);
                BR_INPUT_SKB_CB(skb)->mrouters_only = 1;
                break;
            }
        case ICMPV6_MLD2_REPORT:
-@@ -1782,7 +1815,8 @@ static int br_multicast_ipv6_rcv(struct
+@@ -1781,7 +1814,8 @@ static int br_multicast_ipv6_rcv(struct
                        goto out;
                }
                mld = (struct mld_msg *)skb_transport_header(skb2);
        rcu_assign_pointer(*pp, p);
 --- a/net/bridge/br_forward.c
 +++ b/net/bridge/br_forward.c
-@@ -168,6 +168,29 @@ out:
+@@ -168,6 +168,34 @@ out:
        return p;
  }
  
 +                            struct sk_buff *skb))
 +{
 +      struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev;
++      const unsigned char *src = eth_hdr(skb)->h_source;
 +
 +      if (!should_deliver(p, skb))
 +              return prev;
 +
++      /* Even with hairpin, no soliloquies - prevent breaking IPv6 DAD */
++      if (skb->dev == p->dev && ether_addr_equal(src, addr))
++              return prev;
++
 +      skb = skb_copy(skb, GFP_ATOMIC);
 +      if (!skb) {
 +              dev->stats.tx_dropped++;
  /* called under bridge lock */
  static void br_flood(struct net_bridge *br, struct sk_buff *skb,
                     struct sk_buff *skb0,
-@@ -232,6 +255,7 @@ static void br_multicast_flood(struct ne
+@@ -232,6 +260,7 @@ static void br_multicast_flood(struct ne
        struct net_bridge_port *prev = NULL;
        struct net_bridge_port_group *p;
        struct hlist_node *rp;
  
        rp = rcu_dereference(hlist_first_rcu(&br->router_list));
        p = mdst ? rcu_dereference(mdst->ports) : NULL;
-@@ -242,10 +266,19 @@ static void br_multicast_flood(struct ne
+@@ -242,10 +271,19 @@ static void br_multicast_flood(struct ne
                rport = rp ? hlist_entry(rp, struct net_bridge_port, rlist) :
                             NULL;
  
index 6915599c6cdda245c7dea15c2acd643232d8d76a..bbd8e254477ce6bff701d62e06fb654c51f838e0 100644 (file)
        rcu_assign_pointer(*pp, p);
 --- a/net/bridge/br_forward.c
 +++ b/net/bridge/br_forward.c
-@@ -169,6 +169,29 @@ out:
+@@ -169,6 +169,34 @@ out:
        return p;
  }
  
 +                            struct sk_buff *skb))
 +{
 +      struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev;
++      const unsigned char *src = eth_hdr(skb)->h_source;
 +
 +      if (!should_deliver(p, skb))
 +              return prev;
 +
++      /* Even with hairpin, no soliloquies - prevent breaking IPv6 DAD */
++      if (skb->dev == p->dev && ether_addr_equal(src, addr))
++              return prev;
++
 +      skb = skb_copy(skb, GFP_ATOMIC);
 +      if (!skb) {
 +              dev->stats.tx_dropped++;
  /* called under bridge lock */
  static void br_flood(struct net_bridge *br, struct sk_buff *skb,
                     struct sk_buff *skb0,
-@@ -241,6 +264,7 @@ static void br_multicast_flood(struct ne
+@@ -241,6 +269,7 @@ static void br_multicast_flood(struct ne
        struct net_bridge_port *prev = NULL;
        struct net_bridge_port_group *p;
        struct hlist_node *rp;
  
        rp = rcu_dereference(hlist_first_rcu(&br->router_list));
        p = mdst ? rcu_dereference(mdst->ports) : NULL;
-@@ -251,10 +275,19 @@ static void br_multicast_flood(struct ne
+@@ -251,10 +280,19 @@ static void br_multicast_flood(struct ne
                rport = rp ? hlist_entry(rp, struct net_bridge_port, rlist) :
                             NULL;