inject TCP RST test pass

This commit is contained in:
luwenpeng
2024-05-08 18:24:26 +08:00
parent 61ee619689
commit 37d12ebcfc
16 changed files with 766 additions and 206 deletions

View File

@@ -290,7 +290,7 @@ int dumpfile_io_ingress(struct dumpfile_io *handle, uint16_t thr_idx, struct pac
pkt = &pkts[nr_parsed];
memset(pkt, 0, sizeof(struct packet));
packet_parse(pkt, pcap_pkt->data, pcap_pkt->len);
packet_set_io_ctx(pkt, pcap_pkt);
packet_set_origin_ctx(pkt, pcap_pkt);
packet_set_origin(pkt, PACKET_ORIGIN_DUMPFILE);
nr_parsed++;
}
@@ -316,7 +316,7 @@ void dumpfile_io_egress(struct dumpfile_io *handle, uint16_t thr_idx, struct pac
stat->raw_tx_pkts++;
stat->raw_tx_bytes += len;
struct pcap_pkt *pcap_pkt = (struct pcap_pkt *)packet_get_io_ctx(pkt);
struct pcap_pkt *pcap_pkt = (struct pcap_pkt *)packet_get_origin_ctx(pkt);
if (pcap_pkt)
{
free(pcap_pkt);
@@ -333,7 +333,7 @@ void dumpfile_io_drop(struct dumpfile_io *handle, uint16_t thr_idx, struct packe
for (int i = 0; i < nr_pkts; i++)
{
pkt = &pkts[i];
struct pcap_pkt *pcap_pkt = (struct pcap_pkt *)packet_get_io_ctx(pkt);
struct pcap_pkt *pcap_pkt = (struct pcap_pkt *)packet_get_origin_ctx(pkt);
if (pcap_pkt)
{
stat->drop_pkts++;

View File

@@ -170,7 +170,7 @@ int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet
pkt = &pkts[nr_parsed];
memset(pkt, 0, sizeof(struct packet));
packet_parse(pkt, data, len);
packet_set_io_ctx(pkt, mbuff);
packet_set_origin_ctx(pkt, mbuff);
packet_set_origin(pkt, PACKET_ORIGIN_MARSIO);
nr_parsed++;
@@ -205,7 +205,7 @@ void marsio_io_egress(struct marsio_io *handle, uint16_t thr_idx, struct packet
stat->dev_tx_pkts++;
stat->dev_tx_bytes += len;
mbuff = (marsio_buff_t *)packet_get_io_ctx(pkt);
mbuff = (marsio_buff_t *)packet_get_origin_ctx(pkt);
assert(mbuff != NULL);
if (marsio_buff_is_ctrlbuf(mbuff))
@@ -233,7 +233,7 @@ void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *p
for (int i = 0; i < nr_pkts; i++)
{
pkt = &pkts[i];
mbuff = (marsio_buff_t *)packet_get_io_ctx(pkt);
mbuff = (marsio_buff_t *)packet_get_origin_ctx(pkt);
if (mbuff)
{
stat->drop_pkts++;
@@ -252,6 +252,7 @@ int marsio_io_inject(struct marsio_io *handle, uint16_t thr_idx, struct packet *
struct packet *pkt;
marsio_buff_t *mbuff;
struct io_stat *stat = &handle->stat[thr_idx];
struct inject_packet_meta *meta;
for (int i = 0; i < nr_pkts; i++)
{
@@ -277,7 +278,31 @@ int marsio_io_inject(struct marsio_io *handle, uint16_t thr_idx, struct packet *
ptr = marsio_buff_append(mbuff, len);
memcpy(ptr, packet_get_data(pkt), len);
marsio_send_burst(handle->mr_path, thr_idx, &mbuff, 1);
meta = (struct inject_packet_meta *)packet_get_origin_ctx(pkt);
if (meta)
{
if (meta->route.used && marsio_buff_set_metadata(mbuff, MR_BUFF_ROUTE_CTX, meta->route.data, meta->route.used) != 0)
{
PACKET_IO_LOG_ERROR("unable to set route context for inject packet");
}
if (meta->sids.used && marsio_buff_set_sid_list(mbuff, meta->sids.sid, meta->sids.used) != 0)
{
PACKET_IO_LOG_ERROR("unable to set sid list for inject packet");
}
if (meta->session_id && marsio_buff_set_metadata(mbuff, MR_BUFF_SESSION_ID, &meta->session_id, sizeof(meta->session_id)) != 0)
{
PACKET_IO_LOG_ERROR("unable to set session id for inject packet");
}
if (meta->link_id)
{
// TODO
}
if (meta->is_ctrl)
{
marsio_buff_set_ctrlbuf(mbuff);
}
}
marsio_send_burst_with_options(handle->mr_path, thr_idx, &mbuff, 1, MARSIO_SEND_OPT_REHASH);
packet_free(pkt);
}

View File

@@ -71,6 +71,15 @@ struct packet_io_options
uint16_t cpu_mask[MAX_THREAD_NUM];
};
struct inject_packet_meta
{
struct route_ctx route;
struct sid_list sids;
uint64_t session_id;
uint16_t link_id;
int is_ctrl;
};
struct packet_io;
struct packet_io *packet_io_new(struct packet_io_options *opts);
void packet_io_free(struct packet_io *packet_io);