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.gauth...@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