summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-08-06 09:19:14 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2017-08-15 13:26:55 +0200
commit8dc1f7fc888a59c5b723befdd0dbeff5587afa56 (patch)
treeed366b74e0fbbae2d8a198eb4412cebf09b3575f
parentead4ee99acd63d2342e9e9dda7a8f5a103a6f550 (diff)
zebra: irdp: convert into module
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rwxr-xr-xconfigure.ac38
-rw-r--r--zebra/irdp.h1
-rw-r--r--zebra/irdp_interface.c4
-rw-r--r--zebra/irdp_main.c19
-rw-r--r--zebra/irdp_packet.c5
-rw-r--r--zebra/main.c3
-rw-r--r--zebra/subdir.am13
7 files changed, 47 insertions, 36 deletions
diff --git a/configure.ac b/configure.ac
index 574992342f..710a71f636 100755
--- a/configure.ac
+++ b/configure.ac
@@ -344,7 +344,7 @@ AC_ARG_ENABLE(shell_access,
AC_ARG_ENABLE(rtadv,
AS_HELP_STRING([--disable-rtadv], [disable IPV6 router advertisement feature]))
AC_ARG_ENABLE(irdp,
- AS_HELP_STRING([--enable-irdp], [enable IRDP server support in zebra]))
+ AS_HELP_STRING([--disable-irdp], [enable IRDP server support in zebra (default if supported)]))
AC_ARG_ENABLE(capabilities,
AS_HELP_STRING([--disable-capabilities], [disable using POSIX capabilities]))
AC_ARG_ENABLE(rusage,
@@ -570,10 +570,6 @@ else
AC_MSG_RESULT(no)
fi
-if test "${enable_irdp}" = "yes"; then
- AC_DEFINE(HAVE_IRDP,, IRDP )
-fi
-
if test x"${enable_user}" = x"no"; then
enable_user=""
else
@@ -1479,17 +1475,27 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len,
dnl ---------------------------
dnl IRDP/pktinfo/icmphdr checks
dnl ---------------------------
-AC_CHECK_TYPES([struct in_pktinfo],
- [AC_CHECK_TYPES([struct icmphdr],
- [if test "${enable_irdp}" != "no"; then
- AC_DEFINE(HAVE_IRDP,, IRDP)
- fi],
- [if test "${enable_irdp}" = "yes"; then
- AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
- fi], [FRR_INCLUDES])],
- [if test "${enable_irdp}" = "yes"; then
- AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
- fi], [FRR_INCLUDES])
+
+AC_CHECK_TYPES([struct in_pktinfo], [
+ AC_CHECK_TYPES([struct icmphdr], [
+ IRDP=true
+ ], [
+ IRDP=false
+ ], [FRR_INCLUDES])
+], [
+ IRDP=false
+], [FRR_INCLUDES])
+
+case "${enable_irdp}" in
+yes)
+ $IRDP || AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
+ ;;
+no)
+ IRDP=false
+ ;;
+esac
+
+AM_CONDITIONAL(IRDP, $IRDP)
dnl -----------------------
dnl checking for IP_PKTINFO
diff --git a/zebra/irdp.h b/zebra/irdp.h
index f8f7811248..ea190b574d 100644
--- a/zebra/irdp.h
+++ b/zebra/irdp.h
@@ -138,7 +138,6 @@ struct Adv {
int pref;
};
-extern void irdp_init(void);
extern void irdp_if_init(void);
extern int irdp_sock_init(void);
extern int irdp_config_write(struct vty *, struct interface *);
diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c
index 3465bdebbf..34c78e2a48 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -35,8 +35,6 @@
#include <zebra.h>
-#ifdef HAVE_IRDP
-
#include "if.h"
#include "vty.h"
#include "sockunion.h"
@@ -691,5 +689,3 @@ void irdp_if_init()
install_element(INTERFACE_NODE, &ip_irdp_debug_packet_cmd);
install_element(INTERFACE_NODE, &ip_irdp_debug_disable_cmd);
}
-
-#endif /* HAVE_IRDP */
diff --git a/zebra/irdp_main.c b/zebra/irdp_main.c
index 73c6d8141a..9dfa854725 100644
--- a/zebra/irdp_main.c
+++ b/zebra/irdp_main.c
@@ -35,8 +35,6 @@
#include <zebra.h>
-#ifdef HAVE_IRDP
-
#include "if.h"
#include "vty.h"
#include "sockunion.h"
@@ -53,6 +51,7 @@
#include "thread.h"
#include "privs.h"
#include "libfrr.h"
+#include "version.h"
#include "zebra/interface.h"
#include "zebra/rtadv.h"
#include "zebra/rib.h"
@@ -341,11 +340,23 @@ static int irdp_finish(void)
return 0;
}
-void irdp_init(void)
+static int irdp_init(struct thread_master *master)
{
irdp_if_init();
hook_register(frr_early_fini, irdp_finish);
+ return 0;
+}
+
+static int irdp_module_init(void)
+{
+ hook_register(frr_late_init, irdp_init);
+ return 0;
}
-#endif /* HAVE_IRDP */
+FRR_MODULE_SETUP(
+ .name = "zebra_irdp",
+ .version = FRR_VERSION,
+ .description = "zebra IRDP module",
+ .init = irdp_module_init,
+)
diff --git a/zebra/irdp_packet.c b/zebra/irdp_packet.c
index a64eac2ea4..0832245536 100644
--- a/zebra/irdp_packet.c
+++ b/zebra/irdp_packet.c
@@ -36,8 +36,6 @@
#include <zebra.h>
-#ifdef HAVE_IRDP
-
#include "if.h"
#include "vty.h"
#include "sockunion.h"
@@ -353,6 +351,3 @@ void send_packet(struct interface *ifp, struct stream *s, u_int32_t dst,
}
/* printf("TX on %s idx %d\n", ifp->name, ifp->ifindex); */
}
-
-
-#endif /* HAVE_IRDP */
diff --git a/zebra/main.c b/zebra/main.c
index 72f96add86..bc7276817d 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -292,9 +292,6 @@ int main(int argc, char **argv)
#if defined(HAVE_RTADV)
rtadv_cmd_init();
#endif
-#ifdef HAVE_IRDP
- irdp_init();
-#endif
/* PTM socket */
#ifdef ZEBRA_PTM_SUPPORT
zebra_ptm_init();
diff --git a/zebra/subdir.am b/zebra/subdir.am
index 0391cab9fd..3474823623 100644
--- a/zebra/subdir.am
+++ b/zebra/subdir.am
@@ -6,6 +6,9 @@ if ZEBRA
sbin_PROGRAMS += zebra/zebra
dist_examples_DATA += zebra/zebra.conf.sample
+if IRDP
+module_LTLIBRARIES += zebra/zebra_irdp.la
+endif
if SNMP
module_LTLIBRARIES += zebra/zebra_snmp.la
endif
@@ -30,9 +33,6 @@ zebra_zebra_SOURCES = \
zebra/ipforward_proc.c \
zebra/ipforward_solaris.c \
zebra/ipforward_sysctl.c \
- zebra/irdp_interface.c \
- zebra/irdp_main.c \
- zebra/irdp_packet.c \
zebra/kernel_netlink.c \
zebra/kernel_socket.c \
zebra/label_manager.c \
@@ -106,6 +106,13 @@ noinst_HEADERS += \
zebra/zserv.h \
# end
+zebra_zebra_irdp_la_SOURCES = \
+ zebra/irdp_interface.c \
+ zebra/irdp_main.c \
+ zebra/irdp_packet.c \
+ # end
+zebra_zebra_irdp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic
+
zebra_zebra_snmp_la_SOURCES = zebra/zebra_snmp.c
zebra_zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS)
zebra_zebra_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic