diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-08 03:35:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:20 -0400 |
commit | 7d98230a73c21b4d0cee9c3aca38190d215e0e39 (patch) | |
tree | c2a5b5ff2e7927c3519ed49c3cb907ee29a5a90a /arch/um/drivers/pcap_user.c | |
parent | a436ed9c5106b41606cbb55ab3b28389fe8ae04f (diff) |
uml: network and pcap cleanup
Some network device cleanup.
When setup_etheraddr found a globally valid MAC being assigned to an
interface, it went ahead and used it rather than assigning a random MAC like
the other cases do. This isn't really an error like the others, but it seems
consistent to make it behave the same.
We were getting some duplicate kfree() in the error case in eth_configure
because platform_device_unregister frees buffers that the error cases
following tried to free again.
The pcap initialization routine wasn't doing the proper printk of its
information, causing a printk of the first part of that line to be
unterminated by a newline.
The pcap code had a bunch of style violations, which are now fixed.
pcap_setup wasn't returning false when it detected an unrecognized
option.
The printks in pcap_user all got UM_KERN_BLAH prepended to their
format strings.
pcap_remove now checks for a non-NULL pcap structure before it calls
pcap_close.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Acked-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/drivers/pcap_user.c')
-rw-r--r-- | arch/um/drivers/pcap_user.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/arch/um/drivers/pcap_user.c b/arch/um/drivers/pcap_user.c index dc0a903ef9a6..483aa15222a4 100644 --- a/arch/um/drivers/pcap_user.c +++ b/arch/um/drivers/pcap_user.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "pcap_user.h" | 13 | #include "pcap_user.h" |
14 | #include "user.h" | 14 | #include "user.h" |
15 | #include "um_malloc.h" | 15 | #include "um_malloc.h" |
16 | #include "kern_constants.h" | ||
16 | 17 | ||
17 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) | 18 | #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) |
18 | 19 | ||
@@ -26,8 +27,8 @@ static int pcap_user_init(void *data, void *dev) | |||
26 | 27 | ||
27 | p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors); | 28 | p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors); |
28 | if(p == NULL){ | 29 | if(p == NULL){ |
29 | printk("pcap_user_init : pcap_open_live failed - '%s'\n", | 30 | printk(UM_KERN_ERR "pcap_user_init : pcap_open_live failed - " |
30 | errors); | 31 | "'%s'\n", errors); |
31 | return -EINVAL; | 32 | return -EINVAL; |
32 | } | 33 | } |
33 | 34 | ||
@@ -48,13 +49,13 @@ static int pcap_open(void *data) | |||
48 | if(pri->filter != NULL){ | 49 | if(pri->filter != NULL){ |
49 | err = dev_netmask(pri->dev, &netmask); | 50 | err = dev_netmask(pri->dev, &netmask); |
50 | if(err < 0){ | 51 | if(err < 0){ |
51 | printk("pcap_open : dev_netmask failed\n"); | 52 | printk(UM_KERN_ERR "pcap_open : dev_netmask failed\n"); |
52 | return -EIO; | 53 | return -EIO; |
53 | } | 54 | } |
54 | 55 | ||
55 | pri->compiled = um_kmalloc(sizeof(struct bpf_program)); | 56 | pri->compiled = um_kmalloc(sizeof(struct bpf_program)); |
56 | if(pri->compiled == NULL){ | 57 | if(pri->compiled == NULL){ |
57 | printk("pcap_open : kmalloc failed\n"); | 58 | printk(UM_KERN_ERR "pcap_open : kmalloc failed\n"); |
58 | return -ENOMEM; | 59 | return -ENOMEM; |
59 | } | 60 | } |
60 | 61 | ||
@@ -62,15 +63,15 @@ static int pcap_open(void *data) | |||
62 | (struct bpf_program *) pri->compiled, | 63 | (struct bpf_program *) pri->compiled, |
63 | pri->filter, pri->optimize, netmask); | 64 | pri->filter, pri->optimize, netmask); |
64 | if(err < 0){ | 65 | if(err < 0){ |
65 | printk("pcap_open : pcap_compile failed - '%s'\n", | 66 | printk(UM_KERN_ERR "pcap_open : pcap_compile failed - " |
66 | pcap_geterr(pri->pcap)); | 67 | "'%s'\n", pcap_geterr(pri->pcap)); |
67 | return -EIO; | 68 | return -EIO; |
68 | } | 69 | } |
69 | 70 | ||
70 | err = pcap_setfilter(pri->pcap, pri->compiled); | 71 | err = pcap_setfilter(pri->pcap, pri->compiled); |
71 | if(err < 0){ | 72 | if(err < 0){ |
72 | printk("pcap_open : pcap_setfilter failed - '%s'\n", | 73 | printk(UM_KERN_ERR "pcap_open : pcap_setfilter " |
73 | pcap_geterr(pri->pcap)); | 74 | "failed - '%s'\n", pcap_geterr(pri->pcap)); |
74 | return -EIO; | 75 | return -EIO; |
75 | } | 76 | } |
76 | } | 77 | } |
@@ -85,7 +86,8 @@ static void pcap_remove(void *data) | |||
85 | if(pri->compiled != NULL) | 86 | if(pri->compiled != NULL) |
86 | pcap_freecode(pri->compiled); | 87 | pcap_freecode(pri->compiled); |
87 | 88 | ||
88 | pcap_close(pri->pcap); | 89 | if(pri->pcap != NULL) |
90 | pcap_close(pri->pcap); | ||
89 | } | 91 | } |
90 | 92 | ||
91 | struct pcap_handler_data { | 93 | struct pcap_handler_data { |
@@ -114,7 +116,8 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri) | |||
114 | 116 | ||
115 | n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); | 117 | n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); |
116 | if(n < 0){ | 118 | if(n < 0){ |
117 | printk("pcap_dispatch failed - %s\n", pcap_geterr(pri->pcap)); | 119 | printk(UM_KERN_ERR "pcap_dispatch failed - %s\n", |
120 | pcap_geterr(pri->pcap)); | ||
118 | return -EIO; | 121 | return -EIO; |
119 | } | 122 | } |
120 | else if(n == 0) | 123 | else if(n == 0) |