Skip to content

build: the war on config.h is a war of attrition, 2 of ∞ #18877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,6 @@ m4_define([FRR_INCLUDES],
#include <stdlib.h>
#include <stddef.h>
#include <sys/types.h>
/* sys/conf.h depends on param.h on FBSD at least */
#include <sys/param.h>
/* Required for MAXSIG */
#include <signal.h>
Expand All @@ -1251,23 +1250,8 @@ m4_define([FRR_INCLUDES],
#include <net/if.h>
])dnl

dnl Same applies for HAVE_NET_IF_VAR_H, which HAVE_NETINET6_ND6_H and
dnl HAVE_NETINET_IN_VAR_H depend upon. But if_var.h depends on if.h, hence
dnl an additional round for it.

AC_CHECK_HEADERS([net/if_var.h], [], [], [FRR_INCLUDES])

m4_define([FRR_INCLUDES],
FRR_INCLUDES
[#ifdef HAVE_NET_IF_VAR_H
# include <net/if_var.h>
#endif
])dnl

AC_CHECK_HEADERS([netinet/in_var.h \
net/if_dl.h \
netinet/ip_icmp.h \
sys/sysctl.h sys/sockio.h sys/conf.h],
netinet/ip_icmp.h],
[], [], [FRR_INCLUDES])

AC_CHECK_HEADERS([ucontext.h], [], [],
Expand Down Expand Up @@ -1297,7 +1281,7 @@ FRR_INCLUDES
#ifdef HAVE_NETINET_IN_VAR_H
# include <netinet/in_var.h>
#endif
#ifdef HAVE_NET_IF_DL_H
#ifndef __linux__
# include <net/if_dl.h>
#endif
#include <net/route.h>
Expand Down Expand Up @@ -1797,15 +1781,12 @@ dnl ------------------
dnl IPv6 header checks
dnl ------------------
AC_CHECK_HEADERS([ \
netinet6/in6_var.h netinet6/nd6.h], [], [],
netinet6/nd6.h], [], [],
FRR_INCLUDES)

