aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/core/pktgen.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 39063122fbb7..3827f881f429 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -139,6 +139,7 @@
139#include <linux/proc_fs.h> 139#include <linux/proc_fs.h>
140#include <linux/seq_file.h> 140#include <linux/seq_file.h>
141#include <linux/wait.h> 141#include <linux/wait.h>
142#include <linux/etherdevice.h>
142#include <net/checksum.h> 143#include <net/checksum.h>
143#include <net/ipv6.h> 144#include <net/ipv6.h>
144#include <net/addrconf.h> 145#include <net/addrconf.h>
@@ -281,8 +282,8 @@ struct pktgen_dev {
281 __u32 src_mac_count; /* How many MACs to iterate through */ 282 __u32 src_mac_count; /* How many MACs to iterate through */
282 __u32 dst_mac_count; /* How many MACs to iterate through */ 283 __u32 dst_mac_count; /* How many MACs to iterate through */
283 284
284 unsigned char dst_mac[6]; 285 unsigned char dst_mac[ETH_ALEN];
285 unsigned char src_mac[6]; 286 unsigned char src_mac[ETH_ALEN];
286 287
287 __u32 cur_dst_mac_offset; 288 __u32 cur_dst_mac_offset;
288 __u32 cur_src_mac_offset; 289 __u32 cur_src_mac_offset;
@@ -594,16 +595,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
594 595
595 seq_puts(seq, " src_mac: "); 596 seq_puts(seq, " src_mac: ");
596 597
597 if ((pkt_dev->src_mac[0] == 0) && 598 if (is_zero_ether_addr(pkt_dev->src_mac))
598 (pkt_dev->src_mac[1] == 0) &&
599 (pkt_dev->src_mac[2] == 0) &&
600 (pkt_dev->src_mac[3] == 0) &&
601 (pkt_dev->src_mac[4] == 0) &&
602 (pkt_dev->src_mac[5] == 0))
603
604 for (i = 0; i < 6; i++) 599 for (i = 0; i < 6; i++)
605 seq_printf(seq, "%02X%s", pkt_dev->odev->dev_addr[i], i == 5 ? " " : ":"); 600 seq_printf(seq, "%02X%s", pkt_dev->odev->dev_addr[i], i == 5 ? " " : ":");
606
607 else 601 else
608 for (i = 0; i < 6; i++) 602 for (i = 0; i < 6; i++)
609 seq_printf(seq, "%02X%s", pkt_dev->src_mac[i], i == 5 ? " " : ":"); 603 seq_printf(seq, "%02X%s", pkt_dev->src_mac[i], i == 5 ? " " : ":");
@@ -1189,9 +1183,9 @@ static ssize_t pktgen_if_write(struct file *file, const char __user *user_buffer
1189 } 1183 }
1190 if (!strcmp(name, "dst_mac")) { 1184 if (!strcmp(name, "dst_mac")) {
1191 char *v = valstr; 1185 char *v = valstr;
1192 unsigned char old_dmac[6]; 1186 unsigned char old_dmac[ETH_ALEN];
1193 unsigned char *m = pkt_dev->dst_mac; 1187 unsigned char *m = pkt_dev->dst_mac;
1194 memcpy(old_dmac, pkt_dev->dst_mac, 6); 1188 memcpy(old_dmac, pkt_dev->dst_mac, ETH_ALEN);
1195 1189
1196 len = strn_len(&user_buffer[i], sizeof(valstr) - 1); 1190 len = strn_len(&user_buffer[i], sizeof(valstr) - 1);
1197 if (len < 0) { return len; } 1191 if (len < 0) { return len; }
@@ -1220,8 +1214,8 @@ static ssize_t pktgen_if_write(struct file *file, const char __user *user_buffer
1220 } 1214 }
1221 1215
1222 /* Set up Dest MAC */ 1216 /* Set up Dest MAC */
1223 if (memcmp(old_dmac, pkt_dev->dst_mac, 6) != 0) 1217 if (compare_ether_addr(old_dmac, pkt_dev->dst_mac))
1224 memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, 6); 1218 memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, ETH_ALEN);
1225 1219
1226 sprintf(pg_result, "OK: dstmac"); 1220 sprintf(pg_result, "OK: dstmac");
1227 return count; 1221 return count;
@@ -1560,17 +1554,11 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
1560 1554
1561 /* Default to the interface's mac if not explicitly set. */ 1555 /* Default to the interface's mac if not explicitly set. */
1562 1556
1563 if ((pkt_dev->src_mac[0] == 0) && 1557 if (is_zero_ether_addr(pkt_dev->src_mac))
1564 (pkt_dev->src_mac[1] == 0) && 1558 memcpy(&(pkt_dev->hh[6]), pkt_dev->odev->dev_addr, ETH_ALEN);
1565 (pkt_dev->src_mac[2] == 0) &&
1566 (pkt_dev->src_mac[3] == 0) &&
1567 (pkt_dev->src_mac[4] == 0) &&
1568 (pkt_dev->src_mac[5] == 0)) {
1569 1559
1570 memcpy(&(pkt_dev->hh[6]), pkt_dev->odev->dev_addr, 6);
1571 }
1572 /* Set up Dest MAC */ 1560 /* Set up Dest MAC */
1573 memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, 6); 1561 memcpy(&(pkt_dev->hh[0]), pkt_dev->dst_mac, ETH_ALEN);
1574 1562
1575 /* Set up pkt size */ 1563 /* Set up pkt size */
1576 pkt_dev->cur_pkt_size = pkt_dev->min_pkt_size; 1564 pkt_dev->cur_pkt_size = pkt_dev->min_pkt_size;