Add stat of inject packet and drop packet
This commit is contained in:
@@ -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)
|
void dumpfile_io_drop(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts)
|
||||||
{
|
{
|
||||||
struct packet *pkt = NULL;
|
struct packet *pkt = NULL;
|
||||||
|
struct io_stat *stat = &handle->stat[thr_idx];
|
||||||
|
|
||||||
for (int i = 0; i < nr_pkts; i++)
|
for (int i = 0; i < nr_pkts; i++)
|
||||||
{
|
{
|
||||||
pkt = &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_io_ctx(pkt);
|
||||||
if (pcap_pkt)
|
if (pcap_pkt)
|
||||||
{
|
{
|
||||||
|
stat->drop_pkts++;
|
||||||
|
stat->drop_bytes += packet_get_len(pkt);
|
||||||
free(pcap_pkt);
|
free(pcap_pkt);
|
||||||
}
|
}
|
||||||
packet_free(pkt);
|
packet_free(pkt);
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *p
|
|||||||
{
|
{
|
||||||
struct packet *pkt;
|
struct packet *pkt;
|
||||||
marsio_buff_t *mbuff;
|
marsio_buff_t *mbuff;
|
||||||
|
struct io_stat *stat = &handle->stat[thr_idx];
|
||||||
|
|
||||||
for (int i = 0; i < nr_pkts; i++)
|
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);
|
mbuff = (marsio_buff_t *)packet_get_io_ctx(pkt);
|
||||||
if (mbuff)
|
if (mbuff)
|
||||||
{
|
{
|
||||||
|
stat->drop_pkts++;
|
||||||
|
stat->drop_bytes += packet_get_len(pkt);
|
||||||
marsio_buff_free(handle->mr_ins, &mbuff, 1, 0, thr_idx);
|
marsio_buff_free(handle->mr_ins, &mbuff, 1, 0, thr_idx);
|
||||||
}
|
}
|
||||||
packet_free(pkt);
|
packet_free(pkt);
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ struct io_stat
|
|||||||
uint64_t raw_tx_pkts;
|
uint64_t raw_tx_pkts;
|
||||||
uint64_t raw_tx_bytes;
|
uint64_t raw_tx_bytes;
|
||||||
|
|
||||||
|
// drop packet
|
||||||
|
uint64_t drop_pkts;
|
||||||
|
uint64_t drop_bytes;
|
||||||
|
|
||||||
// inject packet
|
// inject packet
|
||||||
uint64_t inject_pkts;
|
uint64_t inject_pkts;
|
||||||
uint64_t inject_bytes;
|
uint64_t inject_bytes;
|
||||||
|
|||||||
@@ -29,6 +29,14 @@ struct stat_id
|
|||||||
int raw_tx_pkts;
|
int raw_tx_pkts;
|
||||||
int raw_tx_bytes;
|
int raw_tx_bytes;
|
||||||
|
|
||||||
|
// drop packet
|
||||||
|
int drop_pkts;
|
||||||
|
int drop_bytes;
|
||||||
|
|
||||||
|
// inject packet
|
||||||
|
int inject_pkts;
|
||||||
|
int inject_bytes;
|
||||||
|
|
||||||
// ctrl packet
|
// ctrl packet
|
||||||
int ctrl_rx_pkts;
|
int ctrl_rx_pkts;
|
||||||
int ctrl_rx_bytes;
|
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_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_pkts = fieldstat_easy_register_counter(stat->fs, "raw_tx_pkts");
|
||||||
stat->ids.raw_tx_bytes = fieldstat_easy_register_counter(stat->fs, "raw_tx_bytes");
|
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
|
// ctrl packet
|
||||||
stat->ids.ctrl_rx_pkts = fieldstat_easy_register_counter(stat->fs, "ctrl_rx_pkts");
|
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");
|
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_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.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_pkts += stat->thr_io_stat[i].ctrl_rx_pkts;
|
||||||
stat->io_stat.ctrl_rx_bytes += stat->thr_io_stat[i].ctrl_rx_bytes;
|
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_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_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);
|
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
|
// 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_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);
|
fieldstat_easy_counter_set(stat->fs, 0, stat->ids.ctrl_rx_bytes, NULL, 0, stat->io_stat.ctrl_rx_bytes);
|
||||||
|
|||||||
Reference in New Issue
Block a user