[ovs-dev] [PATCH branch-2.8] lib/tc: Handle error parsing action in nl_parse_single_action

Roi Dayan roid at mellanox.com
Thu Mar 22 13:22:09 UTC 2018


Raise the error up instead of ignoring it.
Before this commit beside an error an incorrect rule was also printed.

Signed-off-by: Roi Dayan <roid at mellanox.com>
Reviewed-by: Paul Blakey <paulb at mellanox.com>
Signed-off-by: Simon Horman <simon.horman at netronome.com>
---
 lib/tc.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/tc.c b/lib/tc.c
index 6f8cd1b9faf7..0d099aa1a9c3 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -570,6 +570,7 @@ nl_parse_single_action(struct nlattr *action, struct tc_flower *flower)
     struct nlattr *stats_attrs[ARRAY_SIZE(stats_policy)];
     struct ovs_flow_stats *stats = &flower->stats;
     const struct gnet_stats_basic *bs;
+    int err = 0;
 
     if (!nl_parse_nested(action, act_policy, action_attrs,
                          ARRAY_SIZE(act_policy))) {
@@ -582,16 +583,20 @@ nl_parse_single_action(struct nlattr *action, struct tc_flower *flower)
     act_cookie = action_attrs[TCA_ACT_COOKIE];
 
     if (!strcmp(act_kind, "gact")) {
-        nl_parse_act_drop(act_options, flower);
+        err = nl_parse_act_drop(act_options, flower);
     } else if (!strcmp(act_kind, "mirred")) {
-        nl_parse_act_mirred(act_options, flower);
+        err = nl_parse_act_mirred(act_options, flower);
     } else if (!strcmp(act_kind, "vlan")) {
-        nl_parse_act_vlan(act_options, flower);
+        err = nl_parse_act_vlan(act_options, flower);
     } else if (!strcmp(act_kind, "tunnel_key")) {
-        nl_parse_act_tunnel_key(act_options, flower);
+        err = nl_parse_act_tunnel_key(act_options, flower);
     } else {
         VLOG_ERR_RL(&error_rl, "unknown tc action kind: %s", act_kind);
-        return EINVAL;
+        err = EINVAL;
+    }
+
+    if (err) {
+        return err;
     }
 
     if (act_cookie) {
-- 
2.7.0



More information about the dev mailing list