fixed bug #38210 (ip reassembly while remove oldest datagram)

This commit is contained in:
Greg Renda 2015-02-25 21:43:39 +01:00 committed by sg
parent 83740d81f2
commit 4eb9efdd33
2 changed files with 8 additions and 2 deletions

View File

@ -202,6 +202,9 @@ HISTORY
++ Bugfixes:
2015-02-25: patch by Greg Renda
* ip4_frag.c: fixed bug #38210 (ip reassembly while remove oldest datagram)
2015-02-25: Simon Goldschmidt
* sockets.c: fixed bug #38165 (socket with mulicast): ensure igmp membership
are dropped when socket (not netconn!) is closed.

View File

@ -223,7 +223,7 @@ ip_reass_remove_oldest_datagram(struct ip_hdr *fraghdr, int pbufs_needed)
/* @todo Can't we simply remove the last datagram in the
* linked list behind reassdatagrams?
*/
struct ip_reassdata *r, *oldest, *prev;
struct ip_reassdata *r, *oldest, *prev, *oldest_prev;
int pbufs_freed = 0, pbufs_freed_current;
int other_datagrams;
@ -232,6 +232,7 @@ ip_reass_remove_oldest_datagram(struct ip_hdr *fraghdr, int pbufs_needed)
do {
oldest = NULL;
prev = NULL;
oldest_prev = NULL;
other_datagrams = 0;
r = reassdatagrams;
while (r != NULL) {
@ -240,9 +241,11 @@ ip_reass_remove_oldest_datagram(struct ip_hdr *fraghdr, int pbufs_needed)
other_datagrams++;
if (oldest == NULL) {
oldest = r;
oldest_prev = prev;
} else if (r->timer <= oldest->timer) {
/* older than the previous oldest */
oldest = r;
oldest_prev = prev;
}
}
if (r->next != NULL) {
@ -251,7 +254,7 @@ ip_reass_remove_oldest_datagram(struct ip_hdr *fraghdr, int pbufs_needed)
r = r->next;
}
if (oldest != NULL) {
pbufs_freed_current = ip_reass_free_complete_datagram(oldest, prev);
pbufs_freed_current = ip_reass_free_complete_datagram(oldest, oldest_prev);
pbufs_freed += pbufs_freed_current;
}
} while ((pbufs_freed < pbufs_needed) && (other_datagrams > 1));