vhost/crypto: add missing user protocol flag
[dpdk.git] / lib / librte_flow_classify / rte_flow_classify.c
index 6fa6a74..6022064 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright(c) 2017 Intel Corporation
  */
 
+#include <rte_string_fns.h>
+#include <rte_compat.h>
 #include <rte_flow_classify.h>
 #include "rte_flow_classify_parse.h"
 #include <rte_flow_driver.h>
@@ -246,8 +248,7 @@ rte_flow_classifier_check_params(struct rte_flow_classifier_params *params)
        }
 
        /* socket */
-       if ((params->socket_id < 0) ||
-           (params->socket_id >= RTE_MAX_NUMA_NODES)) {
+       if (params->socket_id < 0) {
                RTE_FLOW_CLASSIFY_LOG(ERR,
                        "%s: Incorrect value for parameter socket_id\n",
                        __func__);
@@ -285,8 +286,7 @@ rte_flow_classifier_create(struct rte_flow_classifier_params *params)
        }
 
        /* Save input parameters */
-       snprintf(cls->name, RTE_FLOW_CLASSIFIER_MAX_NAME_SZ, "%s",
-                       params->name);
+       strlcpy(cls->name, params->name, RTE_FLOW_CLASSIFIER_MAX_NAME_SZ);
 
        cls->socket_id = params->socket_id;
 
@@ -417,7 +417,6 @@ static struct rte_flow_classify_rule *
 allocate_acl_ipv4_5tuple_rule(struct rte_flow_classifier *cls)
 {
        struct rte_flow_classify_rule *rule;
-       int log_level;
 
        rule = malloc(sizeof(struct rte_flow_classify_rule));
        if (!rule)
@@ -466,9 +465,7 @@ allocate_acl_ipv4_5tuple_rule(struct rte_flow_classifier *cls)
                        cls->ntuple_filter.dst_port_mask;
        rule->rules.u.ipv4_5tuple.dst_port = cls->ntuple_filter.dst_port;
 
-       log_level = rte_log_get_level(librte_flow_classify_logtype);
-
-       if (log_level == RTE_LOG_DEBUG)
+       if (rte_log_can_log(librte_flow_classify_logtype, RTE_LOG_DEBUG))
                print_acl_ipv4_key_add(&rule->u.key.key_add);
 
        /* key delete values */
@@ -476,7 +473,7 @@ allocate_acl_ipv4_5tuple_rule(struct rte_flow_classifier *cls)
               &rule->u.key.key_add.field_value[PROTO_FIELD_IPV4],
               NUM_FIELDS_IPV4 * sizeof(struct rte_acl_field));
 
-       if (log_level == RTE_LOG_DEBUG)
+       if (rte_log_can_log(librte_flow_classify_logtype, RTE_LOG_DEBUG))
                print_acl_ipv4_key_delete(&rule->u.key.key_del);
 
        return rule;
@@ -560,6 +557,7 @@ rte_flow_classify_table_entry_add(struct rte_flow_classifier *cls,
                        return rule;
                }
        }
+       free(rule);
        return NULL;
 }
 
@@ -633,9 +631,7 @@ action_apply(struct rte_flow_classifier *cls,
                }
                if (count) {
                        ret = 0;
-                       ntuple_stats =
-                               (struct rte_flow_classify_ipv4_5tuple_stats *)
-                               stats->stats;
+                       ntuple_stats = stats->stats;
                        ntuple_stats->counter1 = count;
                        ntuple_stats->ipv4_5tuple = rule->rules.u.ipv4_5tuple;
                }
@@ -673,10 +669,7 @@ rte_flow_classifier_query(struct rte_flow_classifier *cls,
        return ret;
 }
 
-RTE_INIT(librte_flow_classify_init_log);
-
-static void
-librte_flow_classify_init_log(void)
+RTE_INIT(librte_flow_classify_init_log)
 {
        librte_flow_classify_logtype =
                rte_log_register("lib.flow_classify");