From: Jay Vosburgh <fubar@us.ibm.com>
To: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>, Vlad Yasevich <vyasevic@redhat.com>
Subject: [PATCH v2 net 3/6] net/core: __hw_addr_sync_one / _multiple broken
Date: Fri, 31 May 2013 14:57:28 -0700 [thread overview]
Message-ID: <1370037451-29466-4-git-send-email-fubar@us.ibm.com> (raw)
In-Reply-To: <1370037451-29466-1-git-send-email-fubar@us.ibm.com>
Currently, __hw_addr_sync_one is called in a loop by
__hw_addr_sync_multiple to sync each of a "from" device's hw addresses
to a "to" device. __hw_addr_sync_one calls __hw_addr_add_ex to attempt
to add each address. __hw_addr_add_ex is called with global=false, and
sync=true.
__hw_addr_add_ex checks to see if the new address matches an
address already on the list. If so, it tests global and sync. In this
case, sync=true, and it then checks if the address is already synced,
and if so, returns 0.
This 0 return causes __hw_addr_sync_one to increment the sync_cnt
and refcount for the "from" list's address entry, even though the address
is already synced and has a reference and sync_cnt. This will cause
the sync_cnt and refcount to increment without bound every time an
addresses is added to the "from" device and synced to the "to" device.
The fix here has two parts:
First, when __hw_addr_add_ex finds the address already exists
and is synced, return -EEXIST instead of 0.
Second, __hw_addr_sync_one checks the error return for -EEXIST,
and if so, it (a) does not add a refcount/sync_cnt, and (b) returns 0
itself so that __hw_addr_sync_multiple will not return an error.
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Cc: Vlad Yasevich <vyasevic@redhat.com>
---
net/core/dev_addr_lists.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index c858e81..8e2c2ef 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -67,7 +67,7 @@ static int __hw_addr_add_ex(struct netdev_hw_addr_list *list,
}
if (sync) {
if (ha->synced)
- return 0;
+ return -EEXIST;
else
ha->synced = true;
}
@@ -140,10 +140,13 @@ static int __hw_addr_sync_one(struct netdev_hw_addr_list *to_list,
err = __hw_addr_add_ex(to_list, ha->addr, addr_len, ha->type,
false, true);
- if (err)
+ if (err && err != -EEXIST)
return err;
- ha->sync_cnt++;
- ha->refcount++;
+
+ if (!err) {
+ ha->sync_cnt++;
+ ha->refcount++;
+ }
return 0;
}
--
1.7.1
next prev parent reply other threads:[~2013-05-31 21:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-31 21:57 [PATCH v2 net 0/6] net/core, bonding: dev_uc_sync fixes, bonding update Jay Vosburgh
2013-05-31 21:57 ` [PATCH v2 net 1/6] net/core: __hw_addr_create_ex does not initialize sync_cnt Jay Vosburgh
2013-05-31 21:57 ` [PATCH v2 net 2/6] net/core: __hw_addr_unsync_one "from" address not marked synced Jay Vosburgh
2013-05-31 21:57 ` Jay Vosburgh [this message]
2013-05-31 21:57 ` [PATCH v2 net 4/6] net/core: dev_mc_sync_multiple calls wrong helper Jay Vosburgh
2013-05-31 21:57 ` [PATCH v2 net 5/6] bonding: Convert hw addr handling to sync/unsync, support ucast addresses Jay Vosburgh
2013-06-07 22:06 ` David Miller
2013-05-31 21:57 ` [PATCH v2 net 6/6] bonding: disallow change of MAC if fail_over_mac enabled Jay Vosburgh
2013-06-07 22:06 ` David Miller
2013-05-31 23:58 ` [PATCH v2 net 0/6] net/core, bonding: dev_uc_sync fixes, bonding update David Miller
2013-06-01 17:00 ` Or Gerlitz
2013-06-01 19:04 ` Shawn Bohrer
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=1370037451-29466-4-git-send-email-fubar@us.ibm.com \
--to=fubar@us.ibm.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=vyasevic@redhat.com \
/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).