From 15c6ff3bc0ff3464a8c7efcdea09c86454571622 Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Tue, 1 Jan 2013 03:30:17 +0000 Subject: net: remove unnecessary NET_ADDR_RANDOM "bitclean" NET_ADDR_SET is set in dev_set_mac_address() no need to alter dev->addr_assign_type value in drivers. Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/net/macvlan.c') diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 68a43fe602e7..80c6f927a7b4 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -375,7 +375,6 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p) if (!(dev->flags & IFF_UP)) { /* Just copy in the new address */ - dev->addr_assign_type &= ~NET_ADDR_RANDOM; memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); } else { /* Rehash and update the device filters */ -- cgit From 7cd43db77eed83ce9c2086edb402748256e05f14 Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Thu, 3 Jan 2013 22:48:50 +0000 Subject: macvlan: add link to upper device Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/net/macvlan.c') diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 80c6f927a7b4..0ae45182f40d 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -764,16 +764,22 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, memcpy(dev->dev_addr, lowerdev->dev_addr, ETH_ALEN); } + err = netdev_upper_dev_link(lowerdev, dev); + if (err) + goto destroy_port; + port->count += 1; err = register_netdevice(dev); if (err < 0) - goto destroy_port; + goto upper_dev_unlink; list_add_tail(&vlan->list, &port->vlans); netif_stacked_transfer_operstate(lowerdev, dev); return 0; +upper_dev_unlink: + netdev_upper_dev_unlink(lowerdev, dev); destroy_port: port->count -= 1; if (!port->count) @@ -797,6 +803,7 @@ void macvlan_dellink(struct net_device *dev, struct list_head *head) list_del(&vlan->list); unregister_netdevice_queue(dev, head); + netdev_upper_dev_unlink(vlan->lowerdev, dev); } EXPORT_SYMBOL_GPL(macvlan_dellink); -- cgit From 7826d43f2db45c9305a6e0ba165650e1a203f517 Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Sun, 6 Jan 2013 00:44:26 +0000 Subject: ethtool: fix drvinfo strings set in drivers Use strlcpy where possible to ensure the string is \0 terminated. Use always sizeof(string) instead of 32, ETHTOOL_BUSINFO_LEN and custom defines. Use snprintf instead of sprint. Remove unnecessary inits of ->fw_version Remove unnecessary inits of drvinfo struct. Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/macvlan.c') diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 0ae45182f40d..1047e5875801 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -585,8 +585,8 @@ static int macvlan_fdb_del(struct ndmsg *ndm, static void macvlan_ethtool_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) { - snprintf(drvinfo->driver, 32, "macvlan"); - snprintf(drvinfo->version, 32, "0.1"); + strlcpy(drvinfo->driver, "macvlan", sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, "0.1", sizeof(drvinfo->version)); } static int macvlan_ethtool_get_settings(struct net_device *dev, -- cgit From cd431e738509e74726055390c9e5e81e8e7e03ec Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 5 Feb 2013 20:22:50 +0000 Subject: macvlan: add multicast filter Setting up IPv6 addresses on configurations with many macvlans is not really working, as many multicast messages are dropped. Add a multicast filter to macvlan to reduce the amount of cloned skbs and overhead. Successfully tested with 1024 macvlans on one ethernet device. Signed-off-by: Eric Dumazet Cc: Ben Greear Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'drivers/net/macvlan.c') diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 7b44ebd7770e..f494da82c33f 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -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, @@ -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; @@ -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); @@ -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); } -- cgit From d527043040740f41192dfd71793f905a998ee4f6 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Thu, 7 Feb 2013 16:02:57 +0000 Subject: macvlan: broadcast addr should be part of mc_filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit cd431e738509e (macvlan: add multicast filter) forgot the broadcast case. Signed-off-by: Eric Dumazet Reported-by: Maciej Żenczykowski SIgned-off-by: Maciej Żenczykowski Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/net/macvlan.c') diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index f494da82c33f..ce7c9268c740 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -426,6 +426,9 @@ static void macvlan_set_mac_lists(struct net_device *dev) netdev_for_each_mc_addr(ha, dev) { __set_bit(mc_hash(ha->addr), filter); } + + __set_bit(mc_hash(dev->broadcast), filter); + bitmap_copy(vlan->mc_filter, filter, MACVLAN_MC_FILTER_SZ); } dev_uc_sync(vlan->lowerdev, dev); -- cgit From 3807ff5899f892abb4f06747c245fd648a2acdc5 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Thu, 7 Feb 2013 16:41:02 +0000 Subject: macvlan: add a salt to mc_hash() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some multicast addresses are common to all macvlans, so if a multicast message has a hash value collision, we have to deliver a copy to all macvlans, adding significant latency and possible packet drops if netdev_max_backlog limit is hit. Having a per macvlan hash function permits to reduce the impact of hash collisions. Suggested-by: Maciej Żenczykowski Signed-off-by: Eric Dumazet Signed-off-by: Maciej Żenczykowski Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'drivers/net/macvlan.c') diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index ce7c9268c740..e4b8078e88a9 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -127,10 +127,18 @@ static int macvlan_broadcast_one(struct sk_buff *skb, return vlan->receive(skb); } -static unsigned int mc_hash(const unsigned char *addr) +static u32 macvlan_hash_mix(const struct macvlan_dev *vlan) +{ + return (u32)(((unsigned long)vlan) >> L1_CACHE_SHIFT); +} + + +static unsigned int mc_hash(const struct macvlan_dev *vlan, + const unsigned char *addr) { u32 val = __get_unaligned_cpu32(addr + 2); + val ^= macvlan_hash_mix(vlan); return hash_32(val, MACVLAN_MC_FILTER_BITS); } @@ -145,7 +153,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); + unsigned int hash; if (skb->protocol == htons(ETH_P_PAUSE)) return; @@ -155,6 +163,7 @@ static void macvlan_broadcast(struct sk_buff *skb, if (vlan->dev == src || !(vlan->mode & mode)) continue; + hash = mc_hash(vlan, eth->h_dest); if (!test_bit(hash, vlan->mc_filter)) continue; nskb = skb_clone(skb, GFP_ATOMIC); @@ -424,10 +433,10 @@ static void macvlan_set_mac_lists(struct net_device *dev) bitmap_zero(filter, MACVLAN_MC_FILTER_SZ); netdev_for_each_mc_addr(ha, dev) { - __set_bit(mc_hash(ha->addr), filter); + __set_bit(mc_hash(vlan, ha->addr), filter); } - __set_bit(mc_hash(dev->broadcast), filter); + __set_bit(mc_hash(vlan, dev->broadcast), filter); bitmap_copy(vlan->mc_filter, filter, MACVLAN_MC_FILTER_SZ); } -- cgit From 1690be63a27b20ae65c792729a44f5970561ffa4 Mon Sep 17 00:00:00 2001 From: Vlad Yasevich Date: Wed, 13 Feb 2013 12:00:18 +0000 Subject: bridge: Add vlan support to static neighbors When a user adds bridge neighbors, allow him to specify VLAN id. If the VLAN id is not specified, the neighbor will be added for VLANs currently in the ports filter list. If no VLANs are configured on the port, we use vlan 0 and only add 1 entry. Signed-off-by: Vlad Yasevich Acked-by: Jitendra Kalsaria Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/macvlan.c') diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index e4b8078e88a9..defcd8a85744 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -599,7 +599,7 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], return err; } -static int macvlan_fdb_del(struct ndmsg *ndm, +static int macvlan_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr) { -- cgit