ipsec: enable ipv6 udp checksum offload
[vpp.git] / src / vnet / session / session_rules_table.c
index 6304606..70a702c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
@@ -386,11 +386,11 @@ session_rules_table_lookup6 (session_rules_table_t * srt,
  * @param srt table where rule should be added
  * @param args rule arguments
  *
- * @return 0 if success, clib_error_t error otherwise
+ * @return 0 if success, session_error_t error otherwise
  */
-clib_error_t *
-session_rules_table_add_del (session_rules_table_t * srt,
-                            session_rule_table_add_del_args_t * args)
+session_error_t
+session_rules_table_add_del (session_rules_table_t *srt,
+                            session_rule_table_add_del_args_t *args)
 {
   u8 fib_proto = args->rmt.fp_proto, *rt;
   u32 ri_from_tag, ri;
@@ -398,8 +398,7 @@ session_rules_table_add_del (session_rules_table_t * srt,
 
   ri_from_tag = session_rules_table_rule_for_tag (srt, args->tag);
   if (args->is_add && ri_from_tag != SESSION_RULES_TABLE_INVALID_INDEX)
-    return clib_error_return_code (0, VNET_API_ERROR_INVALID_VALUE, 0,
-                                  "tag exists");
+    return SESSION_E_INVALID;
 
   if (fib_proto == FIB_PROTOCOL_IP4)
     {
@@ -510,11 +509,17 @@ session_rules_table_add_del (session_rules_table_t * srt,
        }
     }
   else
-    return clib_error_return_code (0, VNET_API_ERROR_INVALID_VALUE_2, 0,
-                                  "invalid fib proto");
+    return SESSION_E_INVALID;
   return 0;
 }
 
+void
+session_rules_table_free (session_rules_table_t *srt)
+{
+  mma_rules_table_free_16 (&srt->session_rules_tables_16);
+  mma_rules_table_free_40 (&srt->session_rules_tables_40);
+}
+
 void
 session_rules_table_init (session_rules_table_t * srt)
 {
@@ -600,11 +605,9 @@ session_rules_table_cli_dump (vlib_main_t * vm, session_rules_table_t * srt,
       srt4 = &srt->session_rules_tables_16;
       vlib_cli_output (vm, "IP4 rules");
 
-      /* *INDENT-OFF* */
-      pool_foreach(sr4, srt4->rules, ({
+      pool_foreach (sr4, srt4->rules)  {
        vlib_cli_output (vm, "%U", format_session_rule4, srt, sr4);
-      }));
-      /* *INDENT-ON* */
+      }
 
     }
   else if (fib_proto == FIB_PROTOCOL_IP6)
@@ -614,11 +617,9 @@ session_rules_table_cli_dump (vlib_main_t * vm, session_rules_table_t * srt,
       srt6 = &srt->session_rules_tables_40;
       vlib_cli_output (vm, "IP6 rules");
 
-      /* *INDENT-OFF* */
-      pool_foreach(sr6, srt6->rules, ({
+      pool_foreach (sr6, srt6->rules)  {
         vlib_cli_output (vm, "%U", format_session_rule6, srt, sr6);
-      }));
-      /* *INDENT-ON* */
+      }
 
     }
 }