If the receive buffer size is reduced while there are still incoming
packets in flight, it can be that those will not fit inside the receive
buffer. Instead of calling abort(), just handle as much of the packet as
we can fit in the receive buffer, or handle the whole packet if it is in
order since we bypass the receive buffer in that case.
// Packet loss or reordering occured. Store the data in the buffer.
ssize_t rxd = buffer_put_at(&c->rcvbuf, offset, data, len);
// Packet loss or reordering occured. Store the data in the buffer.
ssize_t rxd = buffer_put_at(&c->rcvbuf, offset, data, len);
- if(rxd < 0 || (size_t)rxd < len) {
- abort();
+ if(rxd <= 0) {
+ debug(c, "packet outside receive buffer, dropping\n");
+ return;
+ }
+
+ if((size_t)rxd < len) {
+ debug(c, "packet partially outside receive buffer\n");
+ len = rxd;
}
// Make note of where we put it.
}
// Make note of where we put it.
uint32_t offset = seqdiff(hdr->seq, c->rcv.nxt);
uint32_t offset = seqdiff(hdr->seq, c->rcv.nxt);
- if(offset + len > c->rcvbuf.maxsize) {
- abort();
- }
-
if(offset) {
handle_out_of_order(c, offset, data, len);
} else {
if(offset) {
handle_out_of_order(c, offset, data, len);
} else {