implement/remove missing IP counters in stats_mib2 (see task #13731)

This commit is contained in:
goldsimon 2015-09-30 15:05:52 +02:00
parent 9d28549f32
commit 7b5ef3ae58
3 changed files with 18 additions and 15 deletions

View File

@ -618,6 +618,8 @@ ip4_reass(struct pbuf *p)
/* and adjust the number of pbufs currently queued for reassembly. */
ip_reass_pbufcount -= pbuf_clen(p);
MIB2_STATS_INC(mib2.ipreasmoks);
/* Return the pbuf chain */
return p;
}
@ -717,7 +719,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF);
if (rambuf == NULL) {
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc(PBUF_LINK, 0, PBUF_REF) failed\n"));
return ERR_MEM;
goto memerr;
}
rambuf->tot_len = rambuf->len = mtu;
rambuf->payload = LWIP_MEM_ALIGN((void *)buf);
@ -757,7 +759,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
#if LWIP_NETIF_TX_SINGLE_PBUF
rambuf = pbuf_alloc(PBUF_IP, cop, PBUF_RAM);
if (rambuf == NULL) {
return ERR_MEM;
goto memerr;
}
LWIP_ASSERT("this needs a pbuf in one piece!",
(rambuf->len == rambuf->tot_len) && (rambuf->next == NULL));
@ -765,7 +767,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
/* make room for the IP header */
if(pbuf_header(rambuf, IP_HLEN)) {
pbuf_free(rambuf);
return ERR_MEM;
goto memerr;
}
/* fill in the IP header */
SMEMCPY(rambuf->payload, original_iphdr, IP_HLEN);
@ -778,7 +780,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
*/
rambuf = pbuf_alloc(PBUF_LINK, IP_HLEN, PBUF_RAM);
if (rambuf == NULL) {
return ERR_MEM;
goto memerr;
}
LWIP_ASSERT("this needs a pbuf in one piece!",
(p->len >= (IP_HLEN)));
@ -801,14 +803,14 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
pcr = ip_frag_alloc_pbuf_custom_ref();
if (pcr == NULL) {
pbuf_free(rambuf);
return ERR_MEM;
goto memerr;
}
/* Mirror this pbuf, although we might not need all of it. */
newpbuf = pbuf_alloced_custom(PBUF_RAW, newpbuflen, PBUF_REF, &pcr->pc, p->payload, newpbuflen);
if (newpbuf == NULL) {
ip_frag_free_pbuf_custom_ref(pcr);
pbuf_free(rambuf);
return ERR_MEM;
goto memerr;
}
pbuf_ref(p);
pcr->original = p;
@ -842,8 +844,8 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
pbuf_realloc(rambuf, left + IP_HLEN);
}
/* This part is ugly: we alloc a RAM based pbuf for
* the link level header for each chunk and then
/* This part is ugly: we alloc a RAM based pbuf for
* the link level header for each chunk and then
* free it. A PBUF_ROM style pbuf for which pbuf_header
* worked would make things simpler.
*/
@ -857,7 +859,7 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
} else {
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_frag: pbuf_alloc() for header failed\n"));
pbuf_free(rambuf);
return ERR_MEM;
goto memerr;
}
#else /* IP_FRAG_USES_STATIC_BUF */
/* No need for separate header pbuf - we allowed room for it in rambuf
@ -883,6 +885,9 @@ ip4_frag(struct pbuf *p, struct netif *netif, const ip4_addr_t *dest)
#endif /* IP_FRAG_USES_STATIC_BUF */
MIB2_STATS_INC(mib2.ipfragoks);
return ERR_OK;
memerr:
MIB2_STATS_INC(mib2.ipfragfails);
return ERR_MEM;
}
#endif /* IP_FRAG */

View File

@ -2575,11 +2575,10 @@ ip_get_value(struct obj_def *od, u16_t len, void *value)
*uint_ptr = STATS_GET(mib2.ipfragcreates);
}
break;
case 23: /* ipRoutingDiscards */
/** @todo can lwIP discard routes at all?? hardwire this to 0?? */
case 23: /* ipRoutingDiscards: not supported -> always 0 */
{
u32_t *uint_ptr = (u32_t*)value;
*uint_ptr = STATS_GET(mib2.iproutingdiscards);
*uint_ptr = 0;
}
break;
default:

View File

@ -120,12 +120,11 @@ struct stats_mib2 {
u32_t ipoutrequests;
u32_t ipoutdiscards;
u32_t ipoutnoroutes;
u32_t ipreasmoks; /* @todo: never incremented */
u32_t ipreasmoks;
u32_t ipreasmfails;
u32_t ipfragoks;
u32_t ipfragfails; /* @todo: never incremented */
u32_t ipfragfails;
u32_t ipfragcreates;
u32_t iproutingdiscards; /* @todo: never incremented */
u32_t ipreasmreqds;
u32_t ipforwdatagrams;
u32_t ipinreceives;