From a90044320eecda424ed678d283ef60806c70fcda Mon Sep 17 00:00:00 2001
From: Chen Qi <Qi.Chen@windriver.com>
Date: Tue, 2 Jul 2024 23:23:57 -0700
Subject: [PATCH 25/26] adjust header inclusion order to avoid redeclaration

Upstream-Status: Inappropriate [musl specific]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 src/basic/parse-util.c                | 3 ++-
 src/libsystemd-network/ndisc-option.c | 6 +++---
 src/libsystemd-network/sd-radv.c      | 5 +++--
 src/network/netdev/l2tp-tunnel.c      | 9 ++++-----
 src/network/netdev/l2tp-tunnel.h      | 6 +++---
 src/network/netdev/wireguard.c        | 2 +-
 src/network/networkctl-link-info.c    | 4 ++--
 src/network/networkd-bridge-mdb.c     | 3 ++-
 src/network/networkd-route.c          | 8 ++++----
 src/resolve/resolved-dns-stream.c     | 5 +++--
 src/resolve/resolved-manager.c        | 5 +++--
 src/shared/conf-parser.c              | 3 ++-
 12 files changed, 32 insertions(+), 27 deletions(-)

diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c
index faa5344921..0fc9d12c89 100644
--- a/src/basic/parse-util.c
+++ b/src/basic/parse-util.c
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <inttypes.h>
-#include <linux/ipv6.h>
 #include <net/if.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -20,6 +19,8 @@
 #include "string-util.h"
 #include "strv.h"
 
