From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
To: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>
Cc: Mahesh Bandewar <maheshb@google.com>, Jiri Benc <jbenc@redhat.com>
Subject: [PATCH v2 1/5] ipvlan: remove counters of ipv4 and ipv6 addresses
Date: Fri, 03 Jul 2015 15:58:36 +0300 [thread overview]
Message-ID: <20150703125836.24121.15213.stgit@buzz> (raw)
In-Reply-To: <20150703125132.24121.50592.stgit@buzz>
They are unused after commit f631c44bbe15 ("ipvlan: Always set broadcast bit in
multicast filter").
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
drivers/net/ipvlan/ipvlan.h | 2 -
drivers/net/ipvlan/ipvlan_main.c | 65 +++++++++++++++-----------------------
2 files changed, 26 insertions(+), 41 deletions(-)
diff --git a/drivers/net/ipvlan/ipvlan.h b/drivers/net/ipvlan/ipvlan.h
index 953a97492fab..68e2549c28c6 100644
--- a/drivers/net/ipvlan/ipvlan.h
+++ b/drivers/net/ipvlan/ipvlan.h
@@ -67,8 +67,6 @@ struct ipvl_dev {
struct ipvl_port *port;
struct net_device *phy_dev;
struct list_head addrs;
- int ipv4cnt;
- int ipv6cnt;
struct ipvl_pcpu_stats __percpu *pcpu_stats;
DECLARE_BITMAP(mac_filters, IPVLAN_MAC_FILTER_SIZE);
netdev_features_t sfeatures;
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 1acc283160d9..62577b3f01f2 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -153,10 +153,9 @@ static int ipvlan_open(struct net_device *dev)
else
dev->flags &= ~IFF_NOARP;
- if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) {
- list_for_each_entry(addr, &ipvlan->addrs, anode)
- ipvlan_ht_addr_add(ipvlan, addr);
- }
+ list_for_each_entry(addr, &ipvlan->addrs, anode)
+ ipvlan_ht_addr_add(ipvlan, addr);
+
return dev_uc_add(phy_dev, phy_dev->dev_addr);
}
@@ -171,10 +170,9 @@ static int ipvlan_stop(struct net_device *dev)
dev_uc_del(phy_dev, phy_dev->dev_addr);
- if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) {
- list_for_each_entry(addr, &ipvlan->addrs, anode)
- ipvlan_ht_addr_del(addr, !dev->dismantle);
- }
+ list_for_each_entry(addr, &ipvlan->addrs, anode)
+ ipvlan_ht_addr_del(addr, !dev->dismantle);
+
return 0;
}
@@ -471,8 +469,6 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev,
ipvlan->port = port;
ipvlan->sfeatures = IPVLAN_FEATURES;
INIT_LIST_HEAD(&ipvlan->addrs);
- ipvlan->ipv4cnt = 0;
- ipvlan->ipv6cnt = 0;
/* TODO Probably put random address here to be presented to the
* world but keep using the physical-dev address for the outgoing
@@ -508,12 +504,11 @@ static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
struct ipvl_dev *ipvlan = netdev_priv(dev);
struct ipvl_addr *addr, *next;
- if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) {
- list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) {
- ipvlan_ht_addr_del(addr, !dev->dismantle);
- list_del(&addr->anode);
- }
+ list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) {
+ ipvlan_ht_addr_del(addr, !dev->dismantle);
+ list_del(&addr->anode);
}
+
list_del_rcu(&ipvlan->pnode);
unregister_netdevice_queue(dev, head);
netdev_upper_dev_unlink(ipvlan->phy_dev, dev);
@@ -627,8 +622,9 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
memcpy(&addr->ip6addr, ip6_addr, sizeof(struct in6_addr));
addr->atype = IPVL_IPV6;
list_add_tail(&addr->anode, &ipvlan->addrs);
- ipvlan->ipv6cnt++;
- /* If the interface is not up, the address will be added to the hash
+
+ /*
+ * If the interface is not up, the address will be added to the hash
* list by ipvlan_open.
*/
if (netif_running(ipvlan->dev))
@@ -642,16 +638,11 @@ static void ipvlan_del_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
struct ipvl_addr *addr;
addr = ipvlan_find_addr(ipvlan, ip6_addr, true);
- if (!addr)
- return;
-
- ipvlan_ht_addr_del(addr, true);
- list_del(&addr->anode);
- ipvlan->ipv6cnt--;
- WARN_ON(ipvlan->ipv6cnt < 0);
- kfree_rcu(addr, rcu);
-
- return;
+ if (addr) {
+ ipvlan_ht_addr_del(addr, true);
+ list_del(&addr->anode);
+ kfree_rcu(addr, rcu);
+ }
}
static int ipvlan_addr6_event(struct notifier_block *unused,
@@ -699,8 +690,9 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
memcpy(&addr->ip4addr, ip4_addr, sizeof(struct in_addr));
addr->atype = IPVL_IPV4;
list_add_tail(&addr->anode, &ipvlan->addrs);
- ipvlan->ipv4cnt++;
- /* If the interface is not up, the address will be added to the hash
+
+ /*
+ * If the interface is not up, the address will be added to the hash
* list by ipvlan_open.
*/
if (netif_running(ipvlan->dev))
@@ -714,16 +706,11 @@ static void ipvlan_del_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
struct ipvl_addr *addr;
addr = ipvlan_find_addr(ipvlan, ip4_addr, false);
- if (!addr)
- return;
-
- ipvlan_ht_addr_del(addr, true);
- list_del(&addr->anode);
- ipvlan->ipv4cnt--;
- WARN_ON(ipvlan->ipv4cnt < 0);
- kfree_rcu(addr, rcu);
-
- return;
+ if (addr) {
+ ipvlan_ht_addr_del(addr, true);
+ list_del(&addr->anode);
+ kfree_rcu(addr, rcu);
+ }
}
static int ipvlan_addr4_event(struct notifier_block *unused,
next prev parent reply other threads:[~2015-07-03 13:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 12:58 [PATCH v2 0/5] ipvlan: fix ipv6 autoconfiguration Konstantin Khlebnikov
2015-07-03 12:58 ` Konstantin Khlebnikov [this message]
2015-07-08 3:59 ` [PATCH v2 1/5] ipvlan: remove counters of ipv4 and ipv6 addresses Mahesh Bandewar
2015-07-03 12:58 ` [PATCH v2 2/5] ipvlan: plug memory leak in ipvlan_link_delete Konstantin Khlebnikov
2015-07-03 12:58 ` [PATCH v2 3/5] ipvlan: unhash addresses without synchronize_rcu Konstantin Khlebnikov
2015-07-03 12:58 ` [PATCH v2 4/5] ipvlan: protect addresses with internal spinlock Konstantin Khlebnikov
2015-07-08 4:05 ` Mahesh Bandewar
2015-07-10 12:08 ` Konstantin Khlebnikov
2015-07-03 12:58 ` [PATCH v2 5/5] ipvlan: set dev_id for l2 ports to generate unique IPv6 addresses Konstantin Khlebnikov
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=20150703125836.24121.15213.stgit@buzz \
--to=khlebnikov@yandex-team.ru \
--cc=davem@davemloft.net \
--cc=jbenc@redhat.com \
--cc=maheshb@google.com \
--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).