From d55874b960a8663cc86284fad4d0472ff37b7a7e Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Sat, 29 Jul 2017 12:46:07 +0300 Subject: trafgen: Get packet from proto_hdr if possible Replace using current_packet() by new proto_hdr_packet(hdr) function to obtain packet directly from header. This is more generic and flexible way, because it guarantees that packet really belongs to the header, which in case in current_packet() is not right because it means getting of last allocated packet. Signed-off-by: Vadim Kochan Signed-off-by: Tobias Klauser --- trafgen_l3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'trafgen_l3.c') diff --git a/trafgen_l3.c b/trafgen_l3.c index 7199b89..48790e5 100644 --- a/trafgen_l3.c +++ b/trafgen_l3.c @@ -81,7 +81,7 @@ static void ipv4_csum_update(struct proto_hdr *hdr) static void ipv4_packet_finish(struct proto_hdr *hdr) { - struct packet *pkt = current_packet(); + struct packet *pkt = proto_hdr_packet(hdr); uint16_t total_len; total_len = pkt->len - hdr->pkt_offset; @@ -166,7 +166,7 @@ static void ipv6_field_changed(struct proto_field *field) static void ipv6_packet_finish(struct proto_hdr *hdr) { - struct packet *pkt = current_packet(); + struct packet *pkt = proto_hdr_packet(hdr); uint16_t total_len = pkt->len - hdr->pkt_offset - IPV6_HDR_LEN; proto_hdr_field_set_default_be16(hdr, IP6_LEN, total_len); -- cgit v1.2.3-54-g00ecf