summaryrefslogtreecommitdiff
path: root/trafgen_l3.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2017-01-23 23:49:22 +0200
committerTobias Klauser <tklauser@distanz.ch>2017-01-25 13:23:47 +0100
commit1e1383fea55fb35cec96a352da93c2a31d9e897c (patch)
tree1b93e0cbe4bcbe7893f0cb92073e5318d469d60c /trafgen_l3.c
parent1df0f481922acfb5f7af0f3a5cb800ec0f77e48f (diff)
trafgen: l3: Fix checksum for UDP/TCP protos
While fixing the issue with getting of IPv4 address from device, the setting of default src IPv4/IPv6 addresses was moved from hdr->header_init(...) callback to hdr->packet_finish(...), but packet_finish(...) is called in the following order: udp_hdr->packet_finish() - UDP csum calculation over IPv4/6 pseudo header ip4_hdr->packet_finish() - setting default src IPv4 address from dev ... So src IPv4/6 address will be set after UDP/TCP csum calculation which is wrong, so fixed issue by moving it to the hdr->header_init(...) stage as it was before the c4e07d5142c8. Fixes: c4e07d5142c8 ("trafgen: l3: Support interface without IP address") Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_l3.c')
-rw-r--r--trafgen_l3.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/trafgen_l3.c b/trafgen_l3.c
index 4d67f58..70aefb9 100644
--- a/trafgen_l3.c
+++ b/trafgen_l3.c
@@ -40,6 +40,7 @@ static void ipv4_header_init(struct proto_hdr *hdr)
proto_hdr_field_set_default_u8(hdr, IP4_VER, 4);
proto_hdr_field_set_default_u8(hdr, IP4_IHL, 5);
+ proto_hdr_field_set_default_dev_ipv4(hdr, IP4_SADDR);
}
static void ipv4_field_changed(struct proto_field *field)
@@ -80,7 +81,6 @@ static void ipv4_packet_finish(struct proto_hdr *hdr)
total_len = pkt->len - hdr->pkt_offset;
proto_hdr_field_set_default_be16(hdr, IP4_LEN, total_len);
- proto_hdr_field_set_default_dev_ipv4(hdr, IP4_SADDR);
ipv4_csum_update(hdr);
}
@@ -140,6 +140,7 @@ static void ipv6_header_init(struct proto_hdr *hdr)
proto_header_fields_add(hdr, ipv6_fields, array_size(ipv6_fields));
proto_hdr_field_set_default_be32(hdr, IP6_VER, 6);
+ proto_hdr_field_set_default_dev_ipv6(hdr, IP6_SADDR);
}
static void ipv6_field_changed(struct proto_field *field)
@@ -160,7 +161,6 @@ static void ipv6_packet_finish(struct proto_hdr *hdr)
uint16_t total_len = pkt->len - hdr->pkt_offset - IPV6_HDR_LEN;
proto_hdr_field_set_default_be16(hdr, IP6_LEN, total_len);
- proto_hdr_field_set_default_dev_ipv6(hdr, IP6_SADDR);
}
static void ipv6_set_next_proto(struct proto_hdr *hdr, enum proto_id pid)