aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaxime Peim <mpeim@cisco.com>2024-03-11 10:35:16 +0100
committerBeno�t Ganne <bganne@cisco.com>2024-05-28 11:56:46 +0000
commit0720d65c7b0cf7106742ce02a0512bf647d5e517 (patch)
treec957bef8c00558424240fbea51893de41361220a /src
parent7624083c27125d1d0abd11738f7dceb2990969ed (diff)
urpf: export to use it externally
Type: improvement Change-Id: Ia70f16c92dfc153256db6dcdf23f5487d5a7b678 Signed-off-by: Maxime Peim <mpeim@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/urpf/CMakeLists.txt4
-rw-r--r--src/plugins/urpf/urpf.c27
-rw-r--r--src/plugins/urpf/urpf.h14
-rw-r--r--src/plugins/urpf/urpf_dp.h15
-rw-r--r--src/vnet/CMakeLists.txt1
5 files changed, 39 insertions, 22 deletions
diff --git a/src/plugins/urpf/CMakeLists.txt b/src/plugins/urpf/CMakeLists.txt
index 2f44e3b2344..f665d30b0bb 100644
--- a/src/plugins/urpf/CMakeLists.txt
+++ b/src/plugins/urpf/CMakeLists.txt
@@ -22,6 +22,10 @@ add_vpp_plugin(urpf
ip4_urpf.c
ip6_urpf.c
+ INSTALL_HEADERS
+ urpf_dp.h
+ urpf.h
+
API_FILES
urpf.api
)
diff --git a/src/plugins/urpf/urpf.c b/src/plugins/urpf/urpf.c
index e5209caafb4..1e7d6c0fb91 100644
--- a/src/plugins/urpf/urpf.c
+++ b/src/plugins/urpf/urpf.c
@@ -60,7 +60,17 @@ static const char *urpf_feats[N_AF][VLIB_N_DIR][URPF_N_MODES] =
urpf_data_t *urpf_cfgs[N_AF][VLIB_N_DIR];
u8 *
-format_urpf_mode (u8 * s, va_list * a)
+format_urpf_trace (u8 *s, va_list *va)
+{
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
+ urpf_trace_t *t = va_arg (*va, urpf_trace_t *);
+
+ return format (s, "uRPF:%d fib:%d", t->urpf, t->fib_index);
+}
+
+__clib_export u8 *
+format_urpf_mode (u8 *s, va_list *a)
{
urpf_mode_t mode = va_arg (*a, int);
@@ -76,8 +86,8 @@ format_urpf_mode (u8 * s, va_list * a)
return (format (s, "unknown"));
}
-static uword
-unformat_urpf_mode (unformat_input_t * input, va_list * args)
+__clib_export uword
+unformat_urpf_mode (unformat_input_t *input, va_list *args)
{
urpf_mode_t *mode = va_arg (*args, urpf_mode_t *);
@@ -94,7 +104,16 @@ unformat_urpf_mode (unformat_input_t * input, va_list * args)
return 0;
}
-int
+__clib_export int
+urpf_feature_enable_disable (ip_address_family_t af, vlib_dir_t dir,
+ urpf_mode_t mode, u32 sw_if_index, int enable)
+{
+ return vnet_feature_enable_disable (urpf_feat_arcs[af][dir],
+ urpf_feats[af][dir][mode], sw_if_index,
+ enable, 0, 0);
+}
+
+__clib_export int
urpf_update (urpf_mode_t mode, u32 sw_if_index, ip_address_family_t af,
vlib_dir_t dir, u32 table_id)
{
diff --git a/src/plugins/urpf/urpf.h b/src/plugins/urpf/urpf.h
index 6983a2b440c..a40a25df16b 100644
--- a/src/plugins/urpf/urpf.h
+++ b/src/plugins/urpf/urpf.h
@@ -32,7 +32,15 @@ typedef enum urpf_mode_t_
#define URPF_N_MODES (URPF_MODE_STRICT+1)
-extern u8 *format_urpf_mode (u8 * s, va_list * a);
+typedef struct
+{
+ index_t urpf;
+ u32 fib_index;
+} urpf_trace_t;
+
+u8 *format_urpf_trace (u8 *s, va_list *va);
+u8 *format_urpf_mode (u8 *s, va_list *a);
+uword unformat_urpf_mode (unformat_input_t *input, va_list *args);
typedef struct
{
@@ -43,8 +51,8 @@ typedef struct
extern urpf_data_t *urpf_cfgs[N_AF][VLIB_N_DIR];
-extern int urpf_update (urpf_mode_t mode, u32 sw_if_index,
- ip_address_family_t af, vlib_dir_t dir, u32 table_id);
+int urpf_update (urpf_mode_t mode, u32 sw_if_index, ip_address_family_t af,
+ vlib_dir_t dir, u32 table_id);
#endif
diff --git a/src/plugins/urpf/urpf_dp.h b/src/plugins/urpf/urpf_dp.h
index bca41863d41..b17fed7e04b 100644
--- a/src/plugins/urpf/urpf_dp.h
+++ b/src/plugins/urpf/urpf_dp.h
@@ -53,21 +53,6 @@
*
* This file contains the interface unicast source check.
*/
-typedef struct
-{
- index_t urpf;
- u32 fib_index;
-} urpf_trace_t;
-
-static u8 *
-format_urpf_trace (u8 * s, va_list * va)
-{
- CLIB_UNUSED (vlib_main_t * vm) = va_arg (*va, vlib_main_t *);
- CLIB_UNUSED (vlib_node_t * node) = va_arg (*va, vlib_node_t *);
- urpf_trace_t *t = va_arg (*va, urpf_trace_t *);
-
- return format (s, "uRPF:%d fib:%d", t->urpf, t->fib_index);
-}
#define foreach_urpf_error \
_(DROP, "uRPF Drop") \
diff --git a/src/vnet/CMakeLists.txt b/src/vnet/CMakeLists.txt
index ad5f44846cc..eb74f5de84c 100644
--- a/src/vnet/CMakeLists.txt
+++ b/src/vnet/CMakeLists.txt
@@ -1144,6 +1144,7 @@ list(APPEND VNET_HEADERS
fib/fib_path_list.h
fib/fib_sas.h
fib/fib_source.h
+ fib/fib_urpf_list.h
)
list(APPEND VNET_API_FILES