diff options
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/ip/ip.api | 16 | ||||
-rw-r--r-- | src/vnet/ip/ip_api.c | 32 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api index ca0088f962f..4b418bea71f 100644 --- a/src/vnet/ip/ip.api +++ b/src/vnet/ip/ip.api @@ -743,6 +743,22 @@ autoreply define ip_source_and_port_range_check_interface_add_del u32 udp_out_vrf_id; }; +/** \brief Set interface source check request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param is_add - add or del + @param loose - strict or loose + @param sw_if_index - interface index +*/ +autoreply define ip_source_check_interface_add_del +{ + u32 client_index; + u32 context; + u8 is_add; + u8 loose; + u32 sw_if_index; +}; + /** \brief Enable/disable periodic IP neighbor scan @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c index 2f476a330ee..c15530c627e 100644 --- a/src/vnet/ip/ip_api.c +++ b/src/vnet/ip/ip_api.c @@ -109,6 +109,8 @@ _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, \ ip_source_and_port_range_check_add_del) \ _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, \ ip_source_and_port_range_check_interface_add_del) \ +_(IP_SOURCE_CHECK_INTERFACE_ADD_DEL, \ + ip_source_check_interface_add_del) \ _(IP_REASSEMBLY_SET, ip_reassembly_set) \ _(IP_REASSEMBLY_GET, ip_reassembly_get) \ _(IP_REASSEMBLY_ENABLE_DISABLE, ip_reassembly_enable_disable) \ @@ -2140,6 +2142,36 @@ reply: REPLY_MACRO (VL_API_IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY); } +typedef union +{ + u32 fib_index; +} ip4_source_check_config_t; + +static void + vl_api_ip_source_check_interface_add_del_t_handler + (vl_api_ip_source_check_interface_add_del_t * mp) +{ + vl_api_ip_source_check_interface_add_del_reply_t *rmp; + int rv; + u32 sw_if_index = ntohl (mp->sw_if_index); + u8 is_add = mp->is_add; + char *feature_name = + mp->loose ? "ip4-source-check-via-any" : "ip4-source-check-via-rx"; + + ip4_source_check_config_t config; + + VALIDATE_SW_IF_INDEX (mp); + + config.fib_index = + fib_table_get_index_for_sw_if_index (FIB_PROTOCOL_IP4, sw_if_index); + rv = + vnet_feature_enable_disable ("ip4-unicast", feature_name, sw_if_index, + is_add, &config, sizeof (config)); + BAD_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_IP_SOURCE_CHECK_INTERFACE_ADD_DEL_REPLY); +} + #define IP4_ARP_EVENT 3 #define IP6_ND_EVENT 4 |