m4_define([FRR_INCLUDES],dnl
FRR_INCLUDES
[#include <netinet/icmp6.h>
#ifdef HAVE_NETINET6_IN6_VAR_H
# include <netinet6/in6_var.h>
#endif
#ifdef HAVE_NETINET6_ND6_H
# include <netinet6/nd6.h>
#endif
Expand Down Expand Up @@ -2310,7 +2291,7 @@ AC_CHECK_TYPES([
struct sockaddr_dl,
struct vifctl, struct mfcctl, struct sioc_sg_req,
vifi_t, struct sioc_vif_req, struct igmpmsg,
struct ifaliasreq, struct in6_aliasreq,
struct ifaliasreq,
struct nd_opt_adv_interval,
struct nd_opt_homeagent_info, struct nd_opt_adv_interval,
struct nd_opt_rdnss, struct nd_opt_dnssl],
Expand Down
4 changes: 4 additions & 0 deletions eigrpd/eigrp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

#include <zebra.h>

#ifndef __linux__
#include <net/if_dl.h>
#endif

#include "frrevent.h"
#include "memory.h"
#include "linklist.h"
Expand Down
4 changes: 4 additions & 0 deletions ldpd/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#include <zebra.h>

#ifndef __linux__
#include <net/if_dl.h>
#endif

#include "ldpd.h"
#include "ldpe.h"
#include "log.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#ifndef _ZEBRA_PREFIX_H
#define _ZEBRA_PREFIX_H

#ifdef GNU_LINUX
#ifdef __linux__
#include <net/ethernet.h>
#else
#include <netinet/if_ether.h>
Expand Down
4 changes: 4 additions & 0 deletions lib/sockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include <zebra.h>

#ifndef __linux__
#include <net/if_dl.h>
#endif

#include "log.h"
#include "sockopt.h"
#include "sockunion.h"
Expand Down
4 changes: 4 additions & 0 deletions lib/sockunion.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include <zebra.h>

#ifndef __linux__
#include <net/if_dl.h>
#endif

#include "prefix.h"
#include "vty.h"
#include "sockunion.h"
Expand Down
26 changes: 0 additions & 26 deletions lib/zebra.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@
#include <ctype.h>
#include <sys/types.h>
#include <sys/param.h>
#ifdef HAVE_SYS_SYSCTL_H
#ifdef GNU_LINUX
#include <linux/types.h>
#else
#include <sys/sysctl.h>
#endif
#endif /* HAVE_SYS_SYSCTL_H */
#ifdef HAVE_SYS_CONF_H
#include <sys/conf.h>
#endif /* HAVE_SYS_CONF_H */
#include <sys/time.h>
#include <time.h>
#include <inttypes.h>
Expand All @@ -44,10 +34,6 @@

#include <sys/socket.h>

#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif /* HAVE_SYS_SOCKIO_H */

#include "openbsd-tree.h"

#include <netinet/in.h>
Expand All @@ -56,14 +42,6 @@

#include <net/if.h>

#ifdef HAVE_NET_IF_DL_H
#include <net/if_dl.h>
#endif /* HAVE_NET_IF_DL_H */

#ifdef HAVE_NET_IF_VAR_H
#include <net/if_var.h>
#endif /* HAVE_NET_IF_VAR_H */

#ifndef HAVE_NETLINK
#define RT_TABLE_MAIN 0
#define RT_TABLE_LOCAL RT_TABLE_MAIN
Expand All @@ -76,10 +54,6 @@
#include <netinet/in_var.h>
#endif /* HAVE_NETINET_IN_VAR_H */

#ifdef HAVE_NETINET6_IN6_VAR_H
#include <netinet6/in6_var.h>
#endif /* HAVE_NETINET6_IN6_VAR_H */

#ifdef HAVE_NETINET6_IN_H
#include <netinet6/in.h>
#endif /* HAVE_NETINET6_IN_H */
Expand Down
4 changes: 4 additions & 0 deletions ospf6d/ospf6_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

#include <zebra.h>

#ifndef __linux__
#include <net/if_dl.h>
#endif

#include "memory.h"
#include "if.h"
#include "log.h"
Expand Down
4 changes: 4 additions & 0 deletions ospfd/ospf_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#include <zebra.h>

#ifndef __linux__
#include <net/if_dl.h>
#endif

#include "monotime.h"
#include "frrevent.h"
#include "memory.h"
Expand Down
2 changes: 1 addition & 1 deletion pceplib/pcep.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "config.h"
#endif

#if defined(linux) || defined(GNU_LINUX)
#ifdef __linux__

#define ipv6_u __in6_u
#else
Expand Down
2 changes: 2 additions & 0 deletions zebra/if_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#if !defined(GNU_LINUX) && !defined(OPEN_BSD)

#include <sys/sysctl.h>

#include "if.h"
#include "sockunion.h"
#include "prefix.h"
Expand Down
4 changes: 4 additions & 0 deletions zebra/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#ifndef _ZEBRA_INTERFACE_H
#define _ZEBRA_INTERFACE_H

#ifndef __linux__
#include <net/if_dl.h>
#endif

#include "redistribute.h"
#include "vrf.h"
#include "hook.h"
Expand Down
29 changes: 3 additions & 26 deletions zebra/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <zebra.h>

#include <sys/ioctl.h>
#ifndef __linux__
#include <netinet6/in6_var.h>
#endif

#include "linklist.h"
#include "if.h"
Expand Down Expand Up @@ -533,12 +536,6 @@ int if_unset_flags(struct interface *ifp, uint64_t flags)
}

#ifndef LINUX_IPV6 /* Netlink has its own code */

#ifdef HAVE_STRUCT_IN6_ALIASREQ
#ifndef ND6_INFINITE_LIFETIME
#define ND6_INFINITE_LIFETIME 0xffffffffL
#endif /* ND6_INFINITE_LIFETIME */

/*
* Helper for interface-addr install, non-netlink
*/
Expand Down Expand Up @@ -614,29 +611,9 @@ static int if_unset_prefix6_ctx(const struct zebra_dplane_ctx *ctx)
#endif
memcpy(&addreq.ifra_prefixmask, &mask, sizeof(struct sockaddr_in6));

#ifdef HAVE_STRUCT_IF6_ALIASREQ_IFRA_LIFETIME
addreq.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME;
addreq.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME;
#endif

ret = if_ioctl_ipv6(SIOCDIFADDR_IN6, (caddr_t)&addreq);
if (ret < 0)
return ret;
return 0;
}
#else
/* The old, pre-dataplane code here just returned, so we're retaining that
* choice.
*/
static int if_set_prefix6_ctx(const struct zebra_dplane_ctx *ctx)
{
return 0;
}

static int if_unset_prefix6_ctx(const struct zebra_dplane_ctx *ctx)
{
return 0;
}
#endif /* HAVE_STRUCT_IN6_ALIASREQ */

#endif /* LINUX_IPV6 */
2 changes: 2 additions & 0 deletions zebra/ipforward_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#if !defined(GNU_LINUX)

#include <sys/sysctl.h>

#include "privs.h"
#include "zebra/ipforward.h"
#include "zebra/zebra_errors.h"
Expand Down
2 changes: 2 additions & 0 deletions zebra/rtread_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#if !defined(GNU_LINUX)

#include <sys/sysctl.h>

#include "memory.h"
#include "log.h"
#include "vrf.h"
Expand Down
4 changes: 2 additions & 2 deletions zebra/table_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extern "C" {
/* routing table identifiers
*
*/
#if !defined(GNU_LINUX)
#ifndef __linux__
/* BSD systems
*/
#define RT_TABLE_ID_MAIN 0
Expand All @@ -33,7 +33,7 @@ extern "C" {
#define RT_TABLE_ID_DEFAULT 253
#define RT_TABLE_ID_COMPAT 252
#define RT_TABLE_ID_UNSPEC 0
#endif /* !def(GNU_LINUX) */
#endif /* !__linux__ */

/*
* Table chunk struct
Expand Down
Loading