diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/dev_octeon/flow.c | 12 | ||||
-rw-r--r-- | src/plugins/dev_octeon/port.c | 27 | ||||
-rw-r--r-- | src/plugins/dev_octeon/rx_node.c | 8 | ||||
-rw-r--r-- | src/plugins/http_static/http_static.api | 12 | ||||
-rw-r--r-- | src/plugins/http_static/http_static.c | 22 | ||||
-rw-r--r-- | src/plugins/http_static/http_static.h | 1 | ||||
-rw-r--r-- | src/plugins/http_static/http_static_test.c | 24 | ||||
-rw-r--r-- | src/plugins/http_static/static_server.c | 2 | ||||
-rw-r--r-- | src/plugins/mss_clamp/mss_clamp.c | 4 | ||||
-rw-r--r-- | src/plugins/tracenode/node.c | 10 | ||||
-rw-r--r-- | src/vnet/srv6/sr.h | 23 | ||||
-rw-r--r-- | src/vnet/srv6/sr_localsid.c | 39 | ||||
-rw-r--r-- | src/vnet/srv6/sr_policy_rewrite.c | 6 | ||||
-rw-r--r-- | src/vnet/srv6/sr_types.api | 5 | ||||
-rw-r--r-- | src/vnet/tcp/tcp_input.c | 2 | ||||
-rw-r--r-- | src/vppinfra/mem.h | 2 | ||||
-rw-r--r-- | src/vppinfra/mem_dlmalloc.c | 19 | ||||
-rw-r--r-- | src/vppinfra/stack.c | 25 | ||||
-rw-r--r-- | src/vppinfra/stack.h | 1 |
19 files changed, 154 insertions, 90 deletions
diff --git a/src/plugins/dev_octeon/flow.c b/src/plugins/dev_octeon/flow.c index 5bef25f5369..e86425ec85d 100644 --- a/src/plugins/dev_octeon/flow.c +++ b/src/plugins/dev_octeon/flow.c @@ -131,6 +131,7 @@ oct_flow_validate_params (vlib_main_t *vm, vnet_dev_port_t *port, vnet_dev_port_cfg_type_t type, u32 flow_index, uword *priv_data) { + vnet_dev_port_interfaces_t *ifs = port->interfaces; vnet_flow_t *flow = vnet_get_flow (flow_index); u32 last_queue; u32 qid; @@ -151,11 +152,11 @@ oct_flow_validate_params (vlib_main_t *vm, vnet_dev_port_t *port, if (flow->actions & VNET_FLOW_ACTION_REDIRECT_TO_QUEUE) { qid = flow->redirect_queue; - if (qid > port->intf.num_rx_queues - 1 || qid < 0) + if (qid > ifs->num_rx_queues - 1 || qid < 0) { log_err (port->dev, "Given Q(%d) is invalid, supported range is %d-%d", qid, 0, - port->intf.num_rx_queues - 1); + ifs->num_rx_queues - 1); return VNET_DEV_ERR_NOT_SUPPORTED; } } @@ -163,12 +164,12 @@ oct_flow_validate_params (vlib_main_t *vm, vnet_dev_port_t *port, if (flow->actions & VNET_FLOW_ACTION_RSS) { last_queue = flow->queue_index + flow->queue_num; - if (last_queue > port->intf.num_rx_queues - 1) + if (last_queue > ifs->num_rx_queues - 1) { log_err (port->dev, "Given Q range(%d-%d) is invalid, supported range is %d-%d", flow->queue_index, flow->queue_index + flow->queue_num, 0, - port->intf.num_rx_queues - 1); + ifs->num_rx_queues - 1); return VNET_DEV_ERR_NOT_SUPPORTED; } } @@ -538,6 +539,7 @@ oct_flow_add (vlib_main_t *vm, vnet_dev_port_t *port, vnet_flow_t *flow, struct roc_npc_item_info item_info[ROC_NPC_ITEM_TYPE_END] = {}; struct roc_npc_action actions[ROC_NPC_ITEM_TYPE_END] = {}; oct_port_t *oct_port = vnet_dev_get_port_data (port); + vnet_dev_port_interfaces_t *ifs = port->interfaces; ethernet_header_t eth_spec = {}, eth_mask = {}; sctp_header_t sctp_spec = {}, sctp_mask = {}; gtpu_header_t gtpu_spec = {}, gtpu_mask = {}; @@ -775,7 +777,7 @@ parse_flow_actions: log_err (port->dev, "RSS action has no queues"); return VNET_DEV_ERR_NOT_SUPPORTED; } - queues = clib_mem_alloc (sizeof (u16) * port->intf.num_rx_queues); + queues = clib_mem_alloc (sizeof (u16) * ifs->num_rx_queues); for (index = 0; index < flow->queue_num; index++) queues[index] = flow->queue_index++; diff --git a/src/plugins/dev_octeon/port.c b/src/plugins/dev_octeon/port.c index 528683fa3c7..f8a7d6ba7db 100644 --- a/src/plugins/dev_octeon/port.c +++ b/src/plugins/dev_octeon/port.c @@ -129,6 +129,7 @@ oct_port_init (vlib_main_t *vm, vnet_dev_port_t *port) vnet_dev_t *dev = port->dev; oct_device_t *cd = vnet_dev_get_data (dev); oct_port_t *cp = vnet_dev_get_port_data (port); + vnet_dev_port_interfaces_t *ifs = port->interfaces; u8 mac_addr[PLT_ETHER_ADDR_LEN]; struct roc_nix *nix = cd->nix; vnet_dev_rv_t rv; @@ -136,14 +137,14 @@ oct_port_init (vlib_main_t *vm, vnet_dev_port_t *port) log_debug (dev, "port init: port %u", port->port_id); - if ((rrv = roc_nix_lf_alloc (nix, port->intf.num_rx_queues, - port->intf.num_tx_queues, rxq_cfg))) + if ((rrv = roc_nix_lf_alloc (nix, ifs->num_rx_queues, ifs->num_tx_queues, + rxq_cfg))) { oct_port_deinit (vm, port); return oct_roc_err ( dev, rrv, "roc_nix_lf_alloc(nb_rxq = %u, nb_txq = %d, rxq_cfg=0x%lx) failed", - port->intf.num_rx_queues, port->intf.num_tx_queues, rxq_cfg); + ifs->num_rx_queues, ifs->num_tx_queues, rxq_cfg); } cp->lf_allocated = 1; @@ -428,6 +429,7 @@ oct_port_start (vlib_main_t *vm, vnet_dev_port_t *port) { vnet_dev_t *dev = port->dev; oct_device_t *cd = vnet_dev_get_data (dev); + oct_port_t *cp = vnet_dev_get_port_data (port); struct roc_nix *nix = cd->nix; struct roc_nix_eeprom_info eeprom_info = {}; vnet_dev_rv_t rv; @@ -451,6 +453,12 @@ oct_port_start (vlib_main_t *vm, vnet_dev_port_t *port) goto done; } + if ((rrv = roc_npc_mcam_enable_all_entries (&cp->npc, true))) + { + rv = oct_roc_err (dev, rrv, "roc_npc_mcam_enable_all_entries() failed"); + goto done; + } + vnet_dev_poll_port_add (vm, port, 0.5, oct_port_poll); if (roc_nix_eeprom_info_get (nix, &eeprom_info) == 0) @@ -469,6 +477,7 @@ oct_port_stop (vlib_main_t *vm, vnet_dev_port_t *port) { vnet_dev_t *dev = port->dev; oct_device_t *cd = vnet_dev_get_data (dev); + oct_port_t *cp = vnet_dev_get_port_data (port); struct roc_nix *nix = cd->nix; int rrv; @@ -476,6 +485,14 @@ oct_port_stop (vlib_main_t *vm, vnet_dev_port_t *port) vnet_dev_poll_port_remove (vm, port, oct_port_poll); + /* Disable all the NPC entries */ + rrv = roc_npc_mcam_enable_all_entries (&cp->npc, false); + if (rrv) + { + oct_roc_err (dev, rrv, "roc_npc_mcam_enable_all_entries() failed"); + return; + } + rrv = roc_nix_npc_rx_ena_dis (nix, false); if (rrv) { @@ -575,6 +592,10 @@ oct_port_add_del_eth_addr (vlib_main_t *vm, vnet_dev_port_t *port, rv = oct_roc_err (dev, rrv, "roc_nix_mac_addr_set() failed"); } } + + rrv = roc_nix_rss_default_setup (nix, default_rss_flowkey); + if (rrv) + rv = oct_roc_err (dev, rrv, "roc_nix_rss_default_setup() failed"); } } diff --git a/src/plugins/dev_octeon/rx_node.c b/src/plugins/dev_octeon/rx_node.c index b057c4d7047..833227eeea8 100644 --- a/src/plugins/dev_octeon/rx_node.c +++ b/src/plugins/dev_octeon/rx_node.c @@ -103,7 +103,7 @@ oct_rx_batch (vlib_main_t *vm, oct_rx_node_ctx_t *ctx, vnet_dev_rx_queue_t *rxq, u32 n) { oct_rxq_t *crq = vnet_dev_get_rx_queue_data (rxq); - vlib_buffer_template_t bt = rxq->buffer_template; + vlib_buffer_template_t bt = vnet_dev_get_rx_queue_if_buffer_template (rxq); u32 b0_err_flags = 0, b1_err_flags = 0; u32 b2_err_flags = 0, b3_err_flags = 0; u32 n_left, err_flags = 0; @@ -347,9 +347,9 @@ oct_rx_node_inline (vlib_main_t *vm, vlib_node_runtime_t *node, oct_nix_rx_cqe_desc_t *descs = crq->cq.desc_base; oct_nix_lf_cq_op_status_t status; oct_rx_node_ctx_t _ctx = { - .next_index = rxq->next_index, - .sw_if_index = port->intf.sw_if_index, - .hw_if_index = port->intf.hw_if_index, + .next_index = vnet_dev_get_rx_queue_if_next_index(rxq), + .sw_if_index = vnet_dev_get_rx_queue_if_sw_if_index (rxq), + .hw_if_index = vnet_dev_get_rx_queue_if_hw_if_index (rxq), }, *ctx = &_ctx; /* get head and tail from NIX_LF_CQ_OP_STATUS */ diff --git a/src/plugins/http_static/http_static.api b/src/plugins/http_static/http_static.api index dd4f513a420..60c0369848d 100644 --- a/src/plugins/http_static/http_static.api +++ b/src/plugins/http_static/http_static.api @@ -3,20 +3,21 @@ This file defines static http server control-plane API messages */ -option version = "2.2.0"; +option version = "2.3.0"; /** \brief Configure and enable the static http server @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param fifo_size - size (in bytes) of the session FIFOs @param cache_size_limit - size (in bytes) of the in-memory file data cache + @param max_age - how long a response is considered fresh (in seconds) @param prealloc_fifos - number of preallocated fifos (usually 0) @param private_segment_size - fifo segment size (usually 0) @param www_root - html root path @param uri - bind URI, defaults to "tcp://0.0.0.0/80" */ -autoreply define http_static_enable { +autoreply define http_static_enable_v2 { option deprecated; /* Client identifier, set from api_main.my_client_index */ @@ -27,6 +28,7 @@ autoreply define http_static_enable { /* Typical options */ u32 fifo_size; u32 cache_size_limit; + u32 max_age [default=600]; /* Unusual options */ u32 prealloc_fifos; u32 private_segment_size; @@ -43,13 +45,16 @@ autoreply define http_static_enable { @param fifo_size - size (in bytes) of the session FIFOs @param cache_size_limit - size (in bytes) of the in-memory file data cache @param max_age - how long a response is considered fresh (in seconds) + @param keepalive_timeout - timeout during which client connection will stay open (in seconds) @param prealloc_fifos - number of preallocated fifos (usually 0) @param private_segment_size - fifo segment size (usually 0) @param www_root - html root path @param uri - bind URI, defaults to "tcp://0.0.0.0/80" */ -autoreply define http_static_enable_v2 { +autoreply define http_static_enable_v3 { + option deprecated; + /* Client identifier, set from api_main.my_client_index */ u32 client_index; @@ -59,6 +64,7 @@ autoreply define http_static_enable_v2 { u32 fifo_size; u32 cache_size_limit; u32 max_age [default=600]; + u32 keepalive_timeout [default=60]; /* Unusual options */ u32 prealloc_fifos; u32 private_segment_size; diff --git a/src/plugins/http_static/http_static.c b/src/plugins/http_static/http_static.c index 967b8474af8..464fd27e90d 100644 --- a/src/plugins/http_static/http_static.c +++ b/src/plugins/http_static/http_static.c @@ -66,7 +66,8 @@ hss_register_url_handler (hss_url_handler_fn fp, const char *url, */ static int hss_enable_api (u32 fifo_size, u32 cache_limit, u32 prealloc_fifos, - u32 private_segment_size, u8 *www_root, u8 *uri, u32 max_age) + u32 private_segment_size, u8 *www_root, u8 *uri, u32 max_age, + u32 keepalive_timeout) { hss_main_t *hsm = &hss_main; int rv; @@ -78,6 +79,7 @@ hss_enable_api (u32 fifo_size, u32 cache_limit, u32 prealloc_fifos, hsm->www_root = format (0, "%s%c", www_root, 0); hsm->uri = format (0, "%s%c", uri, 0); hsm->max_age = max_age; + hsm->keepalive_timeout = keepalive_timeout; if (vec_len (hsm->www_root) < 2) return VNET_API_ERROR_INVALID_VALUE; @@ -104,10 +106,10 @@ hss_enable_api (u32 fifo_size, u32 cache_limit, u32 prealloc_fifos, } /* API message handler */ -static void vl_api_http_static_enable_t_handler - (vl_api_http_static_enable_t * mp) +static void +vl_api_http_static_enable_v2_t_handler (vl_api_http_static_enable_v2_t *mp) { - vl_api_http_static_enable_reply_t *rmp; + vl_api_http_static_enable_v2_reply_t *rmp; hss_main_t *hsm = &hss_main; int rv; @@ -117,16 +119,16 @@ static void vl_api_http_static_enable_t_handler rv = hss_enable_api (ntohl (mp->fifo_size), ntohl (mp->cache_size_limit), ntohl (mp->prealloc_fifos), ntohl (mp->private_segment_size), mp->www_root, mp->uri, - HSS_DEFAULT_MAX_AGE); + ntohl (mp->max_age), HSS_DEFAULT_KEEPALIVE_TIMEOUT); - REPLY_MACRO (VL_API_HTTP_STATIC_ENABLE_REPLY); + REPLY_MACRO (VL_API_HTTP_STATIC_ENABLE_V2_REPLY); } /* API message handler */ static void -vl_api_http_static_enable_v2_t_handler (vl_api_http_static_enable_v2_t *mp) +vl_api_http_static_enable_v3_t_handler (vl_api_http_static_enable_v3_t *mp) { - vl_api_http_static_enable_v2_reply_t *rmp; + vl_api_http_static_enable_v3_reply_t *rmp; hss_main_t *hsm = &hss_main; int rv; @@ -136,9 +138,9 @@ vl_api_http_static_enable_v2_t_handler (vl_api_http_static_enable_v2_t *mp) rv = hss_enable_api (ntohl (mp->fifo_size), ntohl (mp->cache_size_limit), ntohl (mp->prealloc_fifos), ntohl (mp->private_segment_size), mp->www_root, mp->uri, - ntohl (mp->max_age)); + ntohl (mp->max_age), ntohl (mp->keepalive_timeout)); - REPLY_MACRO (VL_API_HTTP_STATIC_ENABLE_V2_REPLY); + REPLY_MACRO (VL_API_HTTP_STATIC_ENABLE_V3_REPLY); } #include <http_static/http_static.api.c> diff --git a/src/plugins/http_static/http_static.h b/src/plugins/http_static/http_static.h index fac24db4ec9..5e0654fae24 100644 --- a/src/plugins/http_static/http_static.h +++ b/src/plugins/http_static/http_static.h @@ -24,6 +24,7 @@ #include <http_static/http_cache.h> #define HSS_DEFAULT_MAX_AGE 600 +#define HSS_DEFAULT_KEEPALIVE_TIMEOUT 60 /** @file http_static.h * Static http server definitions diff --git a/src/plugins/http_static/http_static_test.c b/src/plugins/http_static/http_static_test.c index f701c8b9ee7..edb016f9e05 100644 --- a/src/plugins/http_static/http_static_test.c +++ b/src/plugins/http_static/http_static_test.c @@ -39,10 +39,10 @@ http_static_test_main_t http_static_test_main; #include <vlibapi/vat_helper_macros.h> static int -api_http_static_enable (vat_main_t * vam) +api_http_static_enable_v2 (vat_main_t *vam) { unformat_input_t *line_input = vam->input; - vl_api_http_static_enable_t *mp; + vl_api_http_static_enable_v2_t *mp; u64 tmp; u8 *www_root = 0; u8 *uri = 0; @@ -50,6 +50,7 @@ api_http_static_enable (vat_main_t * vam) u32 private_segment_size = 0; u32 fifo_size = 8 << 10; u32 cache_size_limit = 1 << 20; + u32 max_age = HSS_DEFAULT_MAX_AGE; int ret; /* Parse args required to build the message */ @@ -89,7 +90,8 @@ api_http_static_enable (vat_main_t * vam) } cache_size_limit = (u32) tmp; } - + else if (unformat (line_input, "max-age %d", &max_age)) + ; else if (unformat (line_input, "uri %s", &uri)) ; else @@ -108,16 +110,15 @@ api_http_static_enable (vat_main_t * vam) if (uri == 0) uri = format (0, "tcp://0.0.0.0/80%c", 0); - - /* Construct the API message */ - M (HTTP_STATIC_ENABLE, mp); + M (HTTP_STATIC_ENABLE_V2, mp); strncpy_s ((char *) mp->www_root, 256, (const char *) www_root, 256); strncpy_s ((char *) mp->uri, 256, (const char *) uri, 256); mp->fifo_size = ntohl (fifo_size); mp->cache_size_limit = ntohl (cache_size_limit); mp->prealloc_fifos = ntohl (prealloc_fifos); mp->private_segment_size = ntohl (private_segment_size); + mp->max_age = ntohl (max_age); /* send it... */ S (mp); @@ -128,10 +129,10 @@ api_http_static_enable (vat_main_t * vam) } static int -api_http_static_enable_v2 (vat_main_t *vam) +api_http_static_enable_v3 (vat_main_t *vam) { unformat_input_t *line_input = vam->input; - vl_api_http_static_enable_v2_t *mp; + vl_api_http_static_enable_v3_t *mp; u64 tmp; u8 *www_root = 0; u8 *uri = 0; @@ -140,6 +141,7 @@ api_http_static_enable_v2 (vat_main_t *vam) u32 fifo_size = 8 << 10; u32 cache_size_limit = 1 << 20; u32 max_age = HSS_DEFAULT_MAX_AGE; + u32 keepalive_timeout = HSS_DEFAULT_KEEPALIVE_TIMEOUT; int ret; /* Parse args required to build the message */ @@ -181,6 +183,9 @@ api_http_static_enable_v2 (vat_main_t *vam) } else if (unformat (line_input, "max-age %d", &max_age)) ; + else if (unformat (line_input, "keepalive-timeout %d", + &keepalive_timeout)) + ; else if (unformat (line_input, "uri %s", &uri)) ; else @@ -200,7 +205,7 @@ api_http_static_enable_v2 (vat_main_t *vam) uri = format (0, "tcp://0.0.0.0/80%c", 0); /* Construct the API message */ - M (HTTP_STATIC_ENABLE_V2, mp); + M (HTTP_STATIC_ENABLE_V3, mp); strncpy_s ((char *) mp->www_root, 256, (const char *) www_root, 256); strncpy_s ((char *) mp->uri, 256, (const char *) uri, 256); mp->fifo_size = ntohl (fifo_size); @@ -208,6 +213,7 @@ api_http_static_enable_v2 (vat_main_t *vam) mp->prealloc_fifos = ntohl (prealloc_fifos); mp->private_segment_size = ntohl (private_segment_size); mp->max_age = ntohl (max_age); + mp->keepalive_timeout = ntohl (keepalive_timeout); /* send it... */ S (mp); diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c index d1ece75ce37..a37cc3f03b2 100644 --- a/src/plugins/http_static/static_server.c +++ b/src/plugins/http_static/static_server.c @@ -902,7 +902,7 @@ hss_create_command_fn (vlib_main_t *vm, unformat_input_t *input, hsm->fifo_size = 0; hsm->cache_size = 10 << 20; hsm->max_age = HSS_DEFAULT_MAX_AGE; - hsm->keepalive_timeout = 60; + hsm->keepalive_timeout = HSS_DEFAULT_KEEPALIVE_TIMEOUT; /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) diff --git a/src/plugins/mss_clamp/mss_clamp.c b/src/plugins/mss_clamp/mss_clamp.c index cdac5456641..f1c435a347b 100644 --- a/src/plugins/mss_clamp/mss_clamp.c +++ b/src/plugins/mss_clamp/mss_clamp.c @@ -46,7 +46,7 @@ mssc_enable_disable_feat (u32 sw_if_index, u8 dir4, u8 dir6, int enable) sw_if_index, enable, 0, 0); } -int +__clib_export int mssc_enable_disable (u32 sw_if_index, u8 dir4, u8 dir6, u16 mss4, u16 mss6) { mssc_main_t *cm = &mssc_main; @@ -81,7 +81,7 @@ mssc_enable_disable (u32 sw_if_index, u8 dir4, u8 dir6, u16 mss4, u16 mss6) return rv; } -int +__clib_export int mssc_get_mss (u32 sw_if_index, u8 *dir4, u8 *dir6, u16 *mss4, u16 *mss6) { mssc_main_t *cm = &mssc_main; diff --git a/src/plugins/tracenode/node.c b/src/plugins/tracenode/node.c index 444d93f1708..c56df589826 100644 --- a/src/plugins/tracenode/node.c +++ b/src/plugins/tracenode/node.c @@ -55,23 +55,19 @@ tracenode_inline (vlib_main_t *vm, vlib_node_runtime_t *node, /* enqueue b0 to the current next frame */ vnet_feature_next_u16 (next, b[0]); - /* buffer already traced */ - if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED)) - goto skip; - if (is_pcap && vnet_is_packet_pcaped (pp, b[0], ~0)) { pcap_add_buffer (&pp->pcap_main, vm, from0[0], pp->max_bytes_per_pkt); } - else if (!is_pcap && vlib_trace_buffer (vm, node, next[0], b[0], - 1 /* follow_chain */)) + else if (!is_pcap && !(b[0]->flags & VLIB_BUFFER_IS_TRACED) && + vlib_trace_buffer (vm, node, next[0], b[0], + 1 /* follow_chain */)) { tracenode_trace_t *tr = vlib_add_trace (vm, node, b[0], sizeof *tr); tr->sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_RX]; } - skip: b++; from0++; next++; diff --git a/src/vnet/srv6/sr.h b/src/vnet/srv6/sr.h index ba114f2de6c..40edbbaf437 100644 --- a/src/vnet/srv6/sr.h +++ b/src/vnet/srv6/sr.h @@ -43,10 +43,22 @@ #define SR_BEHAVIOR_DX4 7 #define SR_BEHAVIOR_DT6 8 #define SR_BEHAVIOR_DT4 9 -#define SR_BEHAVIOR_END_UN_PERF 10 -#define SR_BEHAVIOR_END_UN 11 -#define SR_BEHAVIOR_UA 12 -#define SR_BEHAVIOR_LAST 13 /* Must always be the last one */ +/** + * SR_BEHAVIOR_LAST + * Not used anymore. Kept not to break the API. + * We use SR_BEHAVIOR_CURRENT_LAST going forward + * */ +#define SR_BEHAVIOR_LAST 10 +#define SR_BEHAVIOR_END_UN_PERF 11 +#define SR_BEHAVIOR_END_UN 12 +#define SR_BEHAVIOR_UA 13 + +/** + * SR_BEHAVIOR_CURRENT_LAST + * MUST be updated everytime we add new behaviors. + * MUST be set to value of last added behavior + 1. + * */ +#define SR_BEHAVIOR_CURRENT_LAST 14 #define SR_STEER_L2 2 #define SR_STEER_IPV4 4 @@ -165,7 +177,8 @@ typedef int (sr_plugin_callback_t) (ip6_sr_localsid_t * localsid); */ typedef struct { - u16 sr_localsid_function_number; /**< SR LocalSID plugin function (>SR_BEHAVIOR_LAST) */ + u16 sr_localsid_function_number; /**< SR LocalSID plugin function + (>SR_BEHAVIOR_CURRENT_LAST) */ u8 *function_name; /**< Function name. (key). */ diff --git a/src/vnet/srv6/sr_localsid.c b/src/vnet/srv6/sr_localsid.c index 578ee7d7239..2172fa10ef1 100644 --- a/src/vnet/srv6/sr_localsid.c +++ b/src/vnet/srv6/sr_localsid.c @@ -100,10 +100,10 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, { /* Retrieve localsid */ ls = pool_elt_at_index (sm->localsids, p[0]); - if (ls->behavior >= SR_BEHAVIOR_LAST) + if (ls->behavior >= SR_BEHAVIOR_CURRENT_LAST) { - plugin = pool_elt_at_index (sm->plugin_functions, - ls->behavior - SR_BEHAVIOR_LAST); + plugin = pool_elt_at_index ( + sm->plugin_functions, ls->behavior - SR_BEHAVIOR_CURRENT_LAST); pref_length = plugin->prefix_length; } @@ -130,7 +130,7 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, || ls->behavior == SR_BEHAVIOR_DX4) adj_unlock (ls->nh_adj); - if (ls->behavior >= SR_BEHAVIOR_LAST) + if (ls->behavior >= SR_BEHAVIOR_CURRENT_LAST) { /* Callback plugin removal function */ rv = plugin->removal (ls); @@ -149,13 +149,13 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, if (is_del) return -2; - if (behavior >= SR_BEHAVIOR_LAST) - { - sr_localsid_fn_registration_t *plugin = 0; - plugin = - pool_elt_at_index (sm->plugin_functions, behavior - SR_BEHAVIOR_LAST); - pref_length = plugin->prefix_length; - } + if (behavior >= SR_BEHAVIOR_CURRENT_LAST) + { + sr_localsid_fn_registration_t *plugin = 0; + plugin = pool_elt_at_index (sm->plugin_functions, + behavior - SR_BEHAVIOR_CURRENT_LAST); + pref_length = plugin->prefix_length; + } if (localsid_prefix_len != 0) { @@ -294,14 +294,14 @@ sr_cli_localsid (char is_del, ip6_address_t * localsid_addr, ls->behavior == SR_BEHAVIOR_UA) dpo_set (&dpo, sr_localsid_un_perf_dpo_type, DPO_PROTO_IP6, ls - sm->localsids); - else if (ls->behavior > SR_BEHAVIOR_D_FIRST - && ls->behavior < SR_BEHAVIOR_LAST) + else if (ls->behavior > SR_BEHAVIOR_D_FIRST && + ls->behavior < SR_BEHAVIOR_CURRENT_LAST) dpo_set (&dpo, sr_localsid_d_dpo_type, DPO_PROTO_IP6, ls - sm->localsids); - else if (ls->behavior >= SR_BEHAVIOR_LAST) + else if (ls->behavior >= SR_BEHAVIOR_CURRENT_LAST) { sr_localsid_fn_registration_t *plugin = 0; plugin = pool_elt_at_index (sm->plugin_functions, - ls->behavior - SR_BEHAVIOR_LAST); + ls->behavior - SR_BEHAVIOR_CURRENT_LAST); /* Copy the unformat memory result */ ls->plugin_mem = ls_plugin_mem; /* Callback plugin creation function */ @@ -672,11 +672,10 @@ show_sr_localsid_command_fn (vlib_main_t * vm, unformat_input_t * input, FIB_PROTOCOL_IP4)); break; default: - if (ls->behavior >= SR_BEHAVIOR_LAST) + if (ls->behavior >= SR_BEHAVIOR_CURRENT_LAST) { - sr_localsid_fn_registration_t *plugin = - pool_elt_at_index (sm->plugin_functions, - ls->behavior - SR_BEHAVIOR_LAST); + sr_localsid_fn_registration_t *plugin = pool_elt_at_index ( + sm->plugin_functions, ls->behavior - SR_BEHAVIOR_CURRENT_LAST); vlib_cli_output (vm, "\tAddress: \t%U/%u\n" "\tBehavior: \t%s (%s)\n\t%U", @@ -2404,7 +2403,7 @@ sr_localsid_register_function (vlib_main_t * vm, u8 * fn_name, clib_memset (plugin, 0, sizeof (*plugin)); plugin->sr_localsid_function_number = (plugin - sm->plugin_functions); - plugin->sr_localsid_function_number += SR_BEHAVIOR_LAST; + plugin->sr_localsid_function_number += SR_BEHAVIOR_CURRENT_LAST; plugin->prefix_length = prefix_length; plugin->ls_format = ls_format; plugin->ls_unformat = ls_unformat; diff --git a/src/vnet/srv6/sr_policy_rewrite.c b/src/vnet/srv6/sr_policy_rewrite.c index 0aa88cc273e..a9114628f95 100644 --- a/src/vnet/srv6/sr_policy_rewrite.c +++ b/src/vnet/srv6/sr_policy_rewrite.c @@ -418,7 +418,7 @@ create_sl (ip6_sr_policy_t *sr_policy, ip6_address_t *sl, { plugin = pool_elt_at_index (sm->policy_plugin_functions, - sr_policy->plugin - SR_BEHAVIOR_LAST); + sr_policy->plugin - SR_BEHAVIOR_CURRENT_LAST); segment_list->plugin = sr_policy->plugin; segment_list->plugin_mem = sr_policy->plugin_mem; @@ -828,7 +828,7 @@ sr_policy_del (ip6_address_t * bsid, u32 index) plugin = pool_elt_at_index (sm->policy_plugin_functions, - sr_policy->plugin - SR_BEHAVIOR_LAST); + sr_policy->plugin - SR_BEHAVIOR_CURRENT_LAST); plugin->removal (sr_policy); sr_policy->plugin = 0; @@ -3499,7 +3499,7 @@ sr_policy_register_function (vlib_main_t * vm, u8 * fn_name, clib_memset (plugin, 0, sizeof (*plugin)); plugin->sr_policy_function_number = (plugin - sm->policy_plugin_functions); - plugin->sr_policy_function_number += SR_BEHAVIOR_LAST; + plugin->sr_policy_function_number += SR_BEHAVIOR_CURRENT_LAST; plugin->prefix_length = prefix_length; plugin->ls_format = ls_format; plugin->ls_unformat = ls_unformat; diff --git a/src/vnet/srv6/sr_types.api b/src/vnet/srv6/sr_types.api index 967eab0bd5a..7bc22c1a0f4 100644 --- a/src/vnet/srv6/sr_types.api +++ b/src/vnet/srv6/sr_types.api @@ -35,7 +35,10 @@ enum sr_behavior : u8 SR_BEHAVIOR_API_DX4 = 7, SR_BEHAVIOR_API_DT6 = 8, SR_BEHAVIOR_API_DT4 = 9, - SR_BEHAVIOR_API_LAST = 10, /* Must always be the last one */ + SR_BEHAVIOR_API_LAST = 10, /* Not used. Kept not to break the API */ + SR_BEHAVIOR_API_END_UN_PERF = 11 [backwards_compatible], + SR_BEHAVIOR_API_END_UN = 12 [backwards_compatible], + SR_BEHAVIOR_API_UA = 13 [backwards_compatible], }; enum sr_steer : u8 diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c index 70b5d28e0cc..cd3e4b7700c 100644 --- a/src/vnet/tcp/tcp_input.c +++ b/src/vnet/tcp/tcp_input.c @@ -2551,7 +2551,7 @@ tcp46_listen_inline (vlib_main_t *vm, vlib_node_runtime_t *node, tcp_connection_t *tc; tc = tcp_connection_get (vnet_buffer (b[0])->tcp.connection_index, thread_index); - if (tc->state != TCP_STATE_TIME_WAIT) + if (!tc || tc->state != TCP_STATE_TIME_WAIT) { tcp_inc_counter (listen, TCP_ERROR_CREATE_EXISTS, 1); goto done; diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h index ab9c5da30ec..6211bb51f0a 100644 --- a/src/vppinfra/mem.h +++ b/src/vppinfra/mem.h @@ -302,7 +302,7 @@ void clib_mem_exit (void); typedef struct { /* Address of callers: outer first, inner last. */ - uword callers[12]; + void *callers[12]; /* Count of allocations with this traceback. */ u32 n_allocations; diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c index d5ff21e58c0..7944240390b 100644 --- a/src/vppinfra/mem_dlmalloc.c +++ b/src/vppinfra/mem_dlmalloc.c @@ -53,7 +53,7 @@ mheap_get_trace_internal (const clib_mem_heap_t *heap, uword offset, mheap_trace_t *t; uword i, trace_index, *p; mheap_trace_t trace = {}; - int index; + int n_callers; if (heap != tm->current_traced_mheap || mheap_trace_thread_disable) return; @@ -67,19 +67,10 @@ mheap_get_trace_internal (const clib_mem_heap_t *heap, uword offset, /* Turn off tracing for this thread to avoid embarrassment... */ mheap_trace_thread_disable = 1; - index = -2; /* skip first 2 stack frames */ - foreach_clib_stack_frame (sf) - { - if (index >= 0) - { - if (index == ARRAY_LEN (trace.callers)) - break; - trace.callers[index] = sf->ip; - } - index++; - } - - if (index < 1) + /* Skip our frame and mspace_get_aligned's frame */ + n_callers = + clib_stack_frame_get_raw (trace.callers, ARRAY_LEN (trace.callers), 2); + if (n_callers == 0) goto out; if (!tm->trace_by_callers) diff --git a/src/vppinfra/stack.c b/src/vppinfra/stack.c index 190e880c228..12b24e3189f 100644 --- a/src/vppinfra/stack.c +++ b/src/vppinfra/stack.c @@ -17,7 +17,30 @@ static __thread unw_cursor_t cursor; static __thread unw_context_t context; -#endif +#endif /* HAVE_LIBUNWIND */ + +__clib_export int +clib_stack_frame_get_raw (void **sf, int n, int skip) +{ +#if HAVE_LIBUNWIND == 1 + void *sf__[20]; + int n__; + + /* Also skip current frame. */ + skip++; + n__ = unw_backtrace (sf__, clib_min (ARRAY_LEN (sf__), n + skip)); + + if (n__ <= skip) + return 0; + else if (n__ - skip < n) + n = n__ - skip; + + clib_memcpy_fast (&sf[0], &sf__[skip], n * sizeof (sf[0])); + return n; +#else /* HAVE_LIBUNWIND */ + return 0; +#endif /* HAVE_LIBUNWIND */ +} __clib_export clib_stack_frame_t * clib_stack_frame_get (clib_stack_frame_t *sf) diff --git a/src/vppinfra/stack.h b/src/vppinfra/stack.h index 98a621d4176..5b833a3811e 100644 --- a/src/vppinfra/stack.h +++ b/src/vppinfra/stack.h @@ -17,6 +17,7 @@ typedef struct u8 is_signal_frame; } clib_stack_frame_t; +int clib_stack_frame_get_raw (void **sf, int n, int skip); clib_stack_frame_t *clib_stack_frame_get (clib_stack_frame_t *); #define foreach_clib_stack_frame(sf) \ |