Add stat of inject packet and drop packet

This commit is contained in:
luwenpeng
2024-04-30 15:25:34 +08:00
parent 611fda598f
commit e418c84b85
4 changed files with 37 additions and 0 deletions

View File

@@ -262,12 +262,16 @@ void dumpfile_io_egress(struct dumpfile_io *handle, uint16_t thr_idx, struct pac
void dumpfile_io_drop(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts)
{
struct packet *pkt = NULL;
struct io_stat *stat = &handle->stat[thr_idx];
for (int i = 0; i < nr_pkts; i++)
{
pkt = &pkts[i];
struct pcap_pkt *pcap_pkt = (struct pcap_pkt *)packet_get_io_ctx(pkt);
if (pcap_pkt)
{
stat->drop_pkts++;
stat->drop_bytes += packet_get_len(pkt);
free(pcap_pkt);
}
packet_free(pkt);

View File

@@ -228,6 +228,7 @@ void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *p
{
struct packet *pkt;
marsio_buff_t *mbuff;
struct io_stat *stat = &handle->stat[thr_idx];
for (int i = 0; i < nr_pkts; i++)
{
@@ -235,6 +236,8 @@ void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *p
mbuff = (marsio_buff_t *)packet_get_io_ctx(pkt);
if (mbuff)
{
stat->drop_pkts++;
stat->drop_bytes += packet_get_len(pkt);
marsio_buff_free(handle->mr_ins, &mbuff, 1, 0, thr_idx);
}
packet_free(pkt);

View File

@@ -34,6 +34,10 @@ struct io_stat
uint64_t raw_tx_pkts;
uint64_t raw_tx_bytes;
// drop packet
uint64_t drop_pkts;
uint64_t drop_bytes;
// inject packet
uint64_t inject_pkts;
uint64_t inject_bytes;