Commit ce5d0b47f13f83dfb9fbb8ac91adad7120747aaf
Committed by
David S. Miller
1 parent
6ae5f983cf
Exists in
master
and in
7 other branches
[PKTGEN]: srcmac fix
From: Adit Ranadive <adit.262@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 10 additions and 0 deletions Side-by-side Diff
net/core/pktgen.c
... | ... | @@ -111,6 +111,9 @@ |
111 | 111 | * |
112 | 112 | * 802.1Q/Q-in-Q support by Francesco Fondelli (FF) <francesco.fondelli@gmail.com> |
113 | 113 | * |
114 | + * Fixed src_mac command to set source mac of packet to value specified in | |
115 | + * command by Adit Ranadive <adit.262@gmail.com> | |
116 | + * | |
114 | 117 | */ |
115 | 118 | #include <linux/sys.h> |
116 | 119 | #include <linux/types.h> |
117 | 120 | |
... | ... | @@ -1451,8 +1454,11 @@ |
1451 | 1454 | } |
1452 | 1455 | if (!strcmp(name, "src_mac")) { |
1453 | 1456 | char *v = valstr; |
1457 | + unsigned char old_smac[ETH_ALEN]; | |
1454 | 1458 | unsigned char *m = pkt_dev->src_mac; |
1455 | 1459 | |
1460 | + memcpy(old_smac, pkt_dev->src_mac, ETH_ALEN); | |
1461 | + | |
1456 | 1462 | len = strn_len(&user_buffer[i], sizeof(valstr) - 1); |
1457 | 1463 | if (len < 0) { |
1458 | 1464 | return len; |
... | ... | @@ -1480,6 +1486,10 @@ |
1480 | 1486 | *m = 0; |
1481 | 1487 | } |
1482 | 1488 | } |
1489 | + | |
1490 | + /* Set up Src MAC */ | |
1491 | + if (compare_ether_addr(old_smac, pkt_dev->src_mac)) | |
1492 | + memcpy(&(pkt_dev->hh[6]), pkt_dev->src_mac, ETH_ALEN); | |
1483 | 1493 | |
1484 | 1494 | sprintf(pg_result, "OK: srcmac"); |
1485 | 1495 | return count; |