Drop packet if there are not enough free buffers to perform fragmentation
This commit is contained in:
parent
8b72ab49c0
commit
68b9412776
|
@ -107,5 +107,18 @@ memb_inmemb(struct memb *m, void *ptr)
|
||||||
(char *)ptr < (char *)m->mem + (m->num * m->size);
|
(char *)ptr < (char *)m->mem + (m->num * m->size);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
int
|
||||||
|
memb_numfree(struct memb *m)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int num_free = 0;
|
||||||
|
|
||||||
|
for(i = 0; i < m->num; ++i) {
|
||||||
|
if(m->count[i] == 0) {
|
||||||
|
++num_free;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return num_free;
|
||||||
|
}
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -130,6 +130,7 @@ char memb_free(struct memb *m, void *ptr);
|
||||||
|
|
||||||
int memb_inmemb(struct memb *m, void *ptr);
|
int memb_inmemb(struct memb *m, void *ptr);
|
||||||
|
|
||||||
|
int memb_numfree(struct memb *m);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -1454,6 +1454,13 @@ output(const uip_lladdr_t *localdest)
|
||||||
* IPv6/HC1/HC06/HC_UDP dispatchs/headers.
|
* IPv6/HC1/HC06/HC_UDP dispatchs/headers.
|
||||||
* The following fragments contain only the fragn dispatch.
|
* The following fragments contain only the fragn dispatch.
|
||||||
*/
|
*/
|
||||||
|
int estimated_fragments = ((int)uip_len) / ((int)MAC_MAX_PAYLOAD - SICSLOWPAN_FRAGN_HDR_LEN) + 1;
|
||||||
|
int freebuf = queuebuf_numfree() - 1;
|
||||||
|
PRINTFO("uip_len: %d, fragments: %d, free bufs: %d\n", uip_len, estimated_fragments, freebuf);
|
||||||
|
if(freebuf < estimated_fragments) {
|
||||||
|
PRINTFO("Dropping packet, not enough free bufs\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
PRINTFO("Fragmentation sending packet len %d\n", uip_len);
|
PRINTFO("Fragmentation sending packet len %d\n", uip_len);
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,16 @@ queuebuf_init(void)
|
||||||
#endif /* QUEUEBUF_STATS */
|
#endif /* QUEUEBUF_STATS */
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
int
|
||||||
|
queuebuf_numfree(void)
|
||||||
|
{
|
||||||
|
if(packetbuf_is_reference()) {
|
||||||
|
return memb_numfree(&refbufmem);
|
||||||
|
} else {
|
||||||
|
return memb_numfree(&bufmem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
#if QUEUEBUF_DEBUG
|
#if QUEUEBUF_DEBUG
|
||||||
struct queuebuf *
|
struct queuebuf *
|
||||||
queuebuf_new_from_packetbuf_debug(const char *file, int line)
|
queuebuf_new_from_packetbuf_debug(const char *file, int line)
|
||||||
|
|
|
@ -108,7 +108,9 @@ packetbuf_attr_t queuebuf_attr(struct queuebuf *b, uint8_t type);
|
||||||
|
|
||||||
void queuebuf_debug_print(void);
|
void queuebuf_debug_print(void);
|
||||||
|
|
||||||
#endif /* QUEUEBUF_H_ */
|
int queuebuf_numfree(void);
|
||||||
|
|
||||||
|
#endif /* __QUEUEBUF_H__ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
Loading…
Reference in a new issue