All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mahesh Bandewar <maheshb@google.com>
To: Jiri Benc <jbenc@redhat.com>
Cc: linux-netdev <netdev@vger.kernel.org>, Dan Williams <dcbw@redhat.com>
Subject: Re: [PATCH net] ipvlan: fix addr hash list corruption
Date: Mon, 23 Mar 2015 18:10:01 -0700	[thread overview]
Message-ID: <CAF2d9jgbJ793VygsX0vmPDP-2mttVn_eT26NdirkaKg-hQ7FYw@mail.gmail.com> (raw)
In-Reply-To: <2ca7312e5e3df10ce129315f89c3ab5d82d4d428.1427145009.git.jbenc@redhat.com>

On Mon, Mar 23, 2015 at 2:10 PM, Jiri Benc <jbenc@redhat.com> wrote:
> When ipvlan interface with IP addresses attached is brought down and then
> deleted, the assigned addresses are deleted twice from the address hash
> list, first on the interface down and second on the link deletion.
> Similarly, when an address is added while the interface is down, it is added
> second time once the interface is brought up.
>
Presumably this is creating problems for you and I'm not sure why? Do
you have a script  / (sequence of commands) to produce this condition?

ipvlan_ht_addr_del() does use synchronize_rcu() expect when the device
in dismantle state. Could that be a reason?

> Check the interface status before adding/removing to the hash list in the
> notifiers.
>
> Reported-by: Dan Williams <dcbw@redhat.com>
> Signed-off-by: Jiri Benc <jbenc@redhat.com>
> ---
>  drivers/net/ipvlan/ipvlan_main.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
> index 4f4099d5603d..04cfa7a13645 100644
> --- a/drivers/net/ipvlan/ipvlan_main.c
> +++ b/drivers/net/ipvlan/ipvlan_main.c
> @@ -504,7 +504,8 @@ static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
>
>         if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) {
>                 list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) {
> -                       ipvlan_ht_addr_del(addr, !dev->dismantle);
> +                       if (netif_running(dev))
> +                               ipvlan_ht_addr_del(addr, !dev->dismantle);
>                         list_del_rcu(&addr->anode);
>                 }
>         }
> @@ -622,7 +623,8 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
>         addr->atype = IPVL_IPV6;
>         list_add_tail_rcu(&addr->anode, &ipvlan->addrs);
>         ipvlan->ipv6cnt++;
> -       ipvlan_ht_addr_add(ipvlan, addr);
> +       if (netif_running(ipvlan->dev))
> +               ipvlan_ht_addr_add(ipvlan, addr);
>
>         return 0;
>  }
> @@ -635,7 +637,8 @@ static void ipvlan_del_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
>         if (!addr)
>                 return;
>
> -       ipvlan_ht_addr_del(addr, true);
> +       if (netif_running(ipvlan->dev))
> +               ipvlan_ht_addr_del(addr, true);
>         list_del_rcu(&addr->anode);
>         ipvlan->ipv6cnt--;
>         WARN_ON(ipvlan->ipv6cnt < 0);
> @@ -690,7 +693,8 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
>         addr->atype = IPVL_IPV4;
>         list_add_tail_rcu(&addr->anode, &ipvlan->addrs);
>         ipvlan->ipv4cnt++;
> -       ipvlan_ht_addr_add(ipvlan, addr);
> +       if (netif_running(ipvlan->dev))
> +               ipvlan_ht_addr_add(ipvlan, addr);
>         ipvlan_set_broadcast_mac_filter(ipvlan, true);
>
>         return 0;
> @@ -704,7 +708,8 @@ static void ipvlan_del_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
>         if (!addr)
>                 return;
>
> -       ipvlan_ht_addr_del(addr, true);
> +       if (netif_running(ipvlan->dev))
> +               ipvlan_ht_addr_del(addr, true);
>         list_del_rcu(&addr->anode);
>         ipvlan->ipv4cnt--;
>         WARN_ON(ipvlan->ipv4cnt < 0);
> --
> 1.8.3.1
>

  reply	other threads:[~2015-03-24  1:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-23 21:10 [PATCH net] ipvlan: fix addr hash list corruption Jiri Benc
2015-03-24  1:10 ` Mahesh Bandewar [this message]
2015-03-24  8:58   ` Jiri Benc
2015-03-24 17:00 ` David Miller
2015-03-24 17:06   ` Jiri Benc
2015-03-24 23:16     ` Mahesh Bandewar
2015-03-25  1:18       ` David Miller
2015-03-25  8:58       ` Jiri Benc
2015-03-25 15:46         ` David Miller
2015-03-25 18:11           ` Mahesh Bandewar
2015-03-25 18:47             ` Dan Williams
2015-03-25 23:21             ` Jiri Benc
2015-03-25 23:49               ` Jiri Benc
2015-03-26  2:15               ` Mahesh Bandewar
2015-03-26  8:45                 ` Jiri Benc
2015-03-27  5:00                   ` Mahesh Bandewar

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=CAF2d9jgbJ793VygsX0vmPDP-2mttVn_eT26NdirkaKg-hQ7FYw@mail.gmail.com \
    --to=maheshb@google.com \
    --cc=dcbw@redhat.com \
    --cc=jbenc@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.