From d6d511ecff241d459a70e270ac98d107faffdd45 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 15 Dec 2016 18:00:04 +0100 Subject: trafgen: proto: Zero out newly allocated struct packet When allocating a new struct packet, the headers and headers_count fields are not zeroed and retain whatever value the allocator returned. Incidentally, this usually seems to have been zero. But on some systems (e.g. Ubuntu 16.04 with a self-compiled 4.9) it is not and we hit the following bug_on: trafgen: trafgen_proto.c:135: proto_header_push: Assertion `!(pkt->headers_count >= 16)' failed. Fix this by properly zeroing the entire struct packet. Fixes: e7dd63060e44 ("trafgen: proto: Update field value at runtime") Signed-off-by: Tobias Klauser --- trafgen_parser.y | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'trafgen_parser.y') diff --git a/trafgen_parser.y b/trafgen_parser.y index 54aafe7..2340fd4 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -117,8 +117,7 @@ static inline void __init_new_packet_slot(struct packet *slot) static inline void __init_new_counter_slot(struct packet_dyn *slot) { - slot->cnt = NULL; - slot->clen = 0; + memset(slot, 0, sizeof(*slot); } static inline void __init_new_randomizer_slot(struct packet_dyn *slot) -- cgit v1.2.3-54-g00ecf