Re: [PATCH v2 net-next] ovs: allow nl 'flow set' to use ufid without flow key

2016-03-13 Thread David Miller
From: Samuel Gauthier 
Date: Thu, 10 Mar 2016 17:14:59 +0100

> When we want to change a flow using netlink, we have to identify it to
> be able to perform a lookup. Both the flow key and unique flow ID
> (ufid) are valid identifiers, but we always have to specify the flow
> key in the netlink message. When both attributes are there, the ufid
> is used. The flow key is used to validate the actions provided by
> the userland.
> 
> This commit allows to use the ufid without having to provide the flow
> key, as it is already done in the netlink 'flow get' and 'flow del'
> path. The flow key remains mandatory when an action is provided.
> 
> Signed-off-by: Samuel Gauthier 

Applied.


Re: [ovs-dev] [PATCH v2 net-next] ovs: allow nl 'flow set' to use ufid without flow key

2016-03-10 Thread pravin shelar
On Thu, Mar 10, 2016 at 8:14 AM, Samuel Gauthier
 wrote:
> When we want to change a flow using netlink, we have to identify it to
> be able to perform a lookup. Both the flow key and unique flow ID
> (ufid) are valid identifiers, but we always have to specify the flow
> key in the netlink message. When both attributes are there, the ufid
> is used. The flow key is used to validate the actions provided by
> the userland.
>
> This commit allows to use the ufid without having to provide the flow
> key, as it is already done in the netlink 'flow get' and 'flow del'
> path. The flow key remains mandatory when an action is provided.
>
> Signed-off-by: Samuel Gauthier 
> ---
> v2:
>  - Restore mask init and parsing
>  - Keep the flow key mandatory when an action is provided
>
Looks good.

Acked-by: Pravin B Shelar 


Re: [PATCH v2 net-next] ovs: allow nl 'flow set' to use ufid without flow key

2016-03-10 Thread Simon Horman
On Thu, Mar 10, 2016 at 05:14:59PM +0100, Samuel Gauthier wrote:
> When we want to change a flow using netlink, we have to identify it to
> be able to perform a lookup. Both the flow key and unique flow ID
> (ufid) are valid identifiers, but we always have to specify the flow
> key in the netlink message. When both attributes are there, the ufid
> is used. The flow key is used to validate the actions provided by
> the userland.
> 
> This commit allows to use the ufid without having to provide the flow
> key, as it is already done in the netlink 'flow get' and 'flow del'
> path. The flow key remains mandatory when an action is provided.
> 
> Signed-off-by: Samuel Gauthier 

Reviewed-by: Simon Horman 


[PATCH v2 net-next] ovs: allow nl 'flow set' to use ufid without flow key

2016-03-10 Thread Samuel Gauthier
When we want to change a flow using netlink, we have to identify it to
be able to perform a lookup. Both the flow key and unique flow ID
(ufid) are valid identifiers, but we always have to specify the flow
key in the netlink message. When both attributes are there, the ufid
is used. The flow key is used to validate the actions provided by
the userland.

This commit allows to use the ufid without having to provide the flow
key, as it is already done in the netlink 'flow get' and 'flow del'
path. The flow key remains mandatory when an action is provided.

Signed-off-by: Samuel Gauthier 
---
v2:
 - Restore mask init and parsing
 - Keep the flow key mandatory when an action is provided

 net/openvswitch/datapath.c | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index deadfdab1bc3..db6858f2f67a 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -1100,26 +1100,32 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct 
genl_info *info)
struct sw_flow_match match;
struct sw_flow_id sfid;
u32 ufid_flags = ovs_nla_get_ufid_flags(a[OVS_FLOW_ATTR_UFID_FLAGS]);
-   int error;
+   int error = 0;
bool log = !a[OVS_FLOW_ATTR_PROBE];
bool ufid_present;
 
-   /* Extract key. */
-   error = -EINVAL;
-   if (!a[OVS_FLOW_ATTR_KEY]) {
-   OVS_NLERR(log, "Flow key attribute not present in set flow.");
-   goto error;
-   }
-
ufid_present = ovs_nla_get_ufid(, a[OVS_FLOW_ATTR_UFID], log);
-   ovs_match_init(, , );
-   error = ovs_nla_get_match(net, , a[OVS_FLOW_ATTR_KEY],
- a[OVS_FLOW_ATTR_MASK], log);
+   if (a[OVS_FLOW_ATTR_KEY]) {
+   ovs_match_init(, , );
+   error = ovs_nla_get_match(net, , a[OVS_FLOW_ATTR_KEY],
+ a[OVS_FLOW_ATTR_MASK], log);
+   } else if (!ufid_present) {
+   OVS_NLERR(log,
+ "Flow set message rejected, Key attribute missing.");
+   error = -EINVAL;
+   }
if (error)
goto error;
 
/* Validate actions. */
if (a[OVS_FLOW_ATTR_ACTIONS]) {
+   if (!a[OVS_FLOW_ATTR_KEY]) {
+   OVS_NLERR(log,
+ "Flow key attribute not present in set 
flow.");
+   error = -EINVAL;
+   goto error;
+   }
+
acts = get_flow_actions(net, a[OVS_FLOW_ATTR_ACTIONS], ,
, log);
if (IS_ERR(acts)) {
-- 
2.2.1.62.g3f15098