diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2006-01-18 16:20:16 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2006-01-18 16:20:16 -0500 |
commit | b4ea75b649417606fd6b38710a2962ec9770e772 (patch) | |
tree | 217727bea3813e154dee942a3c835933de26acee /net/core | |
parent | 2baeaaa4dab6b43e35c7150d5350bfaff1284153 (diff) | |
parent | 7c4d33675f81fa38f85eeabbbf3e7b8687c15cc3 (diff) |
Merge branch 'upstream-fixes'
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/filter.c | 13 | ||||
-rw-r--r-- | net/core/netpoll.c | 2 | ||||
-rw-r--r-- | net/core/pktgen.c | 34 |
3 files changed, 18 insertions, 31 deletions
diff --git a/net/core/filter.c b/net/core/filter.c index a52665f752..9540946a48 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -74,7 +74,6 @@ static inline void *load_pointer(struct sk_buff *skb, int k, | |||
74 | * filtering, filter is the array of filter instructions, and | 74 | * filtering, filter is the array of filter instructions, and |
75 | * len is the number of filter blocks in the array. | 75 | * len is the number of filter blocks in the array. |
76 | */ | 76 | */ |
77 | |||
78 | unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen) | 77 | unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen) |
79 | { | 78 | { |
80 | struct sock_filter *fentry; /* We walk down these */ | 79 | struct sock_filter *fentry; /* We walk down these */ |
@@ -175,7 +174,7 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int | |||
175 | continue; | 174 | continue; |
176 | case BPF_LD|BPF_W|BPF_ABS: | 175 | case BPF_LD|BPF_W|BPF_ABS: |
177 | k = fentry->k; | 176 | k = fentry->k; |
178 | load_w: | 177 | load_w: |
179 | ptr = load_pointer(skb, k, 4, &tmp); | 178 | ptr = load_pointer(skb, k, 4, &tmp); |
180 | if (ptr != NULL) { | 179 | if (ptr != NULL) { |
181 | A = ntohl(*(u32 *)ptr); | 180 | A = ntohl(*(u32 *)ptr); |
@@ -184,7 +183,7 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int | |||
184 | break; | 183 | break; |
185 | case BPF_LD|BPF_H|BPF_ABS: | 184 | case BPF_LD|BPF_H|BPF_ABS: |
186 | k = fentry->k; | 185 | k = fentry->k; |
187 | load_h: | 186 | load_h: |
188 | ptr = load_pointer(skb, k, 2, &tmp); | 187 | ptr = load_pointer(skb, k, 2, &tmp); |
189 | if (ptr != NULL) { | 188 | if (ptr != NULL) { |
190 | A = ntohs(*(u16 *)ptr); | 189 | A = ntohs(*(u16 *)ptr); |
@@ -374,7 +373,7 @@ int sk_chk_filter(struct sock_filter *filter, int flen) | |||
374 | case BPF_JMP|BPF_JSET|BPF_K: | 373 | case BPF_JMP|BPF_JSET|BPF_K: |
375 | case BPF_JMP|BPF_JSET|BPF_X: | 374 | case BPF_JMP|BPF_JSET|BPF_X: |
376 | /* for conditionals both must be safe */ | 375 | /* for conditionals both must be safe */ |
377 | if (pc + ftest->jt + 1 >= flen || | 376 | if (pc + ftest->jt + 1 >= flen || |
378 | pc + ftest->jf + 1 >= flen) | 377 | pc + ftest->jf + 1 >= flen) |
379 | return -EINVAL; | 378 | return -EINVAL; |
380 | break; | 379 | break; |
@@ -384,7 +383,7 @@ int sk_chk_filter(struct sock_filter *filter, int flen) | |||
384 | } | 383 | } |
385 | } | 384 | } |
386 | 385 | ||
387 | return (BPF_CLASS(filter[flen - 1].code) == BPF_RET) ? 0 : -EINVAL; | 386 | return (BPF_CLASS(filter[flen - 1].code) == BPF_RET) ? 0 : -EINVAL; |
388 | } | 387 | } |
389 | 388 | ||
390 | /** | 389 | /** |
@@ -404,8 +403,8 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk) | |||
404 | int err; | 403 | int err; |
405 | 404 | ||
406 | /* Make sure new filter is there and in the right amounts. */ | 405 | /* Make sure new filter is there and in the right amounts. */ |
407 | if (fprog->filter == NULL) | 406 | if (fprog->filter == NULL) |
408 | return -EINVAL; | 407 | return -EINVAL; |
409 | 408 | ||
410 | fp = sock_kmalloc(sk, fsize+sizeof(*fp), GFP_KERNEL); | 409 | fp = sock_kmalloc(sk, fsize+sizeof(*fp), GFP_KERNEL); |
411 | if (!fp) | 410 | if (!fp) |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 281a632fa6..ea51f8d02e 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -703,7 +703,7 @@ int netpoll_setup(struct netpoll *np) | |||
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
706 | if (!memcmp(np->local_mac, "\0\0\0\0\0\0", 6) && ndev->dev_addr) | 706 | if (is_zero_ether_addr(np->local_mac) && ndev->dev_addr) |
707 | memcpy(np->local_mac, ndev->dev_addr, 6); | 707 | memcpy(np->local_mac, ndev->dev_addr, 6); |
708 | 708 | ||
709 | if (!np->local_ip) { | 709 | if (!np->local_ip) { |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 39063122fb..3827f881f4 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; |