summaryrefslogtreecommitdiff
path: root/trafgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'trafgen.c')
-rw-r--r--trafgen.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/trafgen.c b/trafgen.c
index 3b2f471..ce2967d 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -342,11 +342,11 @@ static void apply_csum16(int csum_id)
struct csum16 *csum = &packet_dyn[i].csum[j];
fmemset(&packets[i].payload[csum->off], 0, sizeof(sum));
+ if (unlikely(csum->to >= packets[i].len))
+ csum->to = packets[i].len - 1;
switch (csum->which) {
case CSUM_IP:
- if (csum->to >= packets[i].len)
- csum->to = packets[i].len - 1;
sum = calc_csum(packets[i].payload + csum->from,
csum->to - csum->from + 1, 0);
break;
@@ -362,6 +362,9 @@ static void apply_csum16(int csum_id)
(packets[i].len - csum->to),
IPPROTO_TCP);
break;
+ default:
+ bug();
+ break;
}
fmemcpy(&packets[i].payload[csum->off], &sum, sizeof(sum));