aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lb
diff options
context:
space:
mode:
authorHongjun Ni <hongjun.ni@intel.com>2019-09-10 00:49:24 +0800
committerOle Trøan <otroan@employees.org>2019-09-26 11:40:18 +0000
commit33538a15087eea7c994b6f3d8a952c4b6ea98ee4 (patch)
treedf163312f706753c154546fdbaf3d5623318a04e /src/plugins/lb
parent8304933922620cef005b788a36a4d3f2eab45bb5 (diff)
lb: add APIs for set interface nat4 and nat6
Type: feature Change-Id: I5656cd798b108dd780381b87f574554442ed7b23 Signed-off-by: Hongjun Ni <hongjun.ni@intel.com>
Diffstat (limited to 'src/plugins/lb')
-rw-r--r--src/plugins/lb/api.c42
-rw-r--r--src/plugins/lb/lb.api26
2 files changed, 68 insertions, 0 deletions
diff --git a/src/plugins/lb/api.c b/src/plugins/lb/api.c
index 0543720e4e5..e2ab2ac25df 100644
--- a/src/plugins/lb/api.c
+++ b/src/plugins/lb/api.c
@@ -60,6 +60,8 @@ _(LB_ADD_DEL_AS, lb_add_del_as) \
_(LB_VIP_DUMP, lb_vip_dump) \
_(LB_AS_DUMP, lb_as_dump) \
_(LB_FLUSH_VIP, lb_flush_vip) \
+_(LB_ADD_DEL_INTF_NAT4, lb_add_del_intf_nat4) \
+_(LB_ADD_DEL_INTF_NAT6, lb_add_del_intf_nat6) \
/* Macro to finish up custom dump fns */
@@ -389,6 +391,46 @@ vl_api_lb_flush_vip_t_handler
REPLY_MACRO (VL_API_LB_FLUSH_VIP_REPLY);
}
+static void vl_api_lb_add_del_intf_nat4_t_handler
+ (vl_api_lb_add_del_intf_nat4_t * mp)
+{
+ lb_main_t *lbm = &lb_main;
+ vl_api_lb_add_del_intf_nat4_reply_t *rmp;
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u8 is_del;
+ int rv = 0;
+
+ is_del = !mp->is_add;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ rv = lb_nat4_interface_add_del(sw_if_index, is_del);
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ REPLY_MACRO (VL_API_LB_ADD_DEL_INTF_NAT4_REPLY);
+}
+
+static void vl_api_lb_add_del_intf_nat6_t_handler
+ (vl_api_lb_add_del_intf_nat6_t * mp)
+{
+ lb_main_t *lbm = &lb_main;
+ vl_api_lb_add_del_intf_nat6_reply_t *rmp;
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u8 is_del;
+ int rv = 0;
+
+ is_del = !mp->is_add;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ rv = lb_nat6_interface_add_del(sw_if_index, is_del);
+
+ BAD_SW_IF_INDEX_LABEL;
+
+ REPLY_MACRO (VL_API_LB_ADD_DEL_INTF_NAT6_REPLY);
+}
+
static void *vl_api_lb_flush_vip_t_print
(vl_api_lb_flush_vip_t *mp, void * handle)
{
diff --git a/src/plugins/lb/lb.api b/src/plugins/lb/lb.api
index b9f5c22126a..b479b1b3034 100644
--- a/src/plugins/lb/lb.api
+++ b/src/plugins/lb/lb.api
@@ -1,5 +1,6 @@
option version = "1.0.0";
import "plugins/lb/lb_types.api";
+import "vnet/interface_types.api";
/** \brief Configure Load-Balancer global parameters (unlike the CLI, both ip4_src_address and ip6_src_address need to be specified.
@param client_index - opaque cookie to identify the sender
@@ -143,3 +144,28 @@ define lb_as_details {
u32 in_use_since;
};
+/** \brief Enable/disable NAT4 feature on the interface
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param is_add - true if add, false if delete
+ @param sw_if_index - software index of the interface
+*/
+autoreply define lb_add_del_intf_nat4 {
+ u32 client_index;
+ u32 context;
+ bool is_add;
+ vl_api_interface_index_t sw_if_index;
+};
+
+/** \brief Enable/disable NAT6 feature on the interface
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param is_add - true if add, false if delete
+ @param sw_if_index - software index of the interface
+*/
+autoreply define lb_add_del_intf_nat6 {
+ u32 client_index;
+ u32 context;
+ bool is_add;
+ vl_api_interface_index_t sw_if_index;
+};