From 569dda3ae64bbfa3579d4c42e30ee684d51b88d9 Mon Sep 17 00:00:00 2001 From: Alberto Compagno Date: Mon, 18 Nov 2019 14:52:25 +0100 Subject: [HICN-397] Added punting add message for punting on udp ports Change-Id: Ieb5faf5d01e460179028eaba92170ee95cf35edf Signed-off-by: Alberto Compagno --- hicn-plugin/src/punt.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'hicn-plugin/src/punt.c') diff --git a/hicn-plugin/src/punt.c b/hicn-plugin/src/punt.c index fe1ca495f..9fd91a795 100644 --- a/hicn-plugin/src/punt.c +++ b/hicn-plugin/src/punt.c @@ -483,12 +483,31 @@ hicn_punt_add_del_vnetssn_udp (ip_version_t * outer, ip_version_t * inner, u8 base_offset, u8 protocol, u16 sport, u16 dport, int is_add) { - return _hicn_punt_add_del_vnetssn (outer, field->punt_id, prefix->fp_len, - next_hit_index, intfc, base_offset, - is_add, outer->protocol_field, &protocol, - outer->udp_sport, &sport, - outer->udp_dport, &dport, field, - prefix->fp_addr.as_u8, NULL); + if(sport == HICN_PUNT_INVALID_PORT) + { + return _hicn_punt_add_del_vnetssn (outer, field->punt_id, prefix->fp_len, + next_hit_index, intfc, base_offset, + is_add, outer->protocol_field, &protocol, + outer->udp_dport, &dport, field, + prefix->fp_addr.as_u8, NULL); + } + else if(dport == HICN_PUNT_INVALID_PORT) + { + return _hicn_punt_add_del_vnetssn (outer, field->punt_id, prefix->fp_len, + next_hit_index, intfc, base_offset, + is_add, outer->protocol_field, &protocol, + outer->udp_sport, &sport, field, + prefix->fp_addr.as_u8, NULL); + } + else + { + return _hicn_punt_add_del_vnetssn (outer, field->punt_id, prefix->fp_len, + next_hit_index, intfc, base_offset, + is_add, outer->protocol_field, &protocol, + outer->udp_sport, &sport, + outer->udp_dport, &dport, field, + prefix->fp_addr.as_u8, NULL); + } } #define hicn_punt_add_vnetssn_udp(outer, inner, field, prefix, index, intfc, offset, protocol, sport, dport) \ @@ -773,11 +792,15 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm, HICN_CLASSIFY_CURRENT_DATA_FLAG; u8 base_offset = with_l2 ? ETH_L2 : NO_L2; u16 mask = prefix->fp_len; + vnet_main_t *vnm = vnet_get_main (); if (punt_type != HICN_PUNT_IP_TYPE && punt_type != HICN_PUNT_UDP4_TYPE && punt_type != HICN_PUNT_UDP6_TYPE) return HICN_ERROR_PUNT_INVAL; + if ((sport == 0 && dport == 0) || !vnet_sw_interface_is_valid (vnm, swif)) + return HICN_ERROR_PUNT_INVAL; + if (ip46_address_is_ip4 (&prefix->fp_addr)) { if (mask > IPV4_ADDR_LEN_BITS) @@ -940,9 +963,10 @@ hicn_punt_interest_data_for_ip (vlib_main_t * vm, HICN_CLASSIFY_CURRENT_DATA_FLAG; u8 base_offset = with_l2 ? ETH_L2 : NO_L2; u16 mask = prefix->fp_len; + vnet_main_t *vnm = vnet_get_main (); - if (punt_type != HICN_PUNT_IP_TYPE && punt_type != HICN_PUNT_UDP4_TYPE - && punt_type != HICN_PUNT_UDP6_TYPE) + if ((punt_type != HICN_PUNT_IP_TYPE && punt_type != HICN_PUNT_UDP4_TYPE + && punt_type != HICN_PUNT_UDP6_TYPE) || !vnet_sw_interface_is_valid (vnm, swif)) return HICN_ERROR_PUNT_INVAL; if (ip46_address_is_ip4 (&prefix->fp_addr)) -- cgit 1.2.3-korg