Commit 5e1121cd authored by Ignat Korchagin's avatar Ignat Korchagin Committed by Richard Weinberger

um: Some fixes to build UML with musl

musl toolchain and headers are a bit more strict. These fixes enable building
UML with musl as well as seem not to break on glibc.
Signed-off-by: default avatarIgnat Korchagin <ignat@cloudflare.com>
Tested-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent e4e721fe
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
......
...@@ -32,7 +32,7 @@ static int pcap_user_init(void *data, void *dev) ...@@ -32,7 +32,7 @@ static int pcap_user_init(void *data, void *dev)
return 0; return 0;
} }
static int pcap_open(void *data) static int pcap_user_open(void *data)
{ {
struct pcap_data *pri = data; struct pcap_data *pri = data;
__u32 netmask; __u32 netmask;
...@@ -44,14 +44,14 @@ static int pcap_open(void *data) ...@@ -44,14 +44,14 @@ static int pcap_open(void *data)
if (pri->filter != NULL) { if (pri->filter != NULL) {
err = dev_netmask(pri->dev, &netmask); err = dev_netmask(pri->dev, &netmask);
if (err < 0) { if (err < 0) {
printk(UM_KERN_ERR "pcap_open : dev_netmask failed\n"); printk(UM_KERN_ERR "pcap_user_open : dev_netmask failed\n");
return -EIO; return -EIO;
} }
pri->compiled = uml_kmalloc(sizeof(struct bpf_program), pri->compiled = uml_kmalloc(sizeof(struct bpf_program),
UM_GFP_KERNEL); UM_GFP_KERNEL);
if (pri->compiled == NULL) { if (pri->compiled == NULL) {
printk(UM_KERN_ERR "pcap_open : kmalloc failed\n"); printk(UM_KERN_ERR "pcap_user_open : kmalloc failed\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -59,14 +59,14 @@ static int pcap_open(void *data) ...@@ -59,14 +59,14 @@ static int pcap_open(void *data)
(struct bpf_program *) pri->compiled, (struct bpf_program *) pri->compiled,
pri->filter, pri->optimize, netmask); pri->filter, pri->optimize, netmask);
if (err < 0) { if (err < 0) {
printk(UM_KERN_ERR "pcap_open : pcap_compile failed - " printk(UM_KERN_ERR "pcap_user_open : pcap_compile failed - "
"'%s'\n", pcap_geterr(pri->pcap)); "'%s'\n", pcap_geterr(pri->pcap));
goto out; goto out;
} }
err = pcap_setfilter(pri->pcap, pri->compiled); err = pcap_setfilter(pri->pcap, pri->compiled);
if (err < 0) { if (err < 0) {
printk(UM_KERN_ERR "pcap_open : pcap_setfilter " printk(UM_KERN_ERR "pcap_user_open : pcap_setfilter "
"failed - '%s'\n", pcap_geterr(pri->pcap)); "failed - '%s'\n", pcap_geterr(pri->pcap));
goto out; goto out;
} }
...@@ -127,7 +127,7 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri) ...@@ -127,7 +127,7 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri)
const struct net_user_info pcap_user_info = { const struct net_user_info pcap_user_info = {
.init = pcap_user_init, .init = pcap_user_init,
.open = pcap_open, .open = pcap_user_open,
.close = NULL, .close = NULL,
.remove = pcap_remove, .remove = pcap_remove,
.add_address = NULL, .add_address = NULL,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <sys/termios.h> #include <termios.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <net_user.h> #include <net_user.h>
#include <os.h> #include <os.h>
......
...@@ -18,9 +18,7 @@ ...@@ -18,9 +18,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#include <net/ethernet.h>
#include <netinet/ip.h> #include <netinet/ip.h>
#include <netinet/ether.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/if_packet.h> #include <linux/if_packet.h>
#include <sys/wait.h> #include <sys/wait.h>
...@@ -332,7 +330,7 @@ static struct vector_fds *user_init_unix_fds(struct arglist *ifspec, int id) ...@@ -332,7 +330,7 @@ static struct vector_fds *user_init_unix_fds(struct arglist *ifspec, int id)
} }
switch (id) { switch (id) {
case ID_BESS: case ID_BESS:
if (connect(fd, remote_addr, sizeof(struct sockaddr_un)) < 0) { if (connect(fd, (const struct sockaddr *) remote_addr, sizeof(struct sockaddr_un)) < 0) {
printk(UM_KERN_ERR "bess open:cannot connect to %s %i", remote_addr->sun_path, -errno); printk(UM_KERN_ERR "bess open:cannot connect to %s %i", remote_addr->sun_path, -errno);
goto unix_cleanup; goto unix_cleanup;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <signal.h> #include <signal.h>
#include <string.h> #include <string.h>
#include <termios.h> #include <termios.h>
#include <wait.h> #include <sys/wait.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <init.h> #include <init.h>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <stddef.h> #include <stddef.h>
#include <signal.h> #include <signal.h>
#include <sys/poll.h> #include <poll.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/user.h> #include <sys/user.h>
#define __FRAME_OFFSETS #define __FRAME_OFFSETS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment