summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/pnat/pnat_api.c
diff options
context:
space:
mode:
authorFahad Naeem <fahadnaeemkhan@gmail.com>2022-05-10 01:03:52 -0500
committerOle Tr�an <otroan@employees.org>2022-05-12 07:30:33 +0000
commit0891b6aa449cca525b61d0cc23759b2efcd158dc (patch)
treed2010d7871c420fd9631ec3ea57e62eba738e52e /src/plugins/nat/pnat/pnat_api.c
parente2159bd2d3721592edee90a511647f83ea9a4781 (diff)
pnat: add support to wildcard IP Protocol field if not specified
- add pnat_binding_add_v2 which explicitly requires match mask to set to PNAT_PROTO if we want to match on IP Protocol - fix pnat_binding_add backward compatibility i.e. no need to set match mast to PNAT_PROTO Type: improvement Signed-off-by: Fahad Naeem <fahadnaeemkhan@gmail.com> Change-Id: I5a23244be55b7d4c10552c555881527a4b2f325f
Diffstat (limited to 'src/plugins/nat/pnat/pnat_api.c')
-rw-r--r--src/plugins/nat/pnat/pnat_api.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/plugins/nat/pnat/pnat_api.c b/src/plugins/nat/pnat/pnat_api.c
index 35a73955b33..02e61219d1e 100644
--- a/src/plugins/nat/pnat/pnat_api.c
+++ b/src/plugins/nat/pnat/pnat_api.c
@@ -36,12 +36,27 @@ static void vl_api_pnat_binding_add_t_handler(vl_api_pnat_binding_add_t *mp) {
pnat_main_t *pm = &pnat_main;
vl_api_pnat_binding_add_reply_t *rmp;
u32 binding_index;
+
+ // for backward compatibility
+ if (mp->match.proto == 0)
+ mp->match.mask |= PNAT_PROTO;
+
int rv = pnat_binding_add(&mp->match, &mp->rewrite, &binding_index);
REPLY_MACRO2_END(VL_API_PNAT_BINDING_ADD_REPLY,
({ rmp->binding_index = binding_index; }));
}
static void
+vl_api_pnat_binding_add_v2_t_handler(vl_api_pnat_binding_add_t *mp) {
+ pnat_main_t *pm = &pnat_main;
+ vl_api_pnat_binding_add_reply_t *rmp;
+ u32 binding_index;
+ int rv = pnat_binding_add(&mp->match, &mp->rewrite, &binding_index);
+ REPLY_MACRO2_END(VL_API_PNAT_BINDING_ADD_V2_REPLY,
+ ({ rmp->binding_index = binding_index; }));
+}
+
+static void
vl_api_pnat_binding_attach_t_handler(vl_api_pnat_binding_attach_t *mp) {
pnat_main_t *pm = &pnat_main;
vl_api_pnat_binding_attach_reply_t *rmp;