Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 352113
b: refs/heads/master
c: cd431e7
h: refs/heads/master
i:
  352111: 63b55a4
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Feb 6, 2013
1 parent 5fcba6a commit 7356325
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6d1ccff627806829c46091bd9d9835302a3fbf5f
refs/heads/master: cd431e738509e74726055390c9e5e81e8e7e03ec
23 changes: 23 additions & 0 deletions trunk/drivers/net/macvlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <linux/if_vlan.h>
#include <linux/if_link.h>
#include <linux/if_macvlan.h>
#include <linux/hash.h>
#include <net/rtnetlink.h>
#include <net/xfrm.h>

Expand Down Expand Up @@ -126,6 +127,13 @@ static int macvlan_broadcast_one(struct sk_buff *skb,
return vlan->receive(skb);
}

static unsigned int mc_hash(const unsigned char *addr)
{
u32 val = __get_unaligned_cpu32(addr + 2);

return hash_32(val, MACVLAN_MC_FILTER_BITS);
}

static void macvlan_broadcast(struct sk_buff *skb,
const struct macvlan_port *port,
struct net_device *src,
Expand All @@ -137,6 +145,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
struct sk_buff *nskb;
unsigned int i;
int err;
unsigned int hash = mc_hash(eth->h_dest);

if (skb->protocol == htons(ETH_P_PAUSE))
return;
Expand All @@ -146,6 +155,8 @@ static void macvlan_broadcast(struct sk_buff *skb,
if (vlan->dev == src || !(vlan->mode & mode))
continue;

if (!test_bit(hash, vlan->mc_filter))
continue;
nskb = skb_clone(skb, GFP_ATOMIC);
err = macvlan_broadcast_one(nskb, vlan, eth,
mode == MACVLAN_MODE_BRIDGE);
Expand Down Expand Up @@ -405,6 +416,18 @@ static void macvlan_set_mac_lists(struct net_device *dev)
{
struct macvlan_dev *vlan = netdev_priv(dev);

if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
bitmap_fill(vlan->mc_filter, MACVLAN_MC_FILTER_SZ);
} else {
struct netdev_hw_addr *ha;
DECLARE_BITMAP(filter, MACVLAN_MC_FILTER_SZ);

bitmap_zero(filter, MACVLAN_MC_FILTER_SZ);
netdev_for_each_mc_addr(ha, dev) {
__set_bit(mc_hash(ha->addr), filter);
}
bitmap_copy(vlan->mc_filter, filter, MACVLAN_MC_FILTER_SZ);
}
dev_uc_sync(vlan->lowerdev, dev);
dev_mc_sync(vlan->lowerdev, dev);
}
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/linux/if_macvlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ struct macvlan_pcpu_stats {
*/
#define MAX_MACVTAP_QUEUES (NR_CPUS < 16 ? NR_CPUS : 16)

#define MACVLAN_MC_FILTER_BITS 8
#define MACVLAN_MC_FILTER_SZ (1 << MACVLAN_MC_FILTER_BITS)

struct macvlan_dev {
struct net_device *dev;
struct list_head list;
struct hlist_node hlist;
struct macvlan_port *port;
struct net_device *lowerdev;
struct macvlan_pcpu_stats __percpu *pcpu_stats;

DECLARE_BITMAP(mc_filter, MACVLAN_MC_FILTER_SZ);

enum macvlan_mode mode;
u16 flags;
int (*receive)(struct sk_buff *skb);
Expand Down

0 comments on commit 7356325

Please sign in to comment.