From: Samuel Gauthier <samuel.gauthier@6wind.com>
To: Pravin Shelar <pshelar@nicira.com>,
"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, dev@openvswitch.org,
Samuel Gauthier <samuel.gauthier@6wind.com>
Subject: [PATCH net-next 2/2] ovs: support to refresh a flow via netlink
Date: Wed, 16 Mar 2016 16:07:52 +0100 [thread overview]
Message-ID: <1458140872-22438-3-git-send-email-samuel.gauthier@6wind.com> (raw)
In-Reply-To: <1458140872-22438-1-git-send-email-samuel.gauthier@6wind.com>
The used parameter of a flow tells us when it was used for the last
time. It is possible to set this parameter to 0 using the
OVS_FLOW_ATTR_CLEAR attribute, which means 'never used'. But it is not
possible to set this parameter to 'now'.
With this commit, adding OVS_FLOW_ATTR_USED to a 'set flow' netlink
message refreshes the flow used time to the current time. The value in
OVS_FLOW_ATTR_USED attribute is not used in this case.
Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com>
---
net/openvswitch/datapath.c | 2 ++
net/openvswitch/flow.c | 6 ++++++
net/openvswitch/flow.h | 1 +
3 files changed, 9 insertions(+)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 8c6dcffe9b62..f2050af3965a 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1183,6 +1183,8 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info)
/* Clear stats. */
if (a[OVS_FLOW_ATTR_CLEAR])
ovs_flow_stats_clear(flow);
+ if (a[OVS_FLOW_ATTR_USED])
+ ovs_flow_refresh(flow);
ovs_unlock();
if (reply)
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 831db351fef9..602795dd3656 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -167,6 +167,12 @@ void ovs_flow_stats_get(const struct sw_flow *flow,
}
}
+/* Must be called with rcu_read_lock or ovs_mutex. */
+void ovs_flow_refresh(struct sw_flow *flow)
+{
+ ovs_flow_stats_update(flow, 0, 0, 0);
+}
+
/* Called with ovs_mutex. */
void ovs_flow_stats_clear(struct sw_flow *flow)
{
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h
index 51e10c4b1ce6..4b6b64c999ed 100644
--- a/net/openvswitch/flow.h
+++ b/net/openvswitch/flow.h
@@ -214,6 +214,7 @@ void ovs_flow_stats_update_skb(struct sw_flow *, __be16 tcp_flags,
const struct sk_buff *);
void ovs_flow_stats_get(const struct sw_flow *, struct ovs_flow_stats *,
unsigned long *used, __be16 *tcp_flags);
+void ovs_flow_refresh(struct sw_flow *);
void ovs_flow_stats_clear(struct sw_flow *);
u64 ovs_flow_used_time(unsigned long flow_jiffies);
--
2.2.1.62.g3f15098
next prev parent reply other threads:[~2016-03-16 15:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-16 15:07 [PATCH net-next 0/2] ovs: refresh a flow via netlink Samuel Gauthier
2016-03-16 15:07 ` [PATCH net-next 1/2] ovs: split ovs_flow_stats_update into skb and stats Samuel Gauthier
2016-03-16 15:07 ` Samuel Gauthier [this message]
[not found] ` <1458140872-22438-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2016-03-16 23:23 ` [PATCH net-next 0/2] ovs: refresh a flow via netlink Jesse Gross
2016-03-17 16:24 ` Samuel Gauthier
[not found] ` <CAMEOZh+TR3S+30e+u9yVH04XN2Z26WEnhNK=t7DFq8YaBmjFyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-17 22:54 ` Jesse Gross
2016-03-17 3:35 ` 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=1458140872-22438-3-git-send-email-samuel.gauthier@6wind.com \
--to=samuel.gauthier@6wind.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=netdev@vger.kernel.org \
--cc=pshelar@nicira.com \
/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).