Re: [netsniff-ng] [PATCH 01/15] trafgen: Move applying dynamic elements to function

2016-07-27 Thread Tobias Klauser
On 2016-07-26 at 21:35:06 +0200, Vadim Kochan  wrote:
> Same code for applying dynamic elements is used in both places
> for slow & fast path modes, lets move them into one inlined function.
> 
> Signed-off-by: Vadim Kochan 

Applied, thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[netsniff-ng] [PATCH 01/15] trafgen: Move applying dynamic elements to function

2016-07-26 Thread Vadim Kochan
Same code for applying dynamic elements is used in both places
for slow & fast path modes, lets move them into one inlined function.

Signed-off-by: Vadim Kochan 
---
 trafgen.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/trafgen.c b/trafgen.c
index 002b01a..b76b5d7 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -612,13 +612,21 @@ static void shaper_delay(struct shaper *sh, unsigned long 
pkt_len)
}
 }
 
+static inline void packet_apply_dyn_elements(int idx)
+{
+   if (packet_dyn_has_elems(_dyn[idx])) {
+   apply_counter(idx);
+   apply_randomizer(idx);
+   apply_csum16(idx);
+   }
+}
+
 static void xmit_slowpath_or_die(struct ctx *ctx, unsigned int cpu, unsigned 
long orig_num)
 {
int ret, icmp_sock = -1;
unsigned long num = 1, i = 0;
struct timeval start, end, diff;
unsigned long long tx_bytes = 0, tx_packets = 0;
-   struct packet_dyn *pktd;
struct sockaddr_ll saddr = {
.sll_family = PF_PACKET,
.sll_halen = ETH_ALEN,
@@ -641,12 +649,7 @@ static void xmit_slowpath_or_die(struct ctx *ctx, unsigned 
int cpu, unsigned lon
shaper_init(>sh);
 
while (likely(sigint == 0 && num > 0 && plen > 0)) {
-   pktd = _dyn[i];
-   if (packet_dyn_has_elems(pktd)) {
-   apply_counter(i);
-   apply_randomizer(i);
-   apply_csum16(i);
-   }
+   packet_apply_dyn_elements(i);
 retry:
ret = sendto(sock, packets[i].payload, packets[i].len, 0,
 (struct sockaddr *) , sizeof(saddr));
@@ -713,7 +716,6 @@ static void xmit_fastpath_or_die(struct ctx *ctx, unsigned 
int cpu, unsigned lon
struct ring tx_ring;
struct frame_map *hdr;
struct timeval start, end, diff;
-   struct packet_dyn *pktd;
unsigned long long tx_bytes = 0, tx_packets = 0;
 
set_sock_prio(sock, 512);
@@ -749,12 +751,7 @@ static void xmit_fastpath_or_die(struct ctx *ctx, unsigned 
int cpu, unsigned lon
hdr->tp_h.tp_snaplen = packets[i].len;
hdr->tp_h.tp_len = packets[i].len;
 
-   pktd = _dyn[i];
-   if (packet_dyn_has_elems(pktd)) {
-   apply_counter(i);
-   apply_randomizer(i);
-   apply_csum16(i);
-   }
+   packet_apply_dyn_elements(i);
 
fmemcpy(out, packets[i].payload, packets[i].len);
 
-- 
2.6.3

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netsniff-ng+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.