All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 1/1] net sched: fix reporting the first-time use timestamp
@ 2020-05-17 12:46 Roman Mashak
  2020-05-17 18:47 ` Cong Wang
  2020-05-19  0:33 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Roman Mashak @ 2020-05-17 12:46 UTC (permalink / raw)
  To: davem; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri, Roman Mashak

When a new action is installed, firstuse field of 'tcf_t' is explicitly set
to 0. Value of zero means "new action, not yet used"; as a packet hits the
action, 'firstuse' is stamped with the current jiffies value.

tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.

Fixes: 48d8ee1694dd ("net sched actions: aggregate dumping of actions timeinfo")
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Roman Mashak <mrv@mojatatu.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 include/net/act_api.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/net/act_api.h b/include/net/act_api.h
index c24d7643548e..124bd139886c 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -75,7 +75,8 @@ static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm)
 {
 	dtm->install = jiffies_to_clock_t(jiffies - stm->install);
 	dtm->lastuse = jiffies_to_clock_t(jiffies - stm->lastuse);
-	dtm->firstuse = jiffies_to_clock_t(jiffies - stm->firstuse);
+	dtm->firstuse = stm->firstuse ?
+		jiffies_to_clock_t(jiffies - stm->firstuse) : 0;
 	dtm->expires = jiffies_to_clock_t(stm->expires);
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] net sched: fix reporting the first-time use timestamp
  2020-05-17 12:46 [PATCH net 1/1] net sched: fix reporting the first-time use timestamp Roman Mashak
@ 2020-05-17 18:47 ` Cong Wang
  2020-05-18  1:10   ` Roman Mashak
  2020-05-19  0:33 ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Cong Wang @ 2020-05-17 18:47 UTC (permalink / raw)
  To: Roman Mashak
  Cc: David Miller, Linux Kernel Network Developers, kernel,
	Jamal Hadi Salim, Jiri Pirko

On Sun, May 17, 2020 at 5:47 AM Roman Mashak <mrv@mojatatu.com> wrote:
>
> When a new action is installed, firstuse field of 'tcf_t' is explicitly set
> to 0. Value of zero means "new action, not yet used"; as a packet hits the
> action, 'firstuse' is stamped with the current jiffies value.
>
> tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.

Your patch makes sense to me.

Just one more thing, how about 'lastuse'? It is initialized with jiffies,
not 0, it seems we should initialize it to 0 too, as it is not yet used?

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] net sched: fix reporting the first-time use timestamp
  2020-05-17 18:47 ` Cong Wang
@ 2020-05-18  1:10   ` Roman Mashak
  2020-05-18 12:43     ` Jamal Hadi Salim
  0 siblings, 1 reply; 6+ messages in thread
From: Roman Mashak @ 2020-05-18  1:10 UTC (permalink / raw)
  To: Cong Wang
  Cc: David Miller, Linux Kernel Network Developers, kernel,
	Jamal Hadi Salim, Jiri Pirko

Cong Wang <xiyou.wangcong@gmail.com> writes:

> On Sun, May 17, 2020 at 5:47 AM Roman Mashak <mrv@mojatatu.com> wrote:
>>
>> When a new action is installed, firstuse field of 'tcf_t' is explicitly set
>> to 0. Value of zero means "new action, not yet used"; as a packet hits the
>> action, 'firstuse' is stamped with the current jiffies value.
>>
>> tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.
>
> Your patch makes sense to me.
>
> Just one more thing, how about 'lastuse'? It is initialized with jiffies,
> not 0, it seems we should initialize it to 0 too, as it is not yet used?

Yes, exactly. I was planning to send a separate patch for this.

