TSG-20717 Service Chaining增加全局链路号以支持无历史状态发包

This commit is contained in:
luwenpeng
2024-04-20 11:40:00 +08:00
parent 6b03470739
commit a0f1eca0ce
25 changed files with 314 additions and 109 deletions

View File

@@ -117,6 +117,12 @@ int mbuff_get_metadata(marsio_buff_t *rx_buff, struct metadata *meta)
return -1;
}
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_LINK_ID, &(meta->link_id), sizeof(meta->link_id)) <= 0)
{
LOG_ERROR("%s: unable to get link_id from metadata", LOG_TAG_PKTIO);
return -1;
}
// 1: E2I
// 0: I2E
if (marsio_buff_get_metadata(rx_buff, MR_BUFF_DIR, &(meta->direction), sizeof(meta->direction)) <= 0)
@@ -181,7 +187,27 @@ int mbuff_set_metadata(marsio_buff_t *tx_buff, struct metadata *meta)
}
}
// need't set MR_BUFF_DIR, set MR_BUFF_ROUTE_CTX instead
if (meta->link_id)
{
if (marsio_buff_set_metadata(tx_buff, MR_BUFF_LINK_ID, &(meta->link_id), sizeof(meta->link_id)) != 0)
{
LOG_ERROR("%s: unable to set link_id from metadata", LOG_TAG_PKTIO);
return -1;
}
}
/*
* for stateless inject packet, set direction is necessary;
* if later set route_ctx, dir will be overwrite by route_ctx.
*
* direction : 1 (E2I)
* direction : 0 (I2E)
*/
if (marsio_buff_set_metadata(tx_buff, MR_BUFF_DIR, &(meta->direction), sizeof(meta->direction)) != 0)
{
LOG_ERROR("%s: unable to set buff_dir from metadata", LOG_TAG_PKTIO);
return -1;
}
if (meta->is_ctrl_pkt)
{
@@ -526,7 +552,7 @@ static inline int send_packet_to_sf(struct session_ctx *session_ctx, marsio_buff
packet_io->config.dev_endpoint_l3_mac, sf->sf_dst_mac,
packet_io->config.dev_endpoint_l3_ip, sf->sf_dst_ip, thread_ctx->tx_packets_ipid % 65535,
session_ctx->vxlan_src_port, meta->raw_len,
meta->direction, meta->is_decrypted, sf->sf_index);
meta->direction, meta->is_decrypted, sf->sf_index, meta->link_id);
nsend = marsio_buff_datalen(mbuff);
marsio_buff_set_metadata(mbuff, MR_BUFF_REHASH_INDEX, &rehash_index, sizeof(rehash_index));
PACKET_TRACE_ON_NEW(packet_io->instance, mbuff);
@@ -1215,6 +1241,7 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx
struct thread_metrics *thread_metrics = &thread_ctx->thread_metrics;
struct packet_io *packet_io = thread_ctx->ref_io;
int thread_index = thread_ctx->thread_index;
struct sce_ctx *sce_ctx = thread_ctx->ref_sce_ctx;
struct metadata meta;
struct vxlan_hdr *vxlan_hdr = NULL;
@@ -1237,9 +1264,19 @@ static void handle_inject_vxlan_packet(marsio_buff_t *rx_buff, struct thread_ctx
meta.raw_len = raw_len - VXLAN_FRAME_HDR_LEN;
meta.l7offset = 0;
meta.is_ctrl_pkt = 0;
sf_index = vxlan_get_opt(vxlan_hdr, VNI_OPT_SFINDEX);
meta.direction = vxlan_get_opt(vxlan_hdr, VNI_OPT_DIR);
meta.is_decrypted = vxlan_get_opt(vxlan_hdr, VNI_OPT_TRAFFIC);
sf_index = vxlan_get_sf_index(vxlan_hdr);
meta.direction = vxlan_get_dir(vxlan_hdr);
meta.is_decrypted = vxlan_get_traffic(vxlan_hdr);
meta.link_id = vxlan_get_link_id(vxlan_hdr);
if (vxlan_get_stateless(vxlan_hdr))
{
meta.sids.num = 1;
meta.sids.elems[0] = sce_ctx->stateless_sids;
THROUGHPUT_METRICS_INC(&(thread_metrics->stateless_inject), 1, meta.raw_len);
marsio_buff_adj(rx_buff, raw_len - meta.raw_len);
action_nf_inject(rx_buff, &meta, NULL, thread_ctx);
return;
}
session_ctx = inject_packet_search_session(session_table, meta.raw_data, meta.raw_len, thread_ctx);
if (session_ctx == NULL)