pnat: add support to wildcard IP Protocol field if not specified
[vpp.git] / src / plugins / nat / pnat / pnat.c
index 7f02ec4..2b4a6b4 100644 (file)
@@ -56,7 +56,9 @@ static pnat_mask_fast_t pnat_mask2fast(pnat_mask_t lookup_mask) {
         m.as_u64[0] = 0xffffffff00000000;
     if (lookup_mask & PNAT_DA)
         m.as_u64[0] |= 0x00000000ffffffff;
-    m.as_u64[1] = 0xffffffff00000000;
+    m.as_u64[1] = 0x00ffffff00000000;
+    if (lookup_mask & PNAT_PROTO)
+        m.as_u64[1] |= 0xff00000000000000;
     if (lookup_mask & PNAT_SPORT)
         m.as_u64[1] |= 0x00000000ffff0000;
     if (lookup_mask & PNAT_DPORT)
@@ -110,9 +112,15 @@ static clib_error_t *pnat_enable_interface(u32 sw_if_index,
 
         if (input) {
             /* TODO: Make shallow virtual reassembly configurable */
-            ip4_sv_reass_enable_disable_with_refcnt(sw_if_index, 1);
+            if (ip4_sv_reass_enable_disable_with_refcnt(sw_if_index, 1) != 0)
+                return clib_error_return(0, "PNAT SVR enable failed on %u",
+                                         sw_if_index);
+
         } else {
-            ip4_sv_reass_output_enable_disable_with_refcnt(sw_if_index, 1);
+            if (ip4_sv_reass_output_enable_disable_with_refcnt(sw_if_index,
+                                                               1) != 0)
+                return clib_error_return(0, "PNAT SVR enable failed on %u",
+                                         sw_if_index);
         }
 
         interface->lookup_mask[attachment] = mask;