examples/vhost_scsi: replace strncpy with strlcpy
[dpdk.git] / examples / ip_pipeline / action.c
index 2cedb24..a29c2b3 100644 (file)
@@ -6,6 +6,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <rte_string_fns.h>
+
 #include "action.h"
 #include "hash_func.h"
 
@@ -133,7 +135,7 @@ port_in_action_profile_create(const char *name,
        }
 
        /* Node fill in */
-       strncpy(profile->name, name, sizeof(profile->name));
+       strlcpy(profile->name, name, sizeof(profile->name));
        memcpy(&profile->params, params, sizeof(*params));
        profile->ap = ap;
 
@@ -186,6 +188,48 @@ table_action_profile_create(const char *name,
                ((params->action_mask & (1LLU << RTE_TABLE_ACTION_FWD)) == 0))
                return NULL;
 
+       if ((params->action_mask & (1LLU << RTE_TABLE_ACTION_LB)) &&
+               (params->lb.f_hash == NULL)) {
+               switch (params->lb.key_size) {
+               case 8:
+                       params->lb.f_hash = hash_default_key8;
+                       break;
+
+               case 16:
+                       params->lb.f_hash = hash_default_key16;
+                       break;
+
+               case 24:
+                       params->lb.f_hash = hash_default_key24;
+                       break;
+
+               case 32:
+                       params->lb.f_hash = hash_default_key32;
+                       break;
+
+               case 40:
+                       params->lb.f_hash = hash_default_key40;
+                       break;
+
+               case 48:
+                       params->lb.f_hash = hash_default_key48;
+                       break;
+
+               case 56:
+                       params->lb.f_hash = hash_default_key56;
+                       break;
+
+               case 64:
+                       params->lb.f_hash = hash_default_key64;
+                       break;
+
+               default:
+                       return NULL;
+               }
+
+               params->lb.seed = 0;
+       }
+
        /* Resource */
        ap = rte_table_action_profile_create(&params->common);
        if (ap == NULL)
@@ -303,7 +347,7 @@ table_action_profile_create(const char *name,
        }
 
        /* Node fill in */
-       strncpy(profile->name, name, sizeof(profile->name));
+       strlcpy(profile->name, name, sizeof(profile->name));
        memcpy(&profile->params, params, sizeof(*params));
        profile->ap = ap;