diff --git a/gtests/net/packetdrill/parser.y b/gtests/net/packetdrill/parser.y
index bae3af88fe6a50547ca96344444fd613754a23df..a8aa42363c5ab2ca6a32c6a55ecf3b73a1d177e7 100644
--- a/gtests/net/packetdrill/parser.y
+++ b/gtests/net/packetdrill/parser.y
@@ -1254,12 +1254,19 @@ sctp_error_chunk_spec
 }
 
 sctp_cookie_echo_chunk_spec
-: COOKIE_ECHO '[' opt_flags ',' opt_len ',' VAL '=' ELLIPSIS ']' {
+: COOKIE_ECHO '[' opt_flags ',' opt_len ',' opt_val ']' {
 	if (($5 != -1) &&
 	    (!is_valid_u16($5) || ($5 < sizeof(struct sctp_cookie_echo_chunk)))) {
 		semantic_error("length value out of range");
 	}
-	$$ = sctp_cookie_echo_chunk_new($3, $5, NULL);
+        if (($5 != -1) && ($7 != NULL) &&
+	    ($5 != sizeof(struct sctp_cookie_echo_chunk) + $7->nr_entries)) {
+		semantic_error("length value incompatible with val");
+	}
+	if (($5 == -1) && ($7 != NULL)) {
+		semantic_error("length needs to be specified");
+	}
+	$$ = sctp_cookie_echo_chunk_new($3, $5, $7);
 }
 
 sctp_cookie_ack_chunk_spec
diff --git a/gtests/net/packetdrill/run_packet.c b/gtests/net/packetdrill/run_packet.c
index f1b1c07059e215907c161cafa4807f63ac1caee5..1767528d18aa2c9865993c3859156af665264392 100644
--- a/gtests/net/packetdrill/run_packet.c
+++ b/gtests/net/packetdrill/run_packet.c
@@ -2409,6 +2409,13 @@ static int do_inbound_script_packet(
 				}
 				break;
 			case SCTP_COOKIE_ECHO_CHUNK_TYPE:
+				if (!(item->flags & FLAG_CHUNK_VALUE_NOCHECK)) break;	// if the cookie was explicitly 
+											// added to the test script, we dont
+											// need to copy the saved cookie
+											// from the init_ack chunk ...
+											// TODO: can this be done in a more readable way?
+											
+				
 				if (socket->state == SOCKET_PASSIVE_INIT_ACK_SENT) {
 					temp_offset = socket->prepared_cookie_echo_length - item->length;
 					assert(packet->ip_bytes + temp_offset <= packet->buffer_bytes);
diff --git a/gtests/net/packetdrill/sctp_packet.c b/gtests/net/packetdrill/sctp_packet.c
index 08df4f48bfd2b64550a24bd58341dd65c6f9f8f7..7f87a869824db991d72511691aa46135516f0708 100644
--- a/gtests/net/packetdrill/sctp_packet.c
+++ b/gtests/net/packetdrill/sctp_packet.c
@@ -939,12 +939,13 @@ sctp_error_chunk_new(s64 flgs, struct sctp_cause_list *list)
 }
 
 struct sctp_chunk_list_item *
-sctp_cookie_echo_chunk_new(s64 flgs, s64 len, u8* cookie)
+sctp_cookie_echo_chunk_new(s64 flgs, s64 len, struct sctp_byte_list *cookie)
 {
 	struct sctp_cookie_echo_chunk *chunk;
+	struct sctp_byte_list_item *item;
 	u32 flags;
-	u16 chunk_length, cookie_length, padding_length;
-
+	u16 chunk_length, cookie_length, padding_length, i;
+	
 	assert((len == -1) ||
 	       (is_valid_u16(len) &&
 	        len >= sizeof(struct sctp_cookie_echo_chunk)));
@@ -973,7 +974,12 @@ sctp_cookie_echo_chunk_new(s64 flgs, s64 len, u8* cookie)
 	}
 	chunk->length = htons(chunk_length);
 	if (cookie != NULL) {
-		memcpy(chunk->cookie, cookie, cookie_length);
+		for (i = 0, item = cookie->first;
+		     item != NULL;
+		     i++, item = item->next) {
+			chunk->cookie[i] = item->byte;
+		}
+		//memcpy(chunk->cookie, cookie, cookie_length);
 	} else {
 		flags |= FLAG_CHUNK_VALUE_NOCHECK;
 		memset(chunk->cookie, 'A', cookie_length);
diff --git a/gtests/net/packetdrill/sctp_packet.h b/gtests/net/packetdrill/sctp_packet.h
index 7e2b170a58f4bd4925eac539b5868a8f8e2c0594..ad974346203a7f703df99db63812e90f41f2bcbb 100644
--- a/gtests/net/packetdrill/sctp_packet.h
+++ b/gtests/net/packetdrill/sctp_packet.h
@@ -257,7 +257,7 @@ struct sctp_chunk_list_item *
 sctp_error_chunk_new(s64 flgs, struct sctp_cause_list *causes);
 
 struct sctp_chunk_list_item *
-sctp_cookie_echo_chunk_new(s64 flgs, s64 len, u8* cookie);
+sctp_cookie_echo_chunk_new(s64 flgs, s64 len, struct sctp_byte_list *cookie);
 
 struct sctp_chunk_list_item *
 sctp_cookie_ack_chunk_new(s64 flgs);