+#include <linux/ipv6.h>
+
 int parse_boolean(const char *v) {
         if (!v)
                 return -EINVAL;
diff --git a/src/libsystemd-network/ndisc-option.c b/src/libsystemd-network/ndisc-option.c
index 3aab51f51b..feeb4c78e5 100644
--- a/src/libsystemd-network/ndisc-option.c
+++ b/src/libsystemd-network/ndisc-option.c
@@ -1,8 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <linux/ipv6.h>
-#include <netinet/icmp6.h>
-
 #include "dns-resolver-internal.h"
 #include "dns-domain.h"
 #include "ether-addr-util.h"
@@ -16,6 +13,9 @@
 #include "strv.h"
 #include "unaligned.h"
 
+#include <linux/ipv6.h>
+#include <netinet/icmp6.h>
+
 /* RFC does not say anything about the maximum number of options, but let's limit the number of options for
  * safety. Typically, the number of options in an ICMPv6 message should be only a few. */
 #define MAX_OPTIONS 128
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c
index f241929ad5..7cef3c3f71 100644
--- a/src/libsystemd-network/sd-radv.c
+++ b/src/libsystemd-network/sd-radv.c
@@ -3,8 +3,6 @@
   Copyright © 2017 Intel Corporation. All rights reserved.
 ***/
 
-#include <linux/ipv6.h>
-#include <netinet/icmp6.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
@@ -29,6 +27,9 @@
 #include "strv.h"
 #include "unaligned.h"
 
+#include <linux/ipv6.h>
+#include <netinet/icmp6.h>
+
 int sd_radv_new(sd_radv **ret) {
         _cleanup_(sd_radv_unrefp) sd_radv *ra = NULL;
 
diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c
index c87e44797b..437b40c114 100644
--- a/src/network/netdev/l2tp-tunnel.c
+++ b/src/network/netdev/l2tp-tunnel.c
@@ -1,10 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <netinet/in.h>
-#include <linux/if_arp.h>
-#include <linux/l2tp.h>
-#include <linux/genetlink.h>
-
 #include "conf-parser.h"
 #include "hashmap.h"
 #include "l2tp-tunnel.h"
@@ -17,6 +12,10 @@
 #include "string-table.h"
 #include "string-util.h"
 
+#include <netinet/in.h>
+#include <linux/l2tp.h>
+#include <linux/genetlink.h>
+
 static const char* const l2tp_l2spec_type_table[_NETDEV_L2TP_L2SPECTYPE_MAX] = {
         [NETDEV_L2TP_L2SPECTYPE_NONE]    = "none",
         [NETDEV_L2TP_L2SPECTYPE_DEFAULT] = "default",
diff --git a/src/network/netdev/l2tp-tunnel.h b/src/network/netdev/l2tp-tunnel.h
index c558ed49de..8419ef34c5 100644
--- a/src/network/netdev/l2tp-tunnel.h
+++ b/src/network/netdev/l2tp-tunnel.h
@@ -1,13 +1,13 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <netinet/in.h>
-#include <linux/l2tp.h>
-
 #include "in-addr-util.h"
 #include "netdev.h"
 #include "networkd-util.h"
 
+#include <netinet/in.h>
+#include <linux/l2tp.h>
+
 typedef enum L2tpL2specType {
         NETDEV_L2TP_L2SPECTYPE_NONE = L2TP_L2SPECTYPE_NONE,
         NETDEV_L2TP_L2SPECTYPE_DEFAULT = L2TP_L2SPECTYPE_DEFAULT,
diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
index 5182783f45..79b21cb4ba 100644
--- a/src/network/netdev/wireguard.c
+++ b/src/network/netdev/wireguard.c
@@ -5,9 +5,9 @@
 
 /* Make sure the net/if.h header is included before any linux/ one */
 #include <net/if.h>
+#include <netinet/in.h>
 //#include <linux/if_arp.h>
 #include <linux/ipv6_route.h>
-#include <netinet/in.h>
 #include <sys/ioctl.h>
 
 #include "sd-resolve.h"
diff --git a/src/network/networkctl-link-info.c b/src/network/networkctl-link-info.c
index f356d3c231..216c442de1 100644
--- a/src/network/networkctl-link-info.c
+++ b/src/network/networkctl-link-info.c
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <linux/if_tunnel.h>
-
 #include "bus-common-errors.h"
 #include "bus-error.h"
 #include "bus-util.h"
@@ -16,6 +14,8 @@
 #include "strxcpyx.h"
 #include "wifi-util.h"
 
+#include <linux/if_tunnel.h>
+
 /* use 128 kB for receive socket kernel queue, we shouldn't need more here */
 #define RCVBUF_SIZE    (128*1024)
 
diff --git a/src/network/networkd-bridge-mdb.c b/src/network/networkd-bridge-mdb.c
index 358ca4d294..fe87f7c093 100644
--- a/src/network/networkd-bridge-mdb.c
+++ b/src/network/networkd-bridge-mdb.c
@@ -2,7 +2,6 @@
 
 /* Make sure the net/if.h header is included before any linux/ one */
 #include <net/if.h>
-#include <linux/if_bridge.h>
 
 #include "netlink-util.h"
 #include "networkd-bridge-mdb.h"
@@ -13,6 +12,8 @@
 #include "string-util.h"
 #include "vlan-util.h"
 
+#include <linux/if_bridge.h>
+
 #define STATIC_BRIDGE_MDB_ENTRIES_PER_NETWORK_MAX 1024U
 
 /* remove MDB entry. */
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 0f3f79ec4f..325743bebf 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -1,9 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <linux/if.h>
-#include <linux/ipv6_route.h>
-#include <linux/nexthop.h>
-
 #include "alloc-util.h"
 #include "event-util.h"
 #include "netlink-util.h"
@@ -21,6 +17,10 @@
 #include "vrf.h"
 #include "wireguard.h"
 
+#include <linux/if.h>
+#include <linux/ipv6_route.h>
+#include <linux/nexthop.h>
+
 static Route* route_detach_impl(Route *route) {
         assert(route);
         assert(!!route->network + !!route->manager + !!route->wireguard <= 1);
diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c
index e57af66221..f66d8f0606 100644
--- a/src/resolve/resolved-dns-stream.c
+++ b/src/resolve/resolved-dns-stream.c
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include <linux/if_arp.h>
-#include <netinet/tcp.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
@@ -12,6 +10,9 @@
 #include "resolved-dns-stream.h"
 #include "resolved-manager.h"
 
+//#include <linux/if_arp.h>
+#include <netinet/tcp.h>
+
 #define DNS_STREAMS_MAX 128
 
 #define DNS_QUERIES_PER_STREAM 32
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index dbaad81734..b988e75851 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <fcntl.h>
-#include <linux/ipv6.h>
-#include <netinet/in.h>
 #include <poll.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
@@ -46,6 +44,9 @@
 #include "utf8.h"
 #include "varlink-util.h"
 
+#include <linux/ipv6.h>
+#include <netinet/in.h>
+
 #define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC)
 
 static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *userdata) {
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index eaa8a5f11c..03379e7474 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -2,7 +2,6 @@
 
 #include <errno.h>
 #include <limits.h>
-#include <linux/ipv6.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -47,6 +46,8 @@
 #include "time-util.h"
 #include "utf8.h"
 
+#include <linux/ipv6.h>
+
 DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(config_file_hash_ops_fclose,
                                               char, path_hash_func, path_compare,
                                               FILE, safe_fclose);
-- 
2.34.1

