Netdev List
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	James Morris <jmorris@namei.org>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	Patrick McHardy <kaber@trash.net>
Subject: Re: [PATCH net-next v4] ipv6: do not overwrite inetpeer metrics prematurely
Date: Thu, 27 Mar 2014 08:43:17 +0100	[thread overview]
Message-ID: <1728201.2Lp3R0hfkV@alaris> (raw)
In-Reply-To: <20140327050618.GK22086@order.stressinduktion.org>

On Thursday 27 of March 2014 06:06:18 Hannes Frederic Sowa wrote:
> On Wed, Mar 26, 2014 at 05:05:03PM +0100, Michal Kubecek wrote:
> > diff --git a/include/net/dst.h b/include/net/dst.h
> > index e01a826..8cf6772 100644
> > --- a/include/net/dst.h
> > +++ b/include/net/dst.h
> > @@ -57,6 +57,7 @@ struct dst_entry {
> > 
> >  #define DST_FAKE_RTABLE		0x0040
> >  #define DST_XFRM_TUNNEL		0x0080
> >  #define DST_XFRM_QUEUE		0x0100
> > 
> > +#define DST_KEEP_METRICS	0x0400
> 
> Minor nit: 0x0200
> 
> You jumped over one bit.

Oh yes. This is because of DST_NOPEER which is still in net but was
removed in net-next.

> > diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> > index fba54a4..4e5b19e 100644
> > --- a/net/ipv6/route.c
> > +++ b/net/ipv6/route.c
> > @@ -149,8 +149,10 @@ static u32 *ipv6_cow_metrics(struct dst_entry
> > *dst, unsigned long old)> 
> >  		unsigned long prev, new;
> >  		
> >  		p = peer->metrics;
> > 
> > -		if (inet_metrics_new(peer))
> > +		if (inet_metrics_new(peer) || (dst->flags & DST_KEEP_METRICS)) {
> > 
> >  			memcpy(p, old_p, sizeof(u32) * RTAX_MAX);
> > 
> > +			dst->flags &= ~DST_KEEP_METRICS;
> > +		}
> 
> I wonder if we can make this more concurrency friendly:
> 
> The idea that came to my mind would be to store KEEP_METRICS flag in
> the metrics pointer and introduce new DST_METRICS_FORCE_OVERWRITE
> flag like DST_METRICS_READ_ONLY.

I was also considering this as logically the flag belongs here more
than into the dst_entry flags. For some reason I was afraid it would
be less efficient but now thinking about it again, I don't see why it
should be.

> __DST_METRICS_PTR would have to mask it out, too (so would the check
> in dst_metrics_write_ptr).

I believe the test in dst_metrics_write_ptr() should stay the way it is.
We want to call cow_metrics() whenever the metrics are read only and
consider DST_METRICS_FORCE_OVERWRITE only in ipv6_cow_metrics(). But I
better check again.

> Then cmpxchg would atomically change status of KEEP_METRICS flag, too.

That would be useful. However, I'm more concerned about 

> In fib6_commit_metrics we could then add the flag somehow if dst is
> DST_HOST and mx != NULL.

IMHO it should do so even if mx is null. Otherwise we could end up with
a dst using read only defaults but having old metrics hidden in inetpeer
which would get revived once cow_metrics() is called for any reason.

I'll prepare a patch and test it.

                                                         Michal Kubecek

  reply	other threads:[~2014-03-27  7:43 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-06  9:50 [PATCH net] ipv6: do not overwrite inetpeer metrics prematurely Michal Kubecek
2014-03-06 19:24 ` David Miller
2014-03-06 20:06   ` Michal Kubecek
2014-03-07 12:36     ` [PATCH net v2] " Michal Kubecek
2014-03-07 20:52     ` [PATCH net] " David Miller
2014-03-07 21:38       ` Michal Kubecek
2014-03-08  8:34         ` Hannes Frederic Sowa
2014-03-08  8:06       ` Hannes Frederic Sowa
2014-03-10  0:26         ` David Miller
2014-03-10  0:52           ` Hannes Frederic Sowa
2014-03-10  5:03             ` David Miller
2014-03-10  8:15               ` Michal Kubecek
2014-03-10 12:00                 ` Hannes Frederic Sowa
2014-03-10 13:15                   ` Michal Kubecek
2014-03-11  2:38                   ` David Miller
2014-03-11  9:53                     ` Michal Kubecek
2014-03-11 15:08                       ` Michal Kubecek
2014-03-11 15:20                         ` Hannes Frederic Sowa
2014-03-11 15:39                         ` Michal Kubecek
2014-03-25 19:11                           ` Hannes Frederic Sowa
2014-03-26 15:09                             ` Michal Kubecek
2014-03-26 15:42                             ` [PATCH net-next v3] " Michal Kubecek
2014-03-26 15:50                               ` Hannes Frederic Sowa
2014-03-26 15:56                                 ` Michal Kubecek
2014-03-26 16:05                                 ` [PATCH net-next v4] " Michal Kubecek
2014-03-27  5:06                                   ` Hannes Frederic Sowa
2014-03-27  7:43                                     ` Michal Kubecek [this message]
2014-03-27 12:04                                     ` [PATCH net-next v5] " Michal Kubecek
2014-03-27 16:30                                       ` Hannes Frederic Sowa
2014-03-27 19:09                                         ` David Miller
2014-03-12 20:54                         ` [PATCH net] " David Miller

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=1728201.2Lp3R0hfkV@alaris \
    --to=mkubecek@suse.cz \
    --cc=davem@davemloft.net \
    --cc=hannes@stressinduktion.org \
    --cc=jmorris@namei.org \
    --cc=kaber@trash.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.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