From: Vlad Yasevich <vyasevic@redhat.com>
To: netdev@vger.kernel.org
Cc: Vlad Yasevich <vyasevic@redhat.com>,
Andrey Dmitrov <andrey.dmitrov@oktetlabs.ru>
Subject: [PATCH] net: Correctly sync addresses from multiple sources to single device
Date: Fri, 17 Jan 2014 14:52:12 -0500 [thread overview]
Message-ID: <1389988332-22472-1-git-send-email-vyasevic@redhat.com> (raw)
When we have multiple devices attempting to sync the same address
to a single destination, each device should be permitted to sync
it once. To accomplish this, pass the sync count of the source
address to __hw_addr_add_ex(). 'sync_cnt' tracks how many time
a given address has been successfully synced. If the address
is found in the destination list, but the 'sync_cnt' of the source
is 0, then this address has not been synced from this interface
and we need to allow the sync operation to succeed thus incrementing
reference counts.
Reported-by: Andrey Dmitrov <andrey.dmitrov@oktetlabs.ru>
CC: Andrey Dmitrov <andrey.dmitrov@oktetlabs.ru>
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
net/core/dev_addr_lists.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index ec40a84..bd1b880 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -48,7 +48,8 @@ static int __hw_addr_create_ex(struct netdev_hw_addr_list *list,
static int __hw_addr_add_ex(struct netdev_hw_addr_list *list,
const unsigned char *addr, int addr_len,
- unsigned char addr_type, bool global, bool sync)
+ unsigned char addr_type, bool global, bool sync,
+ int sync_count)
{
struct netdev_hw_addr *ha;
@@ -66,7 +67,7 @@ static int __hw_addr_add_ex(struct netdev_hw_addr_list *list,
ha->global_use = true;
}
if (sync) {
- if (ha->synced)
+ if (ha->synced && sync_count)
return -EEXIST;
else
ha->synced = true;
@@ -84,7 +85,8 @@ static int __hw_addr_add(struct netdev_hw_addr_list *list,
const unsigned char *addr, int addr_len,
unsigned char addr_type)
{
- return __hw_addr_add_ex(list, addr, addr_len, addr_type, false, false);
+ return __hw_addr_add_ex(list, addr, addr_len, addr_type, false, false,
+ 0);
}
static int __hw_addr_del_entry(struct netdev_hw_addr_list *list,
@@ -139,7 +141,7 @@ static int __hw_addr_sync_one(struct netdev_hw_addr_list *to_list,
int err;
err = __hw_addr_add_ex(to_list, ha->addr, addr_len, ha->type,
- false, true);
+ false, true, ha->sync_count);
if (err && err != -EEXIST)
return err;
@@ -676,7 +678,7 @@ static int __dev_mc_add(struct net_device *dev, const unsigned char *addr,
netif_addr_lock_bh(dev);
err = __hw_addr_add_ex(&dev->mc, addr, dev->addr_len,
- NETDEV_HW_ADDR_T_MULTICAST, global, false);
+ NETDEV_HW_ADDR_T_MULTICAST, global, false, 0);
if (!err)
__dev_set_rx_mode(dev);
netif_addr_unlock_bh(dev);
--
1.8.4.2
next reply other threads:[~2014-01-17 19:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-17 19:52 Vlad Yasevich [this message]
2014-01-21 22:53 ` [PATCH] net: Correctly sync addresses from multiple sources to single device David Miller
2014-01-22 15:30 ` Vlad Yasevich
2014-01-22 14:18 ` Andrey Dmitrov
2014-01-22 15:06 ` Vlad Yasevich
2014-01-22 17:54 ` [PATCH v2] " Vlad Yasevich
2014-01-23 21:07 ` David Miller
2014-01-24 11:33 ` Andrey Dmitrov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389988332-22472-1-git-send-email-vyasevic@redhat.com \
--to=vyasevic@redhat.com \
--cc=andrey.dmitrov@oktetlabs.ru \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).