aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ipvlan/ipvlan_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ipvlan/ipvlan_main.c')
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 4f4099d5603d..4fa14208d799 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -505,7 +505,7 @@ static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
505 if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) { 505 if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) {
506 list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) { 506 list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) {
507 ipvlan_ht_addr_del(addr, !dev->dismantle); 507 ipvlan_ht_addr_del(addr, !dev->dismantle);
508 list_del_rcu(&addr->anode); 508 list_del(&addr->anode);
509 } 509 }
510 } 510 }
511 list_del_rcu(&ipvlan->pnode); 511 list_del_rcu(&ipvlan->pnode);
@@ -607,7 +607,7 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
607{ 607{
608 struct ipvl_addr *addr; 608 struct ipvl_addr *addr;
609 609
610 if (ipvlan_addr_busy(ipvlan, ip6_addr, true)) { 610 if (ipvlan_addr_busy(ipvlan->port, ip6_addr, true)) {
611 netif_err(ipvlan, ifup, ipvlan->dev, 611 netif_err(ipvlan, ifup, ipvlan->dev,
612 "Failed to add IPv6=%pI6c addr for %s intf\n", 612 "Failed to add IPv6=%pI6c addr for %s intf\n",
613 ip6_addr, ipvlan->dev->name); 613 ip6_addr, ipvlan->dev->name);
@@ -620,9 +620,13 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
620 addr->master = ipvlan; 620 addr->master = ipvlan;
621 memcpy(&addr->ip6addr, ip6_addr, sizeof(struct in6_addr)); 621 memcpy(&addr->ip6addr, ip6_addr, sizeof(struct in6_addr));
622 addr->atype = IPVL_IPV6; 622 addr->atype = IPVL_IPV6;
623 list_add_tail_rcu(&addr->anode, &ipvlan->addrs); 623 list_add_tail(&addr->anode, &ipvlan->addrs);
624 ipvlan->ipv6cnt++; 624 ipvlan->ipv6cnt++;
625 ipvlan_ht_addr_add(ipvlan, addr); 625 /* If the interface is not up, the address will be added to the hash
626 * list by ipvlan_open.
627 */
628 if (netif_running(ipvlan->dev))
629 ipvlan_ht_addr_add(ipvlan, addr);
626 630
627 return 0; 631 return 0;
628} 632}
@@ -631,12 +635,12 @@ static void ipvlan_del_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
631{ 635{
632 struct ipvl_addr *addr; 636 struct ipvl_addr *addr;
633 637
634 addr = ipvlan_ht_addr_lookup(ipvlan->port, ip6_addr, true); 638 addr = ipvlan_find_addr(ipvlan, ip6_addr, true);
635 if (!addr) 639 if (!addr)
636 return; 640 return;
637 641
638 ipvlan_ht_addr_del(addr, true); 642 ipvlan_ht_addr_del(addr, true);
639 list_del_rcu(&addr->anode); 643 list_del(&addr->anode);
640 ipvlan->ipv6cnt--; 644 ipvlan->ipv6cnt--;
641 WARN_ON(ipvlan->ipv6cnt < 0); 645 WARN_ON(ipvlan->ipv6cnt < 0);
642 kfree_rcu(addr, rcu); 646 kfree_rcu(addr, rcu);
@@ -675,7 +679,7 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
675{ 679{
676 struct ipvl_addr *addr; 680 struct ipvl_addr *addr;
677 681
678 if (ipvlan_addr_busy(ipvlan, ip4_addr, false)) { 682 if (ipvlan_addr_busy(ipvlan->port, ip4_addr, false)) {
679 netif_err(ipvlan, ifup, ipvlan->dev, 683 netif_err(ipvlan, ifup, ipvlan->dev,
680 "Failed to add IPv4=%pI4 on %s intf.\n", 684 "Failed to add IPv4=%pI4 on %s intf.\n",
681 ip4_addr, ipvlan->dev->name); 685 ip4_addr, ipvlan->dev->name);
@@ -688,9 +692,13 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
688 addr->master = ipvlan; 692 addr->master = ipvlan;
689 memcpy(&addr->ip4addr, ip4_addr, sizeof(struct in_addr)); 693 memcpy(&addr->ip4addr, ip4_addr, sizeof(struct in_addr));
690 addr->atype = IPVL_IPV4; 694 addr->atype = IPVL_IPV4;
691 list_add_tail_rcu(&addr->anode, &ipvlan->addrs); 695 list_add_tail(&addr->anode, &ipvlan->addrs);
692 ipvlan->ipv4cnt++; 696 ipvlan->ipv4cnt++;
693 ipvlan_ht_addr_add(ipvlan, addr); 697 /* If the interface is not up, the address will be added to the hash
698 * list by ipvlan_open.
699 */
700 if (netif_running(ipvlan->dev))
701 ipvlan_ht_addr_add(ipvlan, addr);
694 ipvlan_set_broadcast_mac_filter(ipvlan, true); 702 ipvlan_set_broadcast_mac_filter(ipvlan, true);
695 703
696 return 0; 704 return 0;
@@ -700,12 +708,12 @@ static void ipvlan_del_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
700{ 708{
701 struct ipvl_addr *addr; 709 struct ipvl_addr *addr;
702 710
703 addr = ipvlan_ht_addr_lookup(ipvlan->port, ip4_addr, false); 711 addr = ipvlan_find_addr(ipvlan, ip4_addr, false);
704 if (!addr) 712 if (!addr)
705 return; 713 return;
706 714
707 ipvlan_ht_addr_del(addr, true); 715 ipvlan_ht_addr_del(addr, true);
708 list_del_rcu(&addr->anode); 716 list_del(&addr->anode);
709 ipvlan->ipv4cnt--; 717 ipvlan->ipv4cnt--;
710 WARN_ON(ipvlan->ipv4cnt < 0); 718 WARN_ON(ipvlan->ipv4cnt < 0);
711 if (!ipvlan->ipv4cnt) 719 if (!ipvlan->ipv4cnt)