Projects
Eulaceura:Factory
lwip
_service:obs_scm:0126-add-stats_proto-in-out-to...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0126-add-stats_proto-in-out-to-xmit-recv.patch of Package lwip
From 050f6e547e31a6dd26837a4660ce8c53db71e272 Mon Sep 17 00:00:00 2001 From: root <root@localhost.localdomain> Date: Thu, 25 Apr 2024 10:57:46 +0800 Subject: [PATCH] add stats_proto in/out to xmit/recv --- src/core/ipv4/etharp.c | 25 ++++++++++++++++++++----- src/core/ipv4/icmp.c | 22 +++++++++++++++++++++- src/core/ipv4/ip4.c | 28 ++++++++++++++++++++++------ src/core/tcp_in.c | 8 +++++++- src/core/tcp_out.c | 16 +++++++++++++--- src/core/udp.c | 21 ++++++++++++++++----- src/include/lwip/stats.h | 6 ++++++ 7 files changed, 105 insertions(+), 21 deletions(-) diff --git a/src/core/ipv4/etharp.c b/src/core/ipv4/etharp.c index 6a9117a..ffaa442 100644 --- a/src/core/ipv4/etharp.c +++ b/src/core/ipv4/etharp.c @@ -654,7 +654,9 @@ etharp_input(struct pbuf *p, struct netif *netif) u8_t for_us, from_us; LWIP_ASSERT_CORE_LOCKED(); - +#if GAZELLE_ENABLE + ETHARP_STATS_INC(etharp.rx_in); +#endif LWIP_ERROR("netif != NULL", (netif != NULL), return;); hdr = (struct etharp_hdr *)p->payload; @@ -672,7 +674,9 @@ etharp_input(struct pbuf *p, struct netif *netif) pbuf_free(p); return; } +#if !GAZELLE_ENABLE ETHARP_STATS_INC(etharp.recv); +#endif #if LWIP_ACD /* We have to check if a host already has configured our ip address and @@ -746,6 +750,9 @@ etharp_input(struct pbuf *p, struct netif *netif) break; } /* free ARP packet */ +#if GAZELLE_ENABLE + ETHARP_STATS_INC(etharp.rx_out); +#endif pbuf_free(p); } @@ -801,7 +808,10 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr) const struct eth_addr *dest; struct eth_addr mcastaddr; const ip4_addr_t *dst_addr = ipaddr; - + +#if GAZELLE_ENABLE + ETHARP_STATS_INC(etharp.tx_in); +#endif LWIP_ASSERT_CORE_LOCKED(); LWIP_ASSERT("netif != NULL", netif != NULL); LWIP_ASSERT("q != NULL", q != NULL); @@ -901,6 +911,9 @@ etharp_output(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr) /* continuation for multicast/broadcast destinations */ /* obtain source Ethernet address of the given interface */ /* send packet directly on the link */ +#if GAZELLE_ENABLE + ETHARP_STATS_INC(etharp.tx_out); +#endif return ethernet_output(netif, q, (struct eth_addr *)(netif->hwaddr), dest, ETHTYPE_IP); } @@ -1179,13 +1192,15 @@ etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, { ethernet_output(netif, p, ethsrc_addr, ethdst_addr, ETHTYPE_ARP); } - - ETHARP_STATS_INC(etharp.xmit); +#if GAZELLE_ENABLE + ETHARP_STATS_INC(etharp.tx_out); +#else + ETHARP_STATS_INC(etharp.xmit); +#endif /* free ARP query packet */ pbuf_free(p); p = NULL; /* could not allocate pbuf for ARP request */ - return result; } diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c index a3de92d..ff1ecca 100644 --- a/src/core/ipv4/icmp.c +++ b/src/core/ipv4/icmp.c @@ -92,7 +92,11 @@ icmp_input(struct pbuf *p, struct netif *inp) u16_t hlen; const ip4_addr_t *src; +#if GAZELLE_ENABLE + ICMP_STATS_INC(icmp.rx_in); +#else ICMP_STATS_INC(icmp.recv); +#endif MIB2_STATS_INC(mib2.icmpinmsgs); iphdr_in = ip4_current_header(); @@ -120,6 +124,9 @@ icmp_input(struct pbuf *p, struct netif *inp) break; case ICMP_ECHO: MIB2_STATS_INC(mib2.icmpinechos); +#if GAZELLE_ENABLE + ICMP_STATS_INC(icmp.tx_in); +#endif src = ip4_current_dest_addr(); /* multicast destination address? */ if (ip4_addr_ismulticast(ip4_current_dest_addr())) { @@ -252,8 +259,11 @@ icmp_input(struct pbuf *p, struct netif *inp) #endif } #endif /* CHECKSUM_GEN_IP */ - +#if GAZELLE_ENABLE + ICMP_STATS_INC(icmp.tx_out); +#else ICMP_STATS_INC(icmp.xmit); +#endif /* increase number of messages attempted to send */ MIB2_STATS_INC(mib2.icmpoutmsgs); /* increase number of echo replies attempted to send */ @@ -292,6 +302,9 @@ icmp_input(struct pbuf *p, struct netif *inp) ICMP_STATS_INC(icmp.proterr); ICMP_STATS_INC(icmp.drop); } +#if GAZELLE_ENABLE + ICMP_STATS_INC(icmp.rx_out); +#endif pbuf_free(p); return; lenerr: @@ -361,6 +374,9 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code) /* increase number of messages attempted to send */ MIB2_STATS_INC(mib2.icmpoutmsgs); +#if GAZELLE_ENABLE + ICMP_STATS_INC(icmp.tx_in); +#endif /* Keep IP header + up to 8 bytes */ response_pkt_len = IP_HLEN + ICMP_DEST_UNREACH_DATASIZE; @@ -411,7 +427,11 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code) icmphdr->chksum = inet_chksum(icmphdr, q->len); } #endif +#if GAZELLE_ENABLE + ICMP_STATS_INC(icmp.tx_out); +#else ICMP_STATS_INC(icmp.xmit); +#endif ip4_output_if(q, NULL, &iphdr_src, ICMP_TTL, 0, IP_PROTO_ICMP, netif); } pbuf_free(q); diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index 907a2f0..8865766 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -382,7 +382,9 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) IP_STATS_INC(ip.fw); MIB2_STATS_INC(mib2.ipforwdatagrams); +#if !GAZELLE_ENABLE IP_STATS_INC(ip.xmit); +#endif #ifndef LWIP_PERF PERF_STOP("ip4_forward"); @@ -406,6 +408,9 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp) /* transmit pbuf on chosen interface */ netif->output(netif, p, ip4_current_dest_addr()); return; +#if GAZELLE_ENABLE + IP_STATS_INC(ip.tx_out); +#endif return_noroute: MIB2_STATS_INC(mib2.ipoutnoroutes); } @@ -481,8 +486,12 @@ ip4_input(struct pbuf *p, struct netif *inp) LWIP_ASSERT_CORE_LOCKED(); PERF_START(PERF_LAYER_IP, PERF_POINT_IP_RECV); - - IP_STATS_INC(ip.recv); + +#if GAZELLE_ENABLE + IP_STATS_INC(ip.rx_in); +#else + IP_STATS_INC(ip.recv); +#endif MIB2_STATS_INC(mib2.ipinreceives); /* identify the IP header */ @@ -815,7 +824,9 @@ ip4_input(struct pbuf *p, struct netif *inp) ip4_addr_set_any(ip4_current_dest_addr()); PERF_STOP_INCREASE_COUNT("ip4_input", PERF_LAYER_IP); - +#if GAZELLE_ENABLE + IP_STATS_INC(ip.rx_out); +#endif return ERR_OK; } @@ -908,7 +919,9 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d #if CHECKSUM_GEN_IP_INLINE u32_t chk_sum = 0; #endif /* CHECKSUM_GEN_IP_INLINE */ - +#if GAZELLE_ENABLE + IP_STATS_INC(ip.tx_in); +#endif LWIP_ASSERT_CORE_LOCKED(); LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); @@ -1045,7 +1058,9 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d dest = &dest_addr; } +#if !GAZELLE_ENABLE IP_STATS_INC(ip.xmit); +#endif LWIP_DEBUGF(IP_DEBUG, ("ip4_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], (u16_t)netif->num)); ip4_debug_print(p); @@ -1078,7 +1093,9 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d } #endif #endif /* IP_FRAG */ - +#if GAZELLE_ENABLE + IP_STATS_INC(ip.tx_out); +#endif LWIP_DEBUGF(IP_DEBUG, ("ip4_output_if: call netif->output()\n")); return netif->output(netif, p, dest); } @@ -1107,7 +1124,6 @@ ip4_output(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest, struct netif *netif; LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p); - if ((netif = ip4_route_src(src, dest)) == NULL) { LWIP_DEBUGF(IP_DEBUG, ("ip4_output: No route to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", ip4_addr1_16(dest), ip4_addr2_16(dest), ip4_addr3_16(dest), ip4_addr4_16(dest))); diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c index 2922721..6c960a6 100644 --- a/src/core/tcp_in.c +++ b/src/core/tcp_in.c @@ -179,8 +179,11 @@ tcp_input(struct pbuf *p, struct netif *inp) #ifndef LWIP_PERF PERF_START; #endif - +#if GAZELLE_ENABLE + TCP_STATS_INC(tcp.rx_in); +#else TCP_STATS_INC(tcp.recv); +#endif MIB2_STATS_INC(mib2.tcpinsegs); tcphdr = (struct tcp_hdr *)p->payload; @@ -675,6 +678,9 @@ tcp_input(struct pbuf *p, struct netif *inp) #endif /* TCP_INPUT_DEBUG */ } } +#if GAZELLE_ENABLE + TCP_STATS_INC(tcp.rx_out); +#endif /* Jump target if pcb has been aborted in a callback (by calling tcp_abort()). Below this line, 'pcb' may not be dereferenced! */ aborted: diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c index 1632a66..8a9016b 100644 --- a/src/core/tcp_out.c +++ b/src/core/tcp_out.c @@ -1467,7 +1467,9 @@ tcp_output(struct tcp_pcb *pcb) #endif /* TCP_CWND_DEBUG */ LWIP_ASSERT_CORE_LOCKED(); - +#if GAZELLE_ENABLE + TCP_STATS_INC(tcp.tx_in); +#endif LWIP_ASSERT("tcp_output: invalid pcb", pcb != NULL); /* pcb->state LISTEN not allowed here */ LWIP_ASSERT("don't call tcp_output for listen-pcbs", @@ -2019,8 +2021,9 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif #endif /* CHECKSUM_GEN_TCP_HW */ } #endif /* CHECKSUM_GEN_TCP */ +#if !GAZELLE_ENABLE TCP_STATS_INC(tcp.xmit); - +#endif PERF_PAUSE_RETURN_POINT(PERF_LAYER_TCP, tmpPoint); PERF_START(PERF_LAYER_IP, PERF_POINT_IP_SEND); @@ -2039,7 +2042,9 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif seg->chksum_swapped = 1; } #endif - +#if GAZELLE_ENABLE + TCP_STATS_INC(tcp.tx_out); +#endif PERF_STOP_INCREASE_COUNT("ip_out", PERF_LAYER_IP); PERF_RESUME(PERF_LAYER_TCP, tmpPoint); @@ -2430,7 +2435,12 @@ tcp_output_control_segment_netif(const struct tcp_pcb *pcb, struct pbuf *p, ttl = TCP_TTL; tos = 0; } +#if GAZELLE_ENABLE + TCP_STATS_INC(tcp.tx_out); +#else TCP_STATS_INC(tcp.xmit); +#endif + err = ip_output_if(p, src, dst, ttl, tos, IP_PROTO_TCP, netif); NETIF_RESET_HINTS(netif); diff --git a/src/core/udp.c b/src/core/udp.c index 4a47e99..2c946c7 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -263,7 +263,9 @@ udp_input(struct pbuf *p, struct netif *inp) LWIP_UNUSED_ARG(inp); LWIP_ASSERT_CORE_LOCKED(); - +#if GAZELLE_ENABLE + UDP_STATS_INC(udp.rx_in); +#endif LWIP_ASSERT("udp_input: invalid pbuf", p != NULL); LWIP_ASSERT("udp_input: invalid netif", inp != NULL); @@ -273,7 +275,9 @@ udp_input(struct pbuf *p, struct netif *inp) //PERF_START; #endif +#if !GAZELLE_ENABLE UDP_STATS_INC(udp.recv); +#endif /* Check minimum length (UDP header) */ if (p->len < UDP_HLEN) { @@ -518,6 +522,9 @@ udp_input(struct pbuf *p, struct netif *inp) } else { pbuf_free(p); } +#if GAZELLE_ENABLE + UDP_STATS_INC(udp.rx_out); +#endif end: #if LWIP_RECORD_PERF PERF_STOP_INCREASE_COUNT("udp_input", PERF_LAYER_UDP); @@ -589,7 +596,6 @@ udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, { LWIP_ERROR("udp_send_chksum: invalid pcb", pcb != NULL, return ERR_ARG); LWIP_ERROR("udp_send_chksum: invalid pbuf", p != NULL, return ERR_ARG); - if (IP_IS_ANY_TYPE_VAL(pcb->remote_ip)) { return ERR_VAL; } @@ -839,9 +845,11 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d struct pbuf *q; /* q will be sent down the stack */ u8_t ip_proto; u8_t ttl; - + LWIP_ASSERT_CORE_LOCKED(); - +#if GAZELLE_ENABLE + UDP_STATS_INC(udp.tx_in); +#endif LWIP_ERROR("udp_sendto_if_src: invalid pcb", pcb != NULL, return ERR_ARG); LWIP_ERROR("udp_sendto_if_src: invalid pbuf", p != NULL, return ERR_ARG); LWIP_ERROR("udp_sendto_if_src: invalid dst_ip", dst_ip != NULL, return ERR_ARG); @@ -1057,8 +1065,11 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d q = NULL; /* p is still referenced by the caller, and will live on */ } - +#if GAZELLE_ENABLE + UDP_STATS_INC(udp.tx_out); +#else UDP_STATS_INC(udp.xmit); +#endif return err; } diff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h index 08c34e9..f99f6e5 100644 --- a/src/include/lwip/stats.h +++ b/src/include/lwip/stats.h @@ -64,6 +64,12 @@ extern "C" { struct stats_proto { STAT_COUNTER xmit; /* Transmitted packets. */ STAT_COUNTER recv; /* Received packets. */ +#if GAZELLE_ENABLE + STAT_COUNTER tx_in; /* Transmitted packets. */ + STAT_COUNTER tx_out; /* Transmitted out packets. */ + STAT_COUNTER rx_in; /* Received in packets. */ + STAT_COUNTER rx_out; /* Received out packets. */ +#endif STAT_COUNTER fw; /* Forwarded packets. */ STAT_COUNTER drop; /* Dropped packets. */ STAT_COUNTER chkerr; /* Checksum error. */ -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2