summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trafgen.c4
-rw-r--r--trafgen_conf.h5
-rw-r--r--trafgen_parser.y7
3 files changed, 8 insertions, 8 deletions
diff --git a/trafgen.c b/trafgen.c
index 800ba02..16a078c 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -543,7 +543,7 @@ static void xmit_slowpath_or_die(struct ctx *ctx, unsigned int cpu, unsigned lon
while (likely(sigint == 0 && num > 0 && plen > 0)) {
pktd = &packet_dyn[i];
- if (pktd->clen + pktd->rlen + pktd->slen) {
+ if (packet_dyn_has_elems(pktd)) {
apply_counter(i);
apply_randomizer(i);
apply_csum16(i);
@@ -651,7 +651,7 @@ static void xmit_fastpath_or_die(struct ctx *ctx, unsigned int cpu, unsigned lon
hdr->tp_h.tp_len = packets[i].len;
pktd = &packet_dyn[i];
- if (pktd->clen + pktd->rlen + pktd->slen) {
+ if (packet_dyn_has_elems(pktd)) {
apply_counter(i);
apply_randomizer(i);
apply_csum16(i);
diff --git a/trafgen_conf.h b/trafgen_conf.h
index aee385e..d2df1f4 100644
--- a/trafgen_conf.h
+++ b/trafgen_conf.h
@@ -45,6 +45,11 @@ struct packet_dyn {
size_t slen;
};
+static inline bool packet_dyn_has_elems(struct packet_dyn *p)
+{
+ return (p->rlen || p->slen || p->clen);
+}
+
extern void compile_packets(char *file, bool verbose, unsigned int cpu, bool invoke_cpp);
extern void cleanup_packets(void);
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 8eab614..88daf7a 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -66,11 +66,6 @@ static inline int test_ignore(void)
return 1;
}
-static inline int has_dynamic_elems(struct packet_dyn *p)
-{
- return (p->rlen + p->slen + p->clen);
-}
-
static inline void __init_new_packet_slot(struct packet *slot)
{
slot->payload = NULL;
@@ -230,7 +225,7 @@ static void set_csum16(size_t from, size_t to, enum csum which)
bug_on(!(from < to));
- if (has_dynamic_elems(pktd) || to >= pkt->len || is_dynamic_csum(which))
+ if (packet_dyn_has_elems(pktd) || to >= pkt->len || is_dynamic_csum(which))
__set_csum16_dynamic(from, to, which);
else
__set_csum16_static(from, to, which);