diff options
Diffstat (limited to 'src/plugins')
27 files changed, 193 insertions, 127 deletions
diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index ec951ad7057..d6a6d582702 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -669,10 +669,13 @@ api_acl_add_replace_from_file (vat_main_t * vam) break; } + if (file_name == NULL) + goto done; + fd = open(file_name, O_RDONLY); if (fd < 0) { - clib_warning("Could not open file '%s'"); + clib_warning("Could not open file '%s'", file_name); goto done; } diff --git a/src/plugins/dns/dns.c b/src/plugins/dns/dns.c index 870cfae5074..47955452d3c 100644 --- a/src/plugins/dns/dns.c +++ b/src/plugins/dns/dns.c @@ -2795,7 +2795,7 @@ vnet_send_dns4_reply (dns_main_t * dm, dns_pending_request_t * pr, u8 *reply; vl_api_dns_resolve_name_reply_t _rnr, *rnr = &_rnr; vl_api_dns_resolve_ip_reply_t _rir, *rir = &_rir; - u32 ttl, tmp; + u32 ttl = 64, tmp; u32 qp_offset; dns_query_t *qp; dns_rr_t *rr; diff --git a/src/plugins/dns/dns_test.c b/src/plugins/dns/dns_test.c index 6b0b371dca1..ada9c0b7aa1 100644 --- a/src/plugins/dns/dns_test.c +++ b/src/plugins/dns/dns_test.c @@ -186,6 +186,12 @@ api_dns_resolve_name (vat_main_t * vam) break; } + if (name == 0) + { + errmsg ("missing name to resolve"); + return -99; + } + if (vec_len (name) > 127) { errmsg ("name too long"); diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c index a1c1ea1ca46..251b678a5fb 100644 --- a/src/plugins/dpdk/buffer.c +++ b/src/plugins/dpdk/buffer.c @@ -90,6 +90,7 @@ dpdk_buffer_pool_init (vlib_main_t * vm, vlib_buffer_pool_t * bp) rte_mempool_set_ops_byname (nmp, "vpp-no-cache", NULL); /* Call the mempool priv initializer */ + memset (&priv, 0, sizeof (priv)); priv.mbuf_data_room_size = VLIB_BUFFER_PRE_DATA_SIZE + vlib_buffer_get_default_data_size (vm); priv.mbuf_priv_size = VLIB_BUFFER_HDR_SIZE; diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c index 942def63b0a..436466fa1ad 100644 --- a/src/plugins/dpdk/device/format.c +++ b/src/plugins/dpdk/device/format.c @@ -676,12 +676,10 @@ format_dpdk_device (u8 * s, va_list * args) xstat = vec_elt_at_index(xd->xstats, i); if (verbose == 2 || (verbose && xstat->value)) { - /* format_c_identifier doesn't like c strings inside vector */ - u8 * name = format(0,"%s", xstat_names[i].name); xs = format(xs, "\n%U%-38U%16Lu", format_white_space, indent + 4, - format_c_identifier, name, xstat->value); - vec_free(name); + format_c_identifier, xstat_names[i].name, + xstat->value); } } /* *INDENT-ON* */ diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c index 8ebfaac3580..0523770971c 100644 --- a/src/plugins/dpdk/device/init.c +++ b/src/plugins/dpdk/device/init.c @@ -279,7 +279,6 @@ dpdk_lib_init (dpdk_main_t * dm) int vlan_off; struct rte_eth_dev_info dev_info; struct rte_pci_device *pci_dev; - struct rte_eth_link l; dpdk_portid_t next_port_id; dpdk_device_config_t *devconf = 0; vlib_pci_addr_t pci_addr; @@ -288,7 +287,6 @@ dpdk_lib_init (dpdk_main_t * dm) if (!rte_eth_dev_is_valid_port(i)) continue; - rte_eth_link_get_nowait (i, &l); rte_eth_dev_info_get (i, &dev_info); if (dev_info.device == 0) @@ -504,9 +502,13 @@ dpdk_lib_init (dpdk_main_t * dm) /* Cisco VIC */ case VNET_DPDK_PMD_ENIC: - xd->port_type = port_type_from_link_speed (l.link_speed); - if (dm->conf->enable_tcp_udp_checksum) - dpdk_enable_l4_csum_offload (xd); + { + struct rte_eth_link l; + rte_eth_link_get_nowait (i, &l); + xd->port_type = port_type_from_link_speed (l.link_speed); + if (dm->conf->enable_tcp_udp_checksum) + dpdk_enable_l4_csum_offload (xd); + } break; /* Intel Red Rock Canyon */ @@ -551,7 +553,11 @@ dpdk_lib_init (dpdk_main_t * dm) break; case VNET_DPDK_PMD_NETVSC: - xd->port_type = port_type_from_link_speed (l.link_speed); + { + struct rte_eth_link l; + rte_eth_link_get_nowait (i, &l); + xd->port_type = port_type_from_link_speed (l.link_speed); + } break; default: diff --git a/src/plugins/gbp/test/test_gbp.py b/src/plugins/gbp/test/test_gbp.py index 87266492dca..dcbe976cc6e 100644 --- a/src/plugins/gbp/test/test_gbp.py +++ b/src/plugins/gbp/test/test_gbp.py @@ -36,7 +36,7 @@ NUM_PKTS = 67 def find_gbp_endpoint(test, sw_if_index=None, ip=None, mac=None, - tep=None, sclass=None): + tep=None, sclass=None, flags=None): if ip: vip = VppIpAddress(ip) if mac: @@ -56,6 +56,9 @@ def find_gbp_endpoint(test, sw_if_index=None, ip=None, mac=None, if sclass: if ep.endpoint.sclass != sclass: continue + if flags: + if flags != (flags & ep.endpoint.flags): + continue if ip: for eip in ep.endpoint.ips: if vip == eip: @@ -1542,12 +1545,17 @@ class TestGBP(VppTestCase): def wait_for_ep_timeout(self, sw_if_index=None, ip=None, mac=None, tep=None, n_tries=100, s_time=1): + # only learnt EP can timeout + ep_flags = VppEnum.vl_api_gbp_endpoint_flags_t + flags = ep_flags.GBP_API_ENDPOINT_FLAG_LEARNT while (n_tries): - if not find_gbp_endpoint(self, sw_if_index, ip, mac, tep=tep): + if not find_gbp_endpoint(self, sw_if_index, ip, mac, tep=tep, + flags=flags): return True n_tries = n_tries - 1 self.sleep(s_time) - self.assertFalse(find_gbp_endpoint(self, sw_if_index, ip, mac)) + self.assertFalse(find_gbp_endpoint(self, sw_if_index, ip, mac, tep=tep, + flags=flags)) return False def test_gbp_learn_l2(self): @@ -5877,6 +5885,8 @@ class TestGBP(VppTestCase): self.vlan_101.set_vtr(L2_VTR_OP.L2_DISABLED) self.vlan_100.set_vtr(L2_VTR_OP.L2_DISABLED) self.pg7.unconfig_ip4() + # make sure the programmed EP is no longer learnt from DP + self.wait_for_ep_timeout(sw_if_index=rep.itf.sw_if_index, ip=rep.ip4) if __name__ == '__main__': diff --git a/src/plugins/hs_apps/http_server.c b/src/plugins/hs_apps/http_server.c index cc998a6f661..ce8a3e868f2 100644 --- a/src/plugins/hs_apps/http_server.c +++ b/src/plugins/hs_apps/http_server.c @@ -193,17 +193,6 @@ http_server_session_timer_stop (http_session_t * hs) } static void -http_server_session_cleanup (http_session_t * hs) -{ - if (!hs) - return; - http_server_session_lookup_del (hs->thread_index, hs->vpp_session_index); - vec_free (hs->rx_buf); - http_server_session_timer_stop (hs); - http_server_session_free (hs); -} - -static void http_server_session_disconnect (http_session_t * hs) { vnet_disconnect_args_t _a = { 0 }, *a = &_a; @@ -605,7 +594,6 @@ send_data: close_session: http_server_session_disconnect (hs); - http_server_session_cleanup (hs); return 0; postpone: @@ -651,16 +639,6 @@ http_server_session_disconnect_callback (session_t * s) { http_server_main_t *hsm = &http_server_main; vnet_disconnect_args_t _a = { 0 }, *a = &_a; - http_session_t *hs; - - if (!hsm->is_static) - http_server_sessions_writer_lock (); - - hs = http_server_session_lookup (s->thread_index, s->session_index); - http_server_session_cleanup (hs); - - if (!hsm->is_static) - http_server_sessions_writer_unlock (); a->handle = session_handle (s); a->app_index = hsm->app_index; @@ -672,16 +650,6 @@ http_server_session_reset_callback (session_t * s) { http_server_main_t *hsm = &http_server_main; vnet_disconnect_args_t _a = { 0 }, *a = &_a; - http_session_t *hs; - - if (!hsm->is_static) - http_server_sessions_writer_lock (); - - hs = http_server_session_lookup (s->thread_index, s->session_index); - http_server_session_cleanup (hs); - - if (!hsm->is_static) - http_server_sessions_writer_unlock (); a->handle = session_handle (s); a->app_index = hsm->app_index; @@ -703,13 +671,41 @@ http_server_add_segment_callback (u32 client_index, u64 segment_handle) return -1; } +static void +http_server_cleanup_callback (session_t * s, session_cleanup_ntf_t ntf) +{ + http_server_main_t *hsm = &http_server_main; + http_session_t *hs; + + if (ntf == SESSION_CLEANUP_TRANSPORT) + return; + + if (!hsm->is_static) + http_server_sessions_writer_lock (); + + hs = http_server_session_lookup (s->thread_index, s->session_index); + if (!hs) + goto done; + + http_server_session_lookup_del (hs->thread_index, hs->vpp_session_index); + vec_free (hs->rx_buf); + http_server_session_timer_stop (hs); + http_server_session_free (hs); + +done: + + if (!hsm->is_static) + http_server_sessions_writer_unlock (); +} + static session_cb_vft_t http_server_session_cb_vft = { .session_accept_callback = http_server_session_accept_callback, .session_disconnect_callback = http_server_session_disconnect_callback, .session_connected_callback = http_server_session_connected_callback, .add_segment_callback = http_server_add_segment_callback, .builtin_app_rx_callback = http_server_rx_callback, - .session_reset_callback = http_server_session_reset_callback + .session_reset_callback = http_server_session_reset_callback, + .session_cleanup_callback = http_server_cleanup_callback, }; static int @@ -778,7 +774,7 @@ http_server_listen () } static void -http_server_session_cleanup_cb (void *hs_handlep) +http_server_session_close_cb (void *hs_handlep) { http_session_t *hs; uword hs_handle; @@ -788,7 +784,6 @@ http_server_session_cleanup_cb (void *hs_handlep) return; hs->timer_handle = ~0; http_server_session_disconnect (hs); - http_server_session_cleanup (hs); } static void @@ -802,7 +797,7 @@ http_expired_timers_dispatch (u32 * expired_timers) /* Get session handle. The first bit is the timer id */ hs_handle = expired_timers[i] & 0x7FFFFFFF; session_send_rpc_evt_to_thread (hs_handle >> 24, - http_server_session_cleanup_cb, + http_server_session_close_cb, uword_to_pointer (hs_handle, void *)); } } diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c index ef9d3d77e41..77e3ebd8e13 100644 --- a/src/plugins/http_static/static_server.c +++ b/src/plugins/http_static/static_server.c @@ -243,26 +243,8 @@ http_static_server_detach_cache_entry (http_session_t * hs) vec_free (hs->path); } -/** \brief clean up a session - */ - -static void -http_static_server_session_cleanup (http_session_t * hs) -{ - if (!hs) - return; - - http_static_server_detach_cache_entry (hs); - - http_static_server_session_lookup_del (hs->thread_index, - hs->vpp_session_index); - vec_free (hs->rx_buf); - http_static_server_session_free (hs); -} - /** \brief Disconnect a session */ - static void http_static_server_session_disconnect (http_session_t * hs) { @@ -531,7 +513,6 @@ static void close_session (http_session_t * hs) { http_static_server_session_disconnect (hs); - http_static_server_session_cleanup (hs); } /** \brief Register a builtin GET or POST handler @@ -799,7 +780,7 @@ find_end: dp = pool_elt_at_index (hsm->cache_pool, kv.value); hs->data = dp->data; /* Update the cache entry, mark it in-use */ - lru_update (hsm, dp, vlib_time_now (hsm->vlib_main)); + lru_update (hsm, dp, vlib_time_now (vlib_get_main ())); hs->cache_pool_index = dp - hsm->cache_pool; dp->inuse++; if (hsm->debug_level > 1) @@ -871,7 +852,7 @@ find_end: if (hsm->debug_level > 1) clib_warning ("index %d refcnt now %d", hs->cache_pool_index, dp->inuse); - lru_add (hsm, dp, vlib_time_now (hsm->vlib_main)); + lru_add (hsm, dp, vlib_time_now (vlib_get_main ())); kv.key = (u64) vec_dup (hs->path); kv.value = dp - hsm->cache_pool; /* Add to the lookup table */ @@ -933,7 +914,7 @@ state_sent_ok (session_t * s, http_session_t * hs, /* What kind of dog food are we serving? */ suffix = (char *) (hs->path + vec_len (hs->path) - 1); - while (*suffix != '.') + while ((u8 *) suffix >= hs->path && *suffix != '.') suffix--; suffix++; http_type = "text/html"; @@ -1078,14 +1059,6 @@ http_static_server_session_disconnect_callback (session_t * s) { http_static_server_main_t *hsm = &http_static_server_main; vnet_disconnect_args_t _a = { 0 }, *a = &_a; - http_session_t *hs; - - http_static_server_sessions_writer_lock (); - - hs = http_static_server_session_lookup (s->thread_index, s->session_index); - http_static_server_session_cleanup (hs); - - http_static_server_sessions_writer_unlock (); a->handle = session_handle (s); a->app_index = hsm->app_index; @@ -1100,14 +1073,6 @@ http_static_server_session_reset_callback (session_t * s) { http_static_server_main_t *hsm = &http_static_server_main; vnet_disconnect_args_t _a = { 0 }, *a = &_a; - http_session_t *hs; - - http_static_server_sessions_writer_lock (); - - hs = http_static_server_session_lookup (s->thread_index, s->session_index); - http_static_server_session_cleanup (hs); - - http_static_server_sessions_writer_unlock (); a->handle = session_handle (s); a->app_index = hsm->app_index; @@ -1129,6 +1094,30 @@ http_static_server_add_segment_callback (u32 client_index, u64 segment_handle) return -1; } +static void +http_static_session_cleanup (session_t * s, session_cleanup_ntf_t ntf) +{ + http_session_t *hs; + + if (ntf == SESSION_CLEANUP_TRANSPORT) + return; + + http_static_server_sessions_writer_lock (); + + hs = http_static_server_session_lookup (s->thread_index, s->session_index); + if (!hs) + goto done; + + http_static_server_detach_cache_entry (hs); + http_static_server_session_lookup_del (hs->thread_index, + hs->vpp_session_index); + vec_free (hs->rx_buf); + http_static_server_session_free (hs); + +done: + http_static_server_sessions_writer_unlock (); +} + /** \brief Session-layer virtual function table */ static session_cb_vft_t http_static_server_session_cb_vft = { @@ -1139,7 +1128,8 @@ static session_cb_vft_t http_static_server_session_cb_vft = { .add_segment_callback = http_static_server_add_segment_callback, .builtin_app_rx_callback = http_static_server_rx_callback, .builtin_app_tx_callback = http_static_server_tx_callback, - .session_reset_callback = http_static_server_session_reset_callback + .session_reset_callback = http_static_server_session_reset_callback, + .session_cleanup_callback = http_static_session_cleanup, }; static int @@ -1209,7 +1199,7 @@ http_static_server_listen () } static void -http_static_server_session_cleanup_cb (void *hs_handlep) +http_static_server_session_close_cb (void *hs_handlep) { http_static_server_main_t *hsm = &http_static_server_main; http_session_t *hs; @@ -1225,7 +1215,6 @@ http_static_server_session_cleanup_cb (void *hs_handlep) return; hs->timer_handle = ~0; http_static_server_session_disconnect (hs); - http_static_server_session_cleanup (hs); } /** \brief Expired session timer-wheel callback @@ -1241,7 +1230,7 @@ http_expired_timers_dispatch (u32 * expired_timers) /* Get session handle. The first bit is the timer id */ hs_handle = expired_timers[i] & 0x7FFFFFFF; session_send_rpc_evt_to_thread (hs_handle >> 24, - http_static_server_session_cleanup_cb, + http_static_server_session_close_cb, uword_to_pointer (hs_handle, void *)); } } diff --git a/src/plugins/ikev2/ikev2.c b/src/plugins/ikev2/ikev2.c index 16c21cb2418..cc45d14b56f 100644 --- a/src/plugins/ikev2/ikev2.c +++ b/src/plugins/ikev2/ikev2.c @@ -1498,7 +1498,7 @@ ikev2_create_tunnel_interface (vnet_main_t * vnm, ikev2_sa_t * sa, { a.local_ip.ip4.as_u32 = sa->iaddr.as_u32; a.remote_ip.ip4.as_u32 = sa->raddr.as_u32; - proposals = child->i_proposals; + proposals = child->r_proposals; a.local_spi = child->r_proposals[0].spi; a.remote_spi = child->i_proposals[0].spi; } @@ -1506,7 +1506,7 @@ ikev2_create_tunnel_interface (vnet_main_t * vnm, ikev2_sa_t * sa, { a.local_ip.ip4.as_u32 = sa->raddr.as_u32; a.remote_ip.ip4.as_u32 = sa->iaddr.as_u32; - proposals = child->r_proposals; + proposals = child->i_proposals; a.local_spi = child->i_proposals[0].spi; a.remote_spi = child->r_proposals[0].spi; } @@ -2611,7 +2611,6 @@ ikev2_set_initiator_proposals (vlib_main_t * vm, ikev2_sa_t * sa, { vec_add1 (proposal->transforms, *td); error = 0; - break; } } if (error) @@ -3000,7 +2999,7 @@ ikev2_initiate_sa_init (vlib_main_t * vm, u8 * name) ikev2_sa_free_proposal_vector (&proposals); sa.is_initiator = 1; - sa.profile_index = km->profiles - p; + sa.profile_index = p - km->profiles; sa.is_profile_index_set = 1; sa.state = IKEV2_STATE_SA_INIT; ikev2_generate_sa_init_data (&sa); diff --git a/src/plugins/ikev2/ikev2_api.c b/src/plugins/ikev2/ikev2_api.c index bff13ac4626..cfb0cc14514 100644 --- a/src/plugins/ikev2/ikev2_api.c +++ b/src/plugins/ikev2/ikev2_api.c @@ -144,7 +144,7 @@ static void static void vl_api_ikev2_profile_set_id_t_handler (vl_api_ikev2_profile_set_id_t * mp) { - vl_api_ikev2_profile_add_del_reply_t *rmp; + vl_api_ikev2_profile_set_id_reply_t *rmp; int rv = 0; #if WITH_LIBSSL > 0 @@ -195,7 +195,7 @@ vl_api_ikev2_profile_set_ts_t_handler (vl_api_ikev2_profile_set_ts_t * mp) static void vl_api_ikev2_set_local_key_t_handler (vl_api_ikev2_set_local_key_t * mp) { - vl_api_ikev2_profile_set_ts_reply_t *rmp; + vl_api_ikev2_set_local_key_reply_t *rmp; int rv = 0; #if WITH_LIBSSL > 0 diff --git a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c index e46d0fbf866..cafb83be38a 100644 --- a/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c +++ b/src/plugins/ioam/lib-vxlan-gpe/vxlan_gpe_api.c @@ -272,7 +272,7 @@ setup_message_id_table (vxlan_gpe_ioam_main_t * sm, api_main_t * am) } static clib_error_t * -vxlan_gpe_init (vlib_main_t * vm) +ioam_vxlan_gpe_init (vlib_main_t * vm) { vxlan_gpe_ioam_main_t *sm = &vxlan_gpe_ioam_main; clib_error_t *error = 0; @@ -321,7 +321,7 @@ vxlan_gpe_init (vlib_main_t * vm) return error; } -VLIB_INIT_FUNCTION (vxlan_gpe_init); +VLIB_INIT_FUNCTION (ioam_vxlan_gpe_init); /* * fd.io coding-style-patch-verification: ON diff --git a/src/plugins/lacp/cli.c b/src/plugins/lacp/cli.c index 36a6f9bfbdf..fee1be19463 100644 --- a/src/plugins/lacp/cli.c +++ b/src/plugins/lacp/cli.c @@ -38,12 +38,12 @@ lacp_dump_ifs (lacp_interface_details_t ** out_lacpifs) hi = vnet_get_hw_interface (vnm, sif->hw_if_index); clib_memcpy(lacpif->interface_name, hi->name, MIN (ARRAY_LEN (lacpif->interface_name) - 1, - strlen ((const char *) hi->name))); + vec_len (hi->name))); bif = bond_get_master_by_dev_instance (sif->bif_dev_instance); hi = vnet_get_hw_interface (vnm, bif->hw_if_index); clib_memcpy(lacpif->bond_interface_name, hi->name, MIN (ARRAY_LEN (lacpif->bond_interface_name) - 1, - strlen ((const char *) hi->name))); + vec_len (hi->name))); clib_memcpy (lacpif->actor_system, sif->actor.system, 6); lacpif->actor_system_priority = sif->actor.system_priority; lacpif->actor_key = sif->actor.key; diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c index befb2ed408b..57e30b43662 100644 --- a/src/plugins/lacp/input.c +++ b/src/plugins/lacp/input.c @@ -276,11 +276,11 @@ lacp_input_format_trace (u8 * s, va_list * args) s = format (s, " Marker Information TLV: length %u\n", marker->marker_info.tlv_length); s = format (s, " Requester port: %u\n", - marker->marker_info.requester_port); + ntohs (marker->marker_info.requester_port)); s = format (s, " Requester system: %U\n", format_ethernet_address, marker->marker_info.requester_system); s = format (s, " Requester transaction ID: %u\n", - marker->marker_info.requester_transaction_id); + ntohl (marker->marker_info.requester_transaction_id)); break; case LACP_SUBTYPE: diff --git a/src/plugins/mactime/mactime.c b/src/plugins/mactime/mactime.c index 57895404390..84aba5f72a4 100644 --- a/src/plugins/mactime/mactime.c +++ b/src/plugins/mactime/mactime.c @@ -513,6 +513,11 @@ show_mactime_command_fn (vlib_main_t * vm, vlib_counter_t allow, drop; ethernet_arp_ip4_entry_t *n, *pool; + if (mm->feature_initialized == 0) + return clib_error_return + (0, + "Feature not initialized, suggest 'help mactime enable-disable'..."); + vec_reset_length (mm->arp_cache_copy); pool = ip4_neighbors_pool (); @@ -668,7 +673,9 @@ clear_mactime_command_fn (vlib_main_t * vm, mactime_main_t *mm = &mactime_main; if (mm->feature_initialized == 0) - return clib_error_return (0, "feature not enabled"); + return clib_error_return + (0, + "Feature not initialized, suggest 'help mactime enable-disable'..."); vlib_clear_combined_counters (&mm->allow_counters); vlib_clear_combined_counters (&mm->drop_counters); diff --git a/src/plugins/memif/node.c b/src/plugins/memif/node.c index dd8f9ba597e..82a7cbc142c 100644 --- a/src/plugins/memif/node.c +++ b/src/plugins/memif/node.c @@ -509,7 +509,7 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, thread_index, - mif->hw_if_index, n_rx_packets, + mif->sw_if_index, n_rx_packets, n_rx_bytes); /* refill ring with empty buffers */ @@ -772,7 +772,7 @@ memif_device_input_zc_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, thread_index, - mif->hw_if_index, n_rx_packets, + mif->sw_if_index, n_rx_packets, n_rx_bytes); /* refill ring with empty buffers */ diff --git a/src/plugins/nat/nat44_cli.c b/src/plugins/nat/nat44_cli.c index e9d3ff5426f..8910f1c6c0a 100644 --- a/src/plugins/nat/nat44_cli.c +++ b/src/plugins/nat/nat44_cli.c @@ -1528,8 +1528,13 @@ snat_det_map_command_fn (vlib_main_t * vm, } } - rv = snat_det_add_map (sm, &in_addr, (u8) in_plen, &out_addr, (u8) out_plen, - is_add); + if (in_plen > 32 || out_plen > 32) + { + error = clib_error_return (0, "network prefix length must be <= 32"); + goto done; + } + + rv = snat_det_add_map (sm, &in_addr, in_plen, &out_addr, out_plen, is_add); if (rv) { diff --git a/src/plugins/nat/nat44_hairpinning.c b/src/plugins/nat/nat44_hairpinning.c index 331e7ca96bd..a0a06c04c05 100644 --- a/src/plugins/nat/nat44_hairpinning.c +++ b/src/plugins/nat/nat44_hairpinning.c @@ -94,7 +94,7 @@ snat_hairpinning (snat_main_t * sm, tcp_header_t * tcp0, u32 proto0, int is_ed) { snat_session_key_t key0, sm0; - snat_session_t *s0; + snat_session_t *s0 = NULL; clib_bihash_kv_8_8_t kv0, value0; ip_csum_t sum0; u32 new_dst_addr0 = 0, old_dst_addr0, ti = 0, si; diff --git a/src/plugins/nat/nat_det.c b/src/plugins/nat/nat_det.c index 0ab96dc1026..65a669bceb9 100644 --- a/src/plugins/nat/nat_det.c +++ b/src/plugins/nat/nat_det.c @@ -71,18 +71,35 @@ snat_det_add_map (snat_main_t * sm, ip4_address_t * in_addr, u8 in_plen, if (is_add) { + u32 num_sessions = (1 << (32 - in_plen)); + if (num_sessions > UINT32_MAX / 1000) + { + // don't let it overflow + return VNET_API_ERROR_INVALID_VALUE; + } + else + { + num_sessions = num_sessions * 1000 - 1; + } + + u32 sharing_ratio = (1 << (32 - in_plen)) / (1 << (32 - out_plen)); + if (!sharing_ratio) + { + // avoid division by zero + return VNET_API_ERROR_INVALID_VALUE; + } + pool_get (sm->det_maps, det_map); clib_memset (det_map, 0, sizeof (*det_map)); det_map->in_addr.as_u32 = in_cmp.as_u32; det_map->in_plen = in_plen; det_map->out_addr.as_u32 = out_cmp.as_u32; det_map->out_plen = out_plen; - det_map->sharing_ratio = (1 << (32 - in_plen)) / (1 << (32 - out_plen)); + det_map->sharing_ratio = sharing_ratio; det_map->ports_per_host = (65535 - 1023) / det_map->sharing_ratio; - vec_validate_init_empty (det_map->sessions, - SNAT_DET_SES_PER_USER * (1 << (32 - in_plen)) - - 1, empty_snat_det_session); + vec_validate_init_empty (det_map->sessions, num_sessions, + empty_snat_det_session); } else { diff --git a/src/plugins/nat/nat_ipfix_logging.c b/src/plugins/nat/nat_ipfix_logging.c index c24c2372b54..e85becba121 100755 --- a/src/plugins/nat/nat_ipfix_logging.c +++ b/src/plugins/nat/nat_ipfix_logging.c @@ -565,6 +565,7 @@ snat_ipfix_header_create (flow_report_main_t * frm, u32 stream_index; ip4_header_t *ip; udp_header_t *udp; + vlib_main_t *vm = vlib_get_main (); stream_index = clib_atomic_fetch_or(&silm->stream_index, 0); stream = &frm->streams[stream_index]; @@ -593,7 +594,7 @@ snat_ipfix_header_create (flow_report_main_t * frm, h->export_time = clib_host_to_net_u32 ((u32) (((f64) frm->unix_time_0) + - (vlib_time_now (frm->vlib_main) - + (vlib_time_now (vm) - frm->vlib_time_0))); sequence_number = clib_atomic_fetch_add (&stream->sequence_number, 1); diff --git a/src/plugins/nat/test/test_nat.py b/src/plugins/nat/test/test_nat.py index f2b1dbf79ac..963970b10e4 100644 --- a/src/plugins/nat/test/test_nat.py +++ b/src/plugins/nat/test/test_nat.py @@ -2927,7 +2927,7 @@ class TestNAT44(MethodHolder): self.pg1.assert_nothing_captured() sleep(1) self.vapi.ipfix_flush() - capture = self.pg3.get_capture(9) + capture = self.pg3.get_capture(7) ipfix = IPFIXDecoder() # first load template for p in capture: @@ -8934,7 +8934,7 @@ class TestNAT64(MethodHolder): self.pg1.assert_nothing_captured() sleep(1) self.vapi.ipfix_flush() - capture = self.pg3.get_capture(9) + capture = self.pg3.get_capture(7) ipfix = IPFIXDecoder() # first load template for p in capture: diff --git a/src/plugins/pppoe/pppoe.h b/src/plugins/pppoe/pppoe.h index 471727ce893..3e331ee6a11 100644 --- a/src/plugins/pppoe/pppoe.h +++ b/src/plugins/pppoe/pppoe.h @@ -94,6 +94,7 @@ typedef enum PPPOE_N_ERROR, } pppoe_input_error_t; +extern char *pppoe_error_strings[]; #define MTU 1500 #define MTU_BUFFERS ((MTU + vlib_buffer_get_default_data_size(vm) - 1) / vlib_buffer_get_default_data_size(vm)) diff --git a/src/plugins/pppoe/pppoe_cp_node.c b/src/plugins/pppoe/pppoe_cp_node.c index 3f866450cfb..bf9018e8c90 100644 --- a/src/plugins/pppoe/pppoe_cp_node.c +++ b/src/plugins/pppoe/pppoe_cp_node.c @@ -237,6 +237,9 @@ VLIB_REGISTER_NODE (pppoe_cp_dispatch_node) = { /* Takes a vector of packets. */ .vector_size = sizeof (u32), + .n_errors = PPPOE_N_ERROR, + .error_strings = pppoe_error_strings, + .n_next_nodes = PPPOE_CP_N_NEXT, .next_nodes = { #define _(s,n) [PPPOE_CP_NEXT_##s] = n, diff --git a/src/plugins/pppoe/pppoe_decap.c b/src/plugins/pppoe/pppoe_decap.c index 256dd83e43d..d3f4a5fedf3 100644 --- a/src/plugins/pppoe/pppoe_decap.c +++ b/src/plugins/pppoe/pppoe_decap.c @@ -390,12 +390,14 @@ VLIB_NODE_FN (pppoe_input_node) (vlib_main_t * vm, return from_frame->n_vectors; } -static char * pppoe_error_strings[] = { +#ifndef CLIB_MARCH_VARIANT +char * pppoe_error_strings[] = { #define pppoe_error(n,s) s, #include <pppoe/pppoe_error.def> #undef pppoe_error #undef _ }; +#endif /* CLIB_MARCH_VARIANT */ VLIB_REGISTER_NODE (pppoe_input_node) = { .name = "pppoe-input", diff --git a/src/plugins/rdma/CMakeLists.txt b/src/plugins/rdma/CMakeLists.txt index bf111195ecc..b04c5c12d18 100644 --- a/src/plugins/rdma/CMakeLists.txt +++ b/src/plugins/rdma/CMakeLists.txt @@ -29,8 +29,15 @@ endif() string_append(RDMA_LINK_FLAGS "-Wl,--whole-archive,${MLX5_LIB},--no-whole-archive") -set(CMAKE_REQUIRED_FLAGS "-fPIC -shared -pthread ${RDMA_LINK_FLAGS} ${IBVERBS_LIB} ${RDMA_UTIL_LIB}") -CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" IBVERBS_COMPILES_CHECK) +set(CMAKE_REQUIRED_FLAGS "-fPIC -shared -pthread -Wno-unused-command-line-argument ${RDMA_LINK_FLAGS} ${IBVERBS_LIB} ${RDMA_UTIL_LIB}") +set(CMAKE_REQUIRED_INCLUDES "${IBVERBS_INCLUDE_DIR}") +set(CMAKE_REQUIRED_LIBRARIES "c") # force linkage by including libc explicitely +CHECK_C_SOURCE_COMPILES(" +#include <infiniband/verbs.h> +int main(void) +{ + return 0 != ibv_get_device_list(0); +}" IBVERBS_COMPILES_CHECK) if (NOT IBVERBS_COMPILES_CHECK) message(WARNING "rdma plugins - no working ibverbs found - rdma plugin disabled") diff --git a/src/plugins/srv6-ad/ad.c b/src/plugins/srv6-ad/ad.c index 73ea3f6ac1f..9bf48147188 100644 --- a/src/plugins/srv6-ad/ad.c +++ b/src/plugins/srv6-ad/ad.c @@ -105,8 +105,12 @@ srv6_ad_localsid_creation_fn (ip6_sr_localsid_t * localsid) /* Set interface in promiscuous mode */ vnet_main_t *vnm = vnet_get_main (); - ethernet_set_flags (vnm, ls_mem->sw_if_index_in, - ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, ls_mem->sw_if_index_in); + /* Make sure it is main interface */ + if (hi->sw_if_index == ls_mem->sw_if_index_in) + ethernet_set_flags (vnm, hi->hw_if_index, + ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); /* Associate local SID index to this interface (resize vector if needed) */ if (ls_mem->sw_if_index_in >= vec_len (sm->sw_iface_localsid2)) @@ -196,7 +200,11 @@ srv6_ad_localsid_removal_fn (ip6_sr_localsid_t * localsid) /* Disable promiscuous mode on the interface */ vnet_main_t *vnm = vnet_get_main (); - ethernet_set_flags (vnm, ls_mem->sw_if_index_in, 0); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, ls_mem->sw_if_index_in); + /* Make sure it is main interface */ + if (hi->sw_if_index == ls_mem->sw_if_index_in) + ethernet_set_flags (vnm, hi->hw_if_index, 0); /* Remove local SID index from interface table */ sm->sw_iface_localsid2[ls_mem->sw_if_index_in] = ~(u32) 0; diff --git a/src/plugins/srv6-as/as.c b/src/plugins/srv6-as/as.c index 3a476044d60..69efc99e429 100644 --- a/src/plugins/srv6-as/as.c +++ b/src/plugins/srv6-as/as.c @@ -177,8 +177,12 @@ srv6_as_localsid_creation_fn (ip6_sr_localsid_t * localsid) /* Set interface in promiscuous mode */ vnet_main_t *vnm = vnet_get_main (); - ethernet_set_flags (vnm, ls_mem->sw_if_index_in, - ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, ls_mem->sw_if_index_in); + /* Make sure it is main interface */ + if (hi->sw_if_index == ls_mem->sw_if_index_in) + ethernet_set_flags (vnm, hi->hw_if_index, + ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); /* Prepare rewrite string */ ls_mem->rewrite = prepare_rewrite (ls_mem->src_addr, ls_mem->sid_list, @@ -278,7 +282,11 @@ srv6_as_localsid_removal_fn (ip6_sr_localsid_t * localsid) /* Disable promiscuous mode on the interface */ vnet_main_t *vnm = vnet_get_main (); - ethernet_set_flags (vnm, ls_mem->sw_if_index_in, 0); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, ls_mem->sw_if_index_in); + /* Make sure it is main interface */ + if (hi->sw_if_index == ls_mem->sw_if_index_in) + ethernet_set_flags (vnm, hi->hw_if_index, 0); /* Remove local SID index from interface table */ sm->sw_iface_localsid2[ls_mem->sw_if_index_in] = ~(u32) 0; |