diff options
author | Jeff Dike <jdike@addtoit.com> | 2007-05-08 00:35:04 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 11:15:20 -0700 |
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 dc0a903ef9a..483aa15222a 100644 --- a/arch/um/drivers/pcap_user.c +++ b/arch/um/drivers/pcap_user.c @@ -13,6 +13,7 @@ #include "pcap_user.h" #include "user.h" #include "um_malloc.h" +#include "kern_constants.h" #define MAX_PACKET (ETH_MAX_PACKET + ETH_HEADER_OTHER) @@ -26,8 +27,8 @@ static int pcap_user_init(void *data, void *dev) p = pcap_open_live(pri->host_if, MAX_PACKET, pri->promisc, 0, errors); if(p == NULL){ - printk("pcap_user_init : pcap_open_live failed - '%s'\n", - errors); + printk(UM_KERN_ERR "pcap_user_init : pcap_open_live failed - " + "'%s'\n", errors); return -EINVAL; } @@ -48,13 +49,13 @@ static int pcap_open(void *data) if(pri->filter != NULL){ err = dev_netmask(pri->dev, &netmask); if(err < 0){ - printk("pcap_open : dev_netmask failed\n"); + printk(UM_KERN_ERR "pcap_open : dev_netmask failed\n"); return -EIO; } pri->compiled = um_kmalloc(sizeof(struct bpf_program)); if(pri->compiled == NULL){ - printk("pcap_open : kmalloc failed\n"); + printk(UM_KERN_ERR "pcap_open : kmalloc failed\n"); return -ENOMEM; } @@ -62,15 +63,15 @@ static int pcap_open(void *data) (struct bpf_program *) pri->compiled, pri->filter, pri->optimize, netmask); if(err < 0){ - printk("pcap_open : pcap_compile failed - '%s'\n", - pcap_geterr(pri->pcap)); + printk(UM_KERN_ERR "pcap_open : pcap_compile failed - " + "'%s'\n", pcap_geterr(pri->pcap)); return -EIO; } err = pcap_setfilter(pri->pcap, pri->compiled); if(err < 0){ - printk("pcap_open : pcap_setfilter failed - '%s'\n", - pcap_geterr(pri->pcap)); + printk(UM_KERN_ERR "pcap_open : pcap_setfilter " + "failed - '%s'\n", pcap_geterr(pri->pcap)); return -EIO; } } @@ -85,7 +86,8 @@ static void pcap_remove(void *data) if(pri->compiled != NULL) pcap_freecode(pri->compiled); - pcap_close(pri->pcap); + if(pri->pcap != NULL) + pcap_close(pri->pcap); } struct pcap_handler_data { @@ -114,7 +116,8 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri) n = pcap_dispatch(pri->pcap, 1, handler, (u_char *) &hdata); if(n < 0){ - printk("pcap_dispatch failed - %s\n", pcap_geterr(pri->pcap)); + printk(UM_KERN_ERR "pcap_dispatch failed - %s\n", + pcap_geterr(pri->pcap)); return -EIO; } else if(n == 0) |