diff options
| author | luwenpeng <[email protected]> | 2024-04-30 15:25:34 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2024-04-30 15:25:34 +0800 |
| commit | e418c84b85360561a6b630735c1d3f9c48611d1d (patch) | |
| tree | 31f14bf214a2efc6fa05e8077661394c9f995529 | |
| parent | 611fda598f7ece3e3b99a606ff4d6f42a6ec9b8b (diff) | |
Add stat of inject packet and drop packet
| -rw-r--r-- | src/packet_io/dumpfile_io.cpp | 4 | ||||
| -rw-r--r-- | src/packet_io/marsio_io.cpp | 3 | ||||
| -rw-r--r-- | src/packet_io/packet_io.h | 4 | ||||
| -rw-r--r-- | src/stellar/stat.cpp | 26 |
4 files changed, 37 insertions, 0 deletions
diff --git a/src/packet_io/dumpfile_io.cpp b/src/packet_io/dumpfile_io.cpp index 7d82909..e1eb3a7 100644 --- a/src/packet_io/dumpfile_io.cpp +++ b/src/packet_io/dumpfile_io.cpp @@ -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); diff --git a/src/packet_io/marsio_io.cpp b/src/packet_io/marsio_io.cpp index 21c5747..3640407 100644 --- a/src/packet_io/marsio_io.cpp +++ b/src/packet_io/marsio_io.cpp @@ -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); diff --git a/src/packet_io/packet_io.h b/src/packet_io/packet_io.h index 4499967..bdd268e 100644 --- a/src/packet_io/packet_io.h +++ b/src/packet_io/packet_io.h @@ -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; diff --git a/src/stellar/stat.cpp b/src/stellar/stat.cpp index 3520deb..684d3f5 100644 --- a/src/stellar/stat.cpp +++ b/src/stellar/stat.cpp @@ -29,6 +29,14 @@ struct stat_id int raw_tx_pkts; int raw_tx_bytes; + // drop packet + int drop_pkts; + int drop_bytes; + + // inject packet + int inject_pkts; + int inject_bytes; + // ctrl packet int ctrl_rx_pkts; int ctrl_rx_bytes; @@ -130,6 +138,12 @@ struct stellar_stat *stellar_stat_new(uint16_t nr_thread) stat->ids.raw_rx_bytes = fieldstat_easy_register_counter(stat->fs, "raw_rx_bytes"); stat->ids.raw_tx_pkts = fieldstat_easy_register_counter(stat->fs, "raw_tx_pkts"); stat->ids.raw_tx_bytes = fieldstat_easy_register_counter(stat->fs, "raw_tx_bytes"); + // drop packet + stat->ids.drop_pkts = fieldstat_easy_register_counter(stat->fs, "drop_pkts"); + stat->ids.drop_bytes = fieldstat_easy_register_counter(stat->fs, "drop_bytes"); + // inject packet + stat->ids.inject_pkts = fieldstat_easy_register_counter(stat->fs, "inject_pkts"); + stat->ids.inject_bytes = fieldstat_easy_register_counter(stat->fs, "inject_bytes"); // ctrl packet stat->ids.ctrl_rx_pkts = fieldstat_easy_register_counter(stat->fs, "ctrl_rx_pkts"); stat->ids.ctrl_rx_bytes = fieldstat_easy_register_counter(stat->fs, "ctrl_rx_bytes"); @@ -213,6 +227,12 @@ void stellar_stat_output(struct stellar_stat *stat) stat->io_stat.raw_tx_pkts += stat->thr_io_stat[i].raw_tx_pkts; stat->io_stat.raw_tx_bytes += stat->thr_io_stat[i].raw_tx_bytes; + stat->io_stat.drop_pkts += stat->thr_io_stat[i].drop_pkts; + stat->io_stat.drop_bytes += stat->thr_io_stat[i].drop_bytes; + + stat->io_stat.inject_pkts += stat->thr_io_stat[i].inject_pkts; + stat->io_stat.inject_bytes += stat->thr_io_stat[i].inject_bytes; + stat->io_stat.ctrl_rx_pkts += stat->thr_io_stat[i].ctrl_rx_pkts; stat->io_stat.ctrl_rx_bytes += stat->thr_io_stat[i].ctrl_rx_bytes; @@ -299,6 +319,12 @@ void stellar_stat_output(struct stellar_stat *stat) fieldstat_easy_counter_set(stat->fs, 0, stat->ids.raw_rx_bytes, NULL, 0, stat->io_stat.raw_rx_bytes); fieldstat_easy_counter_set(stat->fs, 0, stat->ids.raw_tx_pkts, NULL, 0, stat->io_stat.raw_tx_pkts); fieldstat_easy_counter_set(stat->fs, 0, stat->ids.raw_tx_bytes, NULL, 0, stat->io_stat.raw_tx_bytes); + // drop packet + fieldstat_easy_counter_set(stat->fs, 0, stat->ids.drop_pkts, NULL, 0, stat->io_stat.drop_pkts); + fieldstat_easy_counter_set(stat->fs, 0, stat->ids.drop_bytes, NULL, 0, stat->io_stat.drop_bytes); + // inject packet + fieldstat_easy_counter_set(stat->fs, 0, stat->ids.inject_pkts, NULL, 0, stat->io_stat.inject_pkts); + fieldstat_easy_counter_set(stat->fs, 0, stat->ids.inject_bytes, NULL, 0, stat->io_stat.inject_bytes); // ctrl packet fieldstat_easy_counter_set(stat->fs, 0, stat->ids.ctrl_rx_pkts, NULL, 0, stat->io_stat.ctrl_rx_pkts); fieldstat_easy_counter_set(stat->fs, 0, stat->ids.ctrl_rx_bytes, NULL, 0, stat->io_stat.ctrl_rx_bytes); |
