python: properly initialize string length on 64bit systems.
[openvswitch] / lib / multipath.c
index 7d4b541ed42922bcdd8be0d32ee23b81debd0130..af0ebffe4284955bfdfaa275de3a4becfa08d4a5 100644 (file)
@@ -17,6 +17,7 @@
 #include <config.h>
 
 #include "multipath.h"
+#include <arpa/inet.h>
 #include <inttypes.h>
 #include <sys/types.h>
 #include <netinet/in.h>
@@ -99,6 +100,7 @@ hash_symmetric_l4(const struct flow *flow, uint16_t basis)
 
     int i;
 
+    memset(&fields, 0, sizeof fields);
     for (i = 0; i < ETH_ADDR_LEN; i++) {
         fields.eth_addr[i] = flow->dl_src[i] ^ flow->dl_dst[i];
     }
@@ -267,7 +269,10 @@ multipath_format(const struct nx_action_multipath *mp, struct ds *s)
 {
     const char *fields, *algorithm;
 
-    switch ((enum nx_mp_fields) ntohs(mp->fields)) {
+    uint16_t mp_fields    = ntohs(mp->fields);
+    uint16_t mp_algorithm = ntohs(mp->algorithm);
+
+    switch ((enum nx_mp_fields) mp_fields) {
     case NX_MP_FIELDS_ETH_SRC:
         fields = "eth_src";
         break;
@@ -278,7 +283,7 @@ multipath_format(const struct nx_action_multipath *mp, struct ds *s)
         fields = "<unknown>";
     }
 
-    switch ((enum nx_mp_algorithm) ntohs(mp->algorithm)) {
+    switch ((enum nx_mp_algorithm) mp_algorithm) {
     case NX_MP_ALG_MODULO_N:
         algorithm = "modulo_n";
         break;