Thanks for review, Cong.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] net sched: fix reporting the first-time use timestamp
  2020-05-18  1:10   ` Roman Mashak
@ 2020-05-18 12:43     ` Jamal Hadi Salim
  2020-05-18 17:58       ` Cong Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Jamal Hadi Salim @ 2020-05-18 12:43 UTC (permalink / raw)
  To: Roman Mashak, Cong Wang
  Cc: David Miller, Linux Kernel Network Developers, kernel, Jiri Pirko

On 2020-05-17 9:10 p.m., Roman Mashak wrote:
> Cong Wang <xiyou.wangcong@gmail.com> writes:
> 
>> On Sun, May 17, 2020 at 5:47 AM Roman Mashak <mrv@mojatatu.com> wrote:
>>>
>>> When a new action is installed, firstuse field of 'tcf_t' is explicitly set
>>> to 0. Value of zero means "new action, not yet used"; as a packet hits the
>>> action, 'firstuse' is stamped with the current jiffies value.
>>>
>>> tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.
>>
>> Your patch makes sense to me.
>>
>> Just one more thing, how about 'lastuse'? It is initialized with jiffies,
>> not 0, it seems we should initialize it to 0 too, as it is not yet used?
> 
> Yes, exactly. I was planning to send a separate patch for this.
> 
> Thanks for review, Cong.
> 

For these corner cases, firstuse using zero to indicate
"has not been used" is not ambigious.
lastuse has ambiguity because zero now has two meanings
if you check for the corner case in the kernel.
1)Zero is a legit value when dumping or
getting (example an action was just hit when you dumped).
2) zero also now means "has not been used".

My suggestion is to leave this alone in the kernel.
In user space/iproute2 check if lastused and created
are equal and declare "has not been used".

cheers,
jamal



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] net sched: fix reporting the first-time use timestamp
  2020-05-18 12:43     ` Jamal Hadi Salim
@ 2020-05-18 17:58       ` Cong Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Cong Wang @ 2020-05-18 17:58 UTC (permalink / raw)
  To: Jamal Hadi Salim
  Cc: Roman Mashak, David Miller, Linux Kernel Network Developers,
	kernel, Jiri Pirko

On Mon, May 18, 2020 at 5:43 AM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
>
> On 2020-05-17 9:10 p.m., Roman Mashak wrote:
> > Cong Wang <xiyou.wangcong@gmail.com> writes:
> >
> >> On Sun, May 17, 2020 at 5:47 AM Roman Mashak <mrv@mojatatu.com> wrote:
> >>>
> >>> When a new action is installed, firstuse field of 'tcf_t' is explicitly set
> >>> to 0. Value of zero means "new action, not yet used"; as a packet hits the
> >>> action, 'firstuse' is stamped with the current jiffies value.
> >>>
> >>> tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.
> >>
> >> Your patch makes sense to me.
> >>
> >> Just one more thing, how about 'lastuse'? It is initialized with jiffies,
> >> not 0, it seems we should initialize it to 0 too, as it is not yet used?
> >
> > Yes, exactly. I was planning to send a separate patch for this.
> >
> > Thanks for review, Cong.
> >
>
> For these corner cases, firstuse using zero to indicate
> "has not been used" is not ambigious.
> lastuse has ambiguity because zero now has two meanings
> if you check for the corner case in the kernel.
> 1)Zero is a legit value when dumping or
> getting (example an action was just hit when you dumped).
> 2) zero also now means "has not been used".

Well, technically firstuse could be a legit 0 too, when the
action was just hit for the first time right when dumping.
So the ambiguity is same for both.

>
> My suggestion is to leave this alone in the kernel.
> In user space/iproute2 check if lastused and created
> are equal and declare "has not been used".

Sounds a good idea to me.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net 1/1] net sched: fix reporting the first-time use timestamp
  2020-05-17 12:46 [PATCH net 1/1] net sched: fix reporting the first-time use timestamp Roman Mashak
  2020-05-17 18:47 ` Cong Wang
@ 2020-05-19  0:33 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2020-05-19  0:33 UTC (permalink / raw)
  To: mrv; +Cc: netdev, kernel, jhs, xiyou.wangcong, jiri

From: Roman Mashak <mrv@mojatatu.com>
Date: Sun, 17 May 2020 08:46:31 -0400

> When a new action is installed, firstuse field of 'tcf_t' is explicitly set
> to 0. Value of zero means "new action, not yet used"; as a packet hits the
> action, 'firstuse' is stamped with the current jiffies value.
> 
> tcf_tm_dump() should return 0 for firstuse if action has not yet been hit.
> 
> Fixes: 48d8ee1694dd ("net sched actions: aggregate dumping of actions timeinfo")
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Signed-off-by: Roman Mashak <mrv@mojatatu.com>
> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-19  0:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17 12:46 [PATCH net 1/1] net sched: fix reporting the first-time use timestamp Roman Mashak
2020-05-17 18:47 ` Cong Wang
2020-05-18  1:10   ` Roman Mashak
2020-05-18 12:43     ` Jamal Hadi Salim
2020-05-18 17:58       ` Cong Wang
2020-05-19  0:33 ` David Miller

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.