From 09e1acaea2074c5ae5d6d81f53f8c7f50c53593c Mon Sep 17 00:00:00 2001 From: Adit Ranadive Date: Fri, 2 Nov 2007 23:05:27 +0100 Subject: [PATCH] [PKTGEN]: srcmac fix Signed-off-by: Andrew Morton Signed-off-by: David S. Miller Signed-off-by: Adrian Bunk --- net/core/pktgen.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 6e972e489b6d..7bde446a0d4b 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -367,6 +367,9 @@ struct pktgen_thread { * Copyright 1994, University of Cambridge Computer Laboratory * All Rights Reserved. * + * Fixed src_mac command to set source mac of packet to value specified in + * command by Adit Ranadive + * */ static inline s64 divremdi3(s64 x, s64 y, int type) { @@ -1228,8 +1231,11 @@ static ssize_t pktgen_if_write(struct file *file, const char __user *user_buffer } if (!strcmp(name, "src_mac")) { char *v = valstr; + unsigned char old_smac[ETH_ALEN]; unsigned char *m = pkt_dev->src_mac; + memcpy(old_smac, pkt_dev->src_mac, ETH_ALEN); + len = strn_len(&user_buffer[i], sizeof(valstr) - 1); if (len < 0) { return len; } memset(valstr, 0, sizeof(valstr)); @@ -1256,6 +1262,10 @@ static ssize_t pktgen_if_write(struct file *file, const char __user *user_buffer } } + /* Set up Src MAC */ + if (compare_ether_addr(old_smac, pkt_dev->src_mac)) + memcpy(&(pkt_dev->hh[6]), pkt_dev->src_mac, ETH_ALEN); + sprintf(pg_result, "OK: srcmac"); return count; } -- 2.39.5