From 950e828f70524039ebda7bdaa4d35a2e602e405e Mon Sep 17 00:00:00 2001 From: yangwei Date: Fri, 17 Nov 2023 21:32:52 +0800 Subject: ✨ feat(MESA_stream_opt): 增加按路由方向获取ROUTE_CTX,marsio模式only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/public/stream_inc/stream_control.h | 2 ++ include/public/stream_inc/stream_rawpkt.h | 4 ++-- src/dealpkt/plug_support.c | 32 +++++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h index 89579f1..13c6262 100644 --- a/include/public/stream_inc/stream_control.h +++ b/include/public/stream_inc/stream_control.h @@ -57,6 +57,8 @@ enum MESA_stream_opt{ MSO_STREAM_INBOND_LINK_ID, MSO_STREAM_OUTBOND_LINK_ID, MSO_STREAM_C2S_ROUTE_DIRECTION, + MSO_STREAM_INBOND_ROUTE_CTX, + MSO_STREAM_OUTBOND_ROUTE_CTX, __MSO_MAX, }; diff --git a/include/public/stream_inc/stream_rawpkt.h b/include/public/stream_inc/stream_rawpkt.h index ce0063d..22b2422 100644 --- a/include/public/stream_inc/stream_rawpkt.h +++ b/include/public/stream_inc/stream_rawpkt.h @@ -27,8 +27,8 @@ enum{ RAW_PKT_GET_ORIGINAL_LOWEST_ETH_SMAC, /* value type is char[6],ʵԭʼsmacַ,mirrorģʽ, ͬRAW_PKT_GET_DATA, ʹstream->pfatherƫ; inline + vxlan + mrtunnatģʽ, ͬRAW_PKT_GET_VXLAN_OUTER_GDEV_MAC; */ RAW_PKT_GET_ORIGINAL_LOWEST_ETH_DMAC, /* value type is char[6],ʵԭʼdmacַ,mirrorģʽ, ͬRAW_PKT_GET_DATA, ʹstream->pfatherƫ; inline + vxlan + mrtunnatģʽ, ͬRAW_PKT_GET_VXLAN_OUTER_LOCAL_MAC; */ - RAW_PKT_GET_ROUTE_CTX, /* max value size char[64] */ - RAW_PKT_GET_SID_LIST, /* value defined in stream_control.h, struct segment_id_list */ + RAW_PKT_GET_ROUTE_CTX, /* get current stream route_dir route_ctx, max value size char[64] */ + RAW_PKT_GET_SID_LIST, /* get current stream route_dir route_ctx, value defined in stream_control.h, struct segment_id_list */ RAW_PKT_GET_IS_CTRL_PKT, }; diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c index 692ecda..592903a 100644 --- a/src/dealpkt/plug_support.c +++ b/src/dealpkt/plug_support.c @@ -1761,9 +1761,9 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o if ((STREAM_TYPE_TCP != pstream->type) || pdetail_pr->flow_stat == NULL || *opt_val_len != sizeof(unsigned int)) { sapp_runtime_log(RLOG_LV_INFO, - "%s,MESA_get_stream_opt() MSO_STREAM_C2S_SYN_NUM error: stream type is not tcp or " - "empyt flow_stat!\n", - printaddr(&pstream->addr, pstream->threadnum)); + "%s,MESA_get_stream_opt() MSO_STREAM_C2S_SYN_NUM error: stream type is not tcp or " + "empyt flow_stat!\n", + printaddr(&pstream->addr, pstream->threadnum)); ret = -1; } else @@ -1869,6 +1869,32 @@ int MESA_get_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o } break; } + case MSO_STREAM_INBOND_ROUTE_CTX: + { + ret = -1; + *opt_val_len = 0; + void **value = (void **)opt_val; + if (pstream_pr->polling_inject_context->meta[DIR_ROUTE_DOWN]) + { + *value = (void *)pstream_pr->polling_inject_context->meta[DIR_ROUTE_DOWN]->data; + *opt_val_len = sizeof(pstream_pr->polling_inject_context->meta[DIR_ROUTE_DOWN]->sz_data); + ret = 0; + } + break; + } + case MSO_STREAM_OUTBOND_ROUTE_CTX: + { + ret = -1; + *opt_val_len = 0; + void **value = (void **)opt_val; + if (pstream_pr->polling_inject_context->meta[DIR_ROUTE_UP]) + { + *value = (void *)pstream_pr->polling_inject_context->meta[DIR_ROUTE_UP]->data; + *opt_val_len = sizeof(pstream_pr->polling_inject_context->meta[DIR_ROUTE_UP]->sz_data); + ret = 0; + } + break; + } default: sapp_runtime_log(RLOG_LV_INFO, "%s,MESA_get_stream_opt() error:unsupport MESA_stream_opt type:%d!\n",printaddr(&pstream->addr, pstream->threadnum), (int)opt); ret = -1; -- cgit v1.2.3