Skip to content

Commit dd0dce1

Browse files
committed
Fixed a Memory Management bug in the MPL Driver
There was a bug in the MPL driver that could cause the references to the minimum sequenced numbered message to get out of sync, resulting in old messages being accepted inserted into the list in the wrong place. This commit both fixes that issue, and improves the MPL Control message generation to prevent it entering an infinite loop should the list be out of order.
1 parent 97376e7 commit dd0dce1

File tree

1 file changed

+15
-5
lines changed
  • os/net/ipv6/multicast

1 file changed

+15
-5
lines changed

os/net/ipv6/multicast/mpl.c

+15-5
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ buffer_reclaim(void)
509509
* We've already worked out what this new value is.
510510
*/
511511
if(largest != NULL) {
512-
reclaim = list_pop(locssptr->min_seq);
512+
reclaim = list_pop(largest->min_seq);
513513
largest->min_seqno = list_item_next(reclaim) == NULL ? reclaim->seq : ((struct mpl_msg *)list_item_next(reclaim))->seq;
514514
largest->count--;
515515
trickle_timer_stop(&reclaim->tt);
@@ -759,6 +759,7 @@ icmp_out(struct mpl_domain *dom)
759759
uint8_t vector[32];
760760
uint8_t vec_size;
761761
uint8_t vec_len;
762+
uint8_t cur_seq;
762763
uint16_t payload_len;
763764
uip_ds6_addr_t *addr;
764765
size_t seed_info_len;
@@ -824,13 +825,22 @@ icmp_out(struct mpl_domain *dom)
824825
/* Populate the seed info message vector */
825826
memset(vector, 0, sizeof(vector));
826827
vec_len = 0;
827-
locmmptr = list_head(locssptr->min_seq);
828-
while(locmmptr != NULL) {
828+
cur_seq = 0;
829+
LOG_INFO("\nBuffer for seed: ");
830+
LOG_INFO_SEED(locssptr->seed_id);
831+
LOG_INFO_("\n");
832+
for(locmmptr = list_head(locssptr->min_seq); locmmptr != NULL; locmmptr = list_item_next(locmmptr)) {
833+
LOG_INFO("%d -- %x\n", locmmptr->seq, locmmptr->data[locmmptr->size - 1]);
834+
cur_seq = SEQ_VAL_ADD(locssptr->min_seqno, vec_len);
829835
if(locmmptr->seq == SEQ_VAL_ADD(locssptr->min_seqno, vec_len)) {
830836
BIT_VECTOR_SET_BIT(vector, vec_len);
831-
locmmptr = list_item_next(locmmptr);
837+
vec_len++;
838+
} else {
839+
/* Insert enough zeros to get to the next message */
840+
vec_len += locmmptr->seq - cur_seq;
841+
BIT_VECTOR_SET_BIT(vector, vec_len);
842+
vec_len++;
832843
}
833-
vec_len++;
834844
}
835845

836846
/* Convert vector length from bits to bytes */

0 commit comments

Comments
 (0)