diff options
| author | songyanchao <[email protected]> | 2024-10-24 08:46:35 +0000 |
|---|---|---|
| committer | songyanchao <[email protected]> | 2024-10-24 09:32:53 +0000 |
| commit | 1dc87d94c5c7c7f5b2da94b66b3b12a03f6c5ae9 (patch) | |
| tree | 13bf24d1b39f3d87ff8ed9f4a243918965892847 | |
| parent | faaf7bfc90f476060ea079522095286e39934129 (diff) | |
🎈 perf: Optimize error handling for load balancer node.v4.7.9-20241025
Optimize error handling for load balancer node.
| -rw-r--r-- | service/include/sc_node_common.h | 26 | ||||
| -rw-r--r-- | service/include/sc_pdump.h | 6 | ||||
| -rw-r--r-- | service/src/node_lb.c | 12 |
3 files changed, 39 insertions, 5 deletions
diff --git a/service/include/sc_node_common.h b/service/include/sc_node_common.h index 53432dc..70f7de4 100644 --- a/service/include/sc_node_common.h +++ b/service/include/sc_node_common.h @@ -117,3 +117,29 @@ static inline int mr_is_local_addr(struct mr_dev_desc * dev_desc, struct mr_gene #define MR_IS_IPV6_SOLICITED_NODE_MCAST(x) \ (x[0] == 0xFF && x[1] == 0x02 && x[2] == 0x00 && x[3] == 0x00 && x[4] == 0x00 && x[5] == 0x00 && x[6] == 0x00 && \ x[7] == 0x00 && x[8] == 0x00 && x[9] == 0x00 && x[10] == 0x00 && x[11] == 0x01 && x[12] == 0xFF) + +#define METADATA_INFO \ + "dir:%u, nf_create:%u, is_ctrlbuf:%u, adapter_type:%u, adapter_id:%u, payload_offset:%u, " \ + "user_0:%u, ef_link_id:%u, traffic_link_id:%u, ef_peer_index:%u, port_ingress:%u, port_egress:%u, " \ + "session_id:%lu, cur_sid:%u, sids:%u,%u,%u,%u,%u,%u,%u,%u .\n" + +static inline void mrb_metadata_pktmbuf_dump(const struct rte_mbuf * m) +{ + char str_metadata[1024] = {}; + + struct mrb_metadata * mrb_meta = (struct mrb_metadata *)mrbuf_cz_data(m, MR_NODE_CTRLZONE_ID); + + snprintf(str_metadata, sizeof(str_metadata), METADATA_INFO, mrb_meta->dir, mrb_meta->packet_create_from_nf, + mrb_meta->is_ctrlbuf, mrb_meta->adapter_type, mrb_meta->adapter_id, mrb_meta->payload_offset, + mrb_meta->user_0, mrb_meta->ef_link_id, mrb_meta->traffic_link_id, mrb_meta->ef_peer_index, + mrb_meta->port_ingress, mrb_meta->port_egress, mrb_meta->session_id, mrb_meta->cur_sid, + mrb_meta->sid_list.sids[0], mrb_meta->sid_list.sids[1], mrb_meta->sid_list.sids[2], + mrb_meta->sid_list.sids[3], mrb_meta->sid_list.sids[4], mrb_meta->sid_list.sids[5], + mrb_meta->sid_list.sids[6], mrb_meta->sid_list.sids[7]); + + MR_ERROR("The pkt metadata: %s", str_metadata); + + rte_pktmbuf_dump(stderr, m, rte_pktmbuf_data_len(m)); + + return; +} diff --git a/service/include/sc_pdump.h b/service/include/sc_pdump.h index 6e30175..fa1c945 100644 --- a/service/include/sc_pdump.h +++ b/service/include/sc_pdump.h @@ -1,6 +1,7 @@ #pragma once #include <sc_common.h> +#include <sc_node_common.h> /* Mr pdump */ /* Used for the multi-process communication */ @@ -16,11 +17,6 @@ #define MR_PDUMP_RING_NAME_SIZE 256 #define MR_PDUMP_RING_SIZE 16384 -#define METADATA_INFO \ - " dir:%u, nf_create:%u, link_id:%u, is_ctrlbuf:%u, payload_offset:%u, session_id:%lu, start_sid:%u, nr_sid:%u, " \ - "cur_sid:%u, sids:[%u],[%u],[%u],[%u],[%u],[%u],[%u],[%u], port_id_ingress:%u, port_id_egress:%u, " \ - "ef_peer_index:%u " - enum { MR_PDUMP_SUCCESS = 0, diff --git a/service/src/node_lb.c b/service/src/node_lb.c index a474d39..2c9c5a4 100644 --- a/service/src/node_lb.c +++ b/service/src/node_lb.c @@ -479,6 +479,17 @@ static __rte_always_inline uint16_t lb_node_process(struct rte_graph * graph, st assert(lb_group_index < MR_LB_MAX_GROUP); assert(lb_group_index < lb_main->nr_group); + if (unlikely(lb_group_index >= lb_main->nr_group)) + { + MR_ERROR("The lb group index is invalid: %u, cur_sid: %u, sid_start: %u, nr_group: %u.", lb_group_index, + private_ctrlzone->cur_sid, sid_start, lb_main->nr_group); + + mrb_metadata_pktmbuf_dump(mbuf); + + next_node_index = LB_NEXT_PKT_DROP; + goto node_enqueue; + } + lb_group_item = &lb_main->lb_groups[lb_group_index]; last_sid = private_ctrlzone->cur_sid; } @@ -498,6 +509,7 @@ static __rte_always_inline uint16_t lb_node_process(struct rte_graph * graph, st next_node_index = LB_NEXT_FORWARDER; } + node_enqueue: /* Batch processing */ if (unlikely(batch_next_node_index != next_node_index)) { |
