diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 9661d7b..e240044 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -791,6 +791,7 @@ struct sctp_packet { /* This contains the payload chunks. */ struct list_head chunk_list; + __u32 num_chunks; /* This is the overhead of the sctp and ip headers. */ size_t overhead; diff --git a/net/sctp/output.c b/net/sctp/output.c index c3f417f..7b9a550 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c @@ -114,6 +114,7 @@ struct sctp_packet *sctp_packet_init(struct sctp_packet *packet, packet->source_port = sport; packet->destination_port = dport; INIT_LIST_HEAD(&packet->chunk_list); + packet->num_chunks = 0; if (asoc) { struct sctp_sock *sp = sctp_sk(asoc->base.sk); overhead = sp->pf->af->net_header_len; @@ -349,6 +350,7 @@ append: /* It is OK to send this chunk. */ list_add_tail(&chunk->list, &packet->chunk_list); + packet->num_chunks += 1; packet->size += chunk_len; chunk->transport = packet->transport; finish: @@ -485,6 +487,12 @@ int sctp_packet_transmit(struct sctp_packet *packet) if (chunk == packet->auth) auth = skb_tail_pointer(nskb); + /* DEBUG: Check to see if this chunk will overflow the + * skb. Output needed info + */ + if ((nskb->tail + chunk->skb->len) > nskb->end) { + printk(KERN_ERR "Possible SKB overflow: packet size = %u, packet overhead = %u, packet chunks = %u, mtu = %u\n", packet->size, packet->overhead, packet->num_chunks, asoc?asoc->pathmtu:tp->pathmtu); + } cksum_buf_len += chunk->skb->len; memcpy(skb_put(nskb, chunk->skb->len), chunk->skb->data, chunk->skb->len);