* [PATCH net-next] ovs: allow nl 'flow set' to use ufid without flow key @ 2016-03-09 17:05 Samuel Gauthier [not found] ` <1457543157-5240-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 8+ messages in thread From: Samuel Gauthier @ 2016-03-09 17:05 UTC (permalink / raw) To: Pravin Shelar, David S. Miller Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA 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. 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. Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com> --- net/openvswitch/datapath.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index deadfdab1bc3..06f15143cf2a 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -1100,21 +1100,20 @@ 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(&sfid, a[OVS_FLOW_ATTR_UFID], log); - ovs_match_init(&match, &key, &mask); - error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], - a[OVS_FLOW_ATTR_MASK], log); + if (a[OVS_FLOW_ATTR_KEY]) { + ovs_match_init(&match, &key, NULL); + error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], + NULL, log); + } else if (!ufid_present) { + OVS_NLERR(log, + "Flow set message rejected, Key attribute missing."); + error = -EINVAL; + } if (error) goto error; -- 2.2.1.62.g3f15098 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev ^ permalink raw reply related [flat|nested] 8+ messages in thread
[parent not found: <1457543157-5240-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH net-next] ovs: allow nl 'flow set' to use ufid without flow key [not found] ` <1457543157-5240-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> @ 2016-03-09 21:35 ` pravin shelar [not found] ` <CAOrHB_DtUjG4DkmFZb+Qj1UAWsTOG3sJH0tQEknnTF-PRQCWzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 8+ messages in thread From: pravin shelar @ 2016-03-09 21:35 UTC (permalink / raw) To: Samuel Gauthier; +Cc: ovs dev, Linux Kernel Network Developers, David S. Miller On Wed, Mar 9, 2016 at 9:05 AM, Samuel Gauthier <samuel.gauthier@6wind.com> 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. > > 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. > > Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com> > --- > net/openvswitch/datapath.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c > index deadfdab1bc3..06f15143cf2a 100644 > --- a/net/openvswitch/datapath.c > +++ b/net/openvswitch/datapath.c > @@ -1100,21 +1100,20 @@ 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(&sfid, a[OVS_FLOW_ATTR_UFID], log); > - ovs_match_init(&match, &key, &mask); > - error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], > - a[OVS_FLOW_ATTR_MASK], log); > + if (a[OVS_FLOW_ATTR_KEY]) { > + ovs_match_init(&match, &key, NULL); > + error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], > + NULL, log); > + } else if (!ufid_present) { > + OVS_NLERR(log, > + "Flow set message rejected, Key attribute missing."); > + error = -EINVAL; > + } Set command sets new action for given flow. The action validation depends on the flow key and mask. so userspace needs to provide the key and mask. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CAOrHB_DtUjG4DkmFZb+Qj1UAWsTOG3sJH0tQEknnTF-PRQCWzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH net-next] ovs: allow nl 'flow set' to use ufid without flow key [not found] ` <CAOrHB_DtUjG4DkmFZb+Qj1UAWsTOG3sJH0tQEknnTF-PRQCWzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2016-03-10 0:25 ` Samuel Gauthier [not found] ` <CAMEOZhK0kBpdS8uOqYqzQs+6LyWh5K3MWL__CRoThmNRnBN2MQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-03-10 16:14 ` [PATCH v2 " Samuel Gauthier 0 siblings, 2 replies; 8+ messages in thread From: Samuel Gauthier @ 2016-03-10 0:25 UTC (permalink / raw) To: pravin shelar; +Cc: ovs dev, Linux Kernel Network Developers, David S. Miller Sorry, I missed that. Thank you for pointing it out. Although, set command is also used to reset the flow statistics, and the action attribute seems optional. Would you find acceptable to make the key attribute mandatory only if the action attribute is provided? The ovs-dpctl command could then be simplified to support ovs-dpctl --clear mod-flow ufid:<ufid> instead of having to specify the flow and action when you just want to reset the statistics of a flow. Le 9 mars 2016 10:35 PM, "pravin shelar" <pshelar@ovn.org> a écrit : > On Wed, Mar 9, 2016 at 9:05 AM, Samuel Gauthier > <samuel.gauthier@6wind.com> 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. > > > > 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. > > > > Signed-off-by: Samuel Gauthier <samuel.gauthier@6wind.com> > > --- > > net/openvswitch/datapath.c | 21 ++++++++++----------- > > 1 file changed, 10 insertions(+), 11 deletions(-) > > > > diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c > > index deadfdab1bc3..06f15143cf2a 100644 > > --- a/net/openvswitch/datapath.c > > +++ b/net/openvswitch/datapath.c > > @@ -1100,21 +1100,20 @@ 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(&sfid, a[OVS_FLOW_ATTR_UFID], > log); > > - ovs_match_init(&match, &key, &mask); > > - error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], > > - a[OVS_FLOW_ATTR_MASK], log); > > + if (a[OVS_FLOW_ATTR_KEY]) { > > + ovs_match_init(&match, &key, NULL); > > + error = ovs_nla_get_match(net, &match, > a[OVS_FLOW_ATTR_KEY], > > + NULL, log); > > + } else if (!ufid_present) { > > + OVS_NLERR(log, > > + "Flow set message rejected, Key attribute > missing."); > > + error = -EINVAL; > > + } > > Set command sets new action for given flow. The action validation > depends on the flow key and mask. so userspace needs to provide the > key and mask. > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CAMEOZhK0kBpdS8uOqYqzQs+6LyWh5K3MWL__CRoThmNRnBN2MQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH net-next] ovs: allow nl 'flow set' to use ufid without flow key [not found] ` <CAMEOZhK0kBpdS8uOqYqzQs+6LyWh5K3MWL__CRoThmNRnBN2MQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2016-03-10 0:32 ` pravin shelar 0 siblings, 0 replies; 8+ messages in thread From: pravin shelar @ 2016-03-10 0:32 UTC (permalink / raw) To: Samuel Gauthier; +Cc: ovs dev, Linux Kernel Network Developers, David S. Miller On Wed, Mar 9, 2016 at 4:25 PM, Samuel Gauthier <samuel.gauthier@6wind.com> wrote: > Sorry, I missed that. Thank you for pointing it out. > > Although, set command is also used to reset the flow statistics, and the > action attribute seems optional. Would you find acceptable to make the key > attribute mandatory only if the action attribute is provided? > > The ovs-dpctl command could then be simplified to support ovs-dpctl --clear > mod-flow ufid:<ufid> instead of having to specify the flow and action when > you just want to reset the statistics of a flow. > That is fine with me. Thanks, Pravin. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 net-next] ovs: allow nl 'flow set' to use ufid without flow key 2016-03-10 0:25 ` Samuel Gauthier [not found] ` <CAMEOZhK0kBpdS8uOqYqzQs+6LyWh5K3MWL__CRoThmNRnBN2MQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2016-03-10 16:14 ` Samuel Gauthier 2016-03-11 2:09 ` [ovs-dev] " pravin shelar [not found] ` <1457626499-26585-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 1 sibling, 2 replies; 8+ messages in thread From: Samuel Gauthier @ 2016-03-10 16:14 UTC (permalink / raw) To: Pravin Shelar, David S. Miller; +Cc: netdev, dev, 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 <samuel.gauthier@6wind.com> --- 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(&sfid, a[OVS_FLOW_ATTR_UFID], log); - ovs_match_init(&match, &key, &mask); - error = ovs_nla_get_match(net, &match, a[OVS_FLOW_ATTR_KEY], - a[OVS_FLOW_ATTR_MASK], log); + if (a[OVS_FLOW_ATTR_KEY]) { + ovs_match_init(&match, &key, &mask); + error = ovs_nla_get_match(net, &match, 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], &key, &mask, log); if (IS_ERR(acts)) { -- 2.2.1.62.g3f15098 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [ovs-dev] [PATCH v2 net-next] ovs: allow nl 'flow set' to use ufid without flow key 2016-03-10 16:14 ` [PATCH v2 " Samuel Gauthier @ 2016-03-11 2:09 ` pravin shelar [not found] ` <1457626499-26585-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 1 sibling, 0 replies; 8+ messages in thread From: pravin shelar @ 2016-03-11 2:09 UTC (permalink / raw) To: Samuel Gauthier Cc: Pravin Shelar, David S. Miller, ovs dev, Linux Kernel Network Developers On Thu, Mar 10, 2016 at 8:14 AM, Samuel Gauthier <samuel.gauthier@6wind.com> 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 <samuel.gauthier@6wind.com> > --- > v2: > - Restore mask init and parsing > - Keep the flow key mandatory when an action is provided > Looks good. Acked-by: Pravin B Shelar <pshelar@ovn.org> ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1457626499-26585-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v2 net-next] ovs: allow nl 'flow set' to use ufid without flow key [not found] ` <1457626499-26585-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> @ 2016-03-11 1:35 ` Simon Horman 2016-03-14 2:20 ` David Miller 1 sibling, 0 replies; 8+ messages in thread From: Simon Horman @ 2016-03-11 1:35 UTC (permalink / raw) To: Samuel Gauthier Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA, David S. Miller 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 <samuel.gauthier@6wind.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 net-next] ovs: allow nl 'flow set' to use ufid without flow key [not found] ` <1457626499-26585-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 2016-03-11 1:35 ` Simon Horman @ 2016-03-14 2:20 ` David Miller 1 sibling, 0 replies; 8+ messages in thread From: David Miller @ 2016-03-14 2:20 UTC (permalink / raw) To: samuel.gauthier-pdR9zngts4EAvxtiuMwx3w Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA From: Samuel Gauthier <samuel.gauthier@6wind.com> 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 <samuel.gauthier@6wind.com> Applied. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-03-14 2:20 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-09 17:05 [PATCH net-next] ovs: allow nl 'flow set' to use ufid without flow key Samuel Gauthier [not found] ` <1457543157-5240-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 2016-03-09 21:35 ` pravin shelar [not found] ` <CAOrHB_DtUjG4DkmFZb+Qj1UAWsTOG3sJH0tQEknnTF-PRQCWzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-03-10 0:25 ` Samuel Gauthier [not found] ` <CAMEOZhK0kBpdS8uOqYqzQs+6LyWh5K3MWL__CRoThmNRnBN2MQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2016-03-10 0:32 ` pravin shelar 2016-03-10 16:14 ` [PATCH v2 " Samuel Gauthier 2016-03-11 2:09 ` [ovs-dev] " pravin shelar [not found] ` <1457626499-26585-1-git-send-email-samuel.gauthier-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> 2016-03-11 1:35 ` Simon Horman 2016-03-14 2:20 ` David Miller
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).