batctl: musl build fixes

Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
This commit is contained in:
Marek Lindner 2015-06-21 19:06:29 +08:00
parent 54b696ef52
commit 8618fb8ba6
2 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,66 @@
From 6423e3e5cdc1f79625dbf90ff6444b0ad8b02185 Mon Sep 17 00:00:00 2001
From: Alex Suykov <alex.suykov@gmail.com>
Date: Mon, 6 Apr 2015 17:29:13 +0300
Subject: [PATCH] batctl: use netinet/if_ether.h instead of linux/if_ether.h
musl does not allow including netinet/* and linux/* headers together.
batctl includes netinet/if_ether.h indirectly via net/ethernet.h,
so netinet/if_ether.h must be used instead of linux/if_ether.h.
Signed-off-by: Alex Suykov <alex.suykov at gmail.com>
Acked-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
ping.c | 2 +-
tcpdump.h | 2 +-
traceroute.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/ping.c b/ping.c
index bdca222..7880a82 100644
--- a/ping.c
+++ b/ping.c
@@ -34,7 +34,7 @@
#include <stdint.h>
#include <sys/select.h>
#include <sys/time.h>
-#include <linux/if_ether.h>
+#include <netinet/if_ether.h>
#include "main.h"
#include "ping.h"
diff --git a/tcpdump.h b/tcpdump.h
index 5d936f2..3c9126c 100644
--- a/tcpdump.h
+++ b/tcpdump.h
@@ -23,7 +23,7 @@
#define _BATCTL_TCPDUMP_H
#include <netpacket/packet.h>
-#include <linux/if_ether.h>
+#include <netinet/if_ether.h>
#include <net/if_arp.h>
#include <sys/types.h>
#include "main.h"
diff --git a/traceroute.c b/traceroute.c
index 4ebfec2..373fe90 100644
--- a/traceroute.c
+++ b/traceroute.c
@@ -22,13 +22,13 @@
#include <netinet/in.h>
+#include <netinet/if_ether.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
-#include <linux/if_ether.h>
#include <stddef.h>
#include <sys/select.h>
#include <sys/time.h>
--
2.1.4

View File

@ -0,0 +1,54 @@
From fb51f72f3fe911103abe565ebe88b7545a18d963 Mon Sep 17 00:00:00 2001
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 17 Apr 2015 19:40:28 +0200
Subject: [PATCH] batctl: Add required includes to all files
The header files could not be build indepdent from each other. This is happened
because headers didn't include the files for things they've used. This was
problematic because the success of a build depended on the knowledge about the
right order of local includes.
Also source files were not including everything they've used explicitly.
Instead they required that transitive includes are always stable. This is
problematic because some transitive includes are not obvious, depend on config
settings and may not be stable in the future.
The order for include blocks are:
* primary headers (main.h and the *.h file of a *.c file)
* global linux headers
* required local headers
* extra forward declarations for pointers in function/struct declarations
The only exceptions are linux/bitops.h and linux/if_ether.h in packet.h. This
header file is shared with userspace applications like batctl and must
therefore build together with userspace applications. The header linux/bitops.h
is not part of the uapi headers and linux/if_ether.h conflicts with the musl
implementation of netinet/if_ether.h. The maintainers rejected the use of
__KERNEL__ preprocessor checks and thus these two headers are only in main.h.
All files using packet.h first have to include main.h to work correctly.
Reported-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
packet.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/packet.h b/packet.h
index b81fbbf..7a9cb7a 100644
--- a/packet.h
+++ b/packet.h
@@ -18,6 +18,9 @@
#ifndef _NET_BATMAN_ADV_PACKET_H_
#define _NET_BATMAN_ADV_PACKET_H_
+#include <asm/byteorder.h>
+#include <linux/types.h>
+
/**
* enum batadv_packettype - types for batman-adv encapsulated packets
* @BATADV_IV_OGM: originator messages for B.A.T.M.A.N. IV
--
2.1.4