zebra: irdp: convert into module

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-08-06 09:19:14 +02:00
parent ead4ee99ac
commit 8dc1f7fc88
7 changed files with 47 additions and 36 deletions

View file

@ -344,7 +344,7 @@ AC_ARG_ENABLE(shell_access,
AC_ARG_ENABLE(rtadv, AC_ARG_ENABLE(rtadv,
AS_HELP_STRING([--disable-rtadv], [disable IPV6 router advertisement feature])) AS_HELP_STRING([--disable-rtadv], [disable IPV6 router advertisement feature]))
AC_ARG_ENABLE(irdp, 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, AC_ARG_ENABLE(capabilities,
AS_HELP_STRING([--disable-capabilities], [disable using POSIX capabilities])) AS_HELP_STRING([--disable-capabilities], [disable using POSIX capabilities]))
AC_ARG_ENABLE(rusage, AC_ARG_ENABLE(rusage,
@ -570,10 +570,6 @@ else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
fi fi
if test "${enable_irdp}" = "yes"; then
AC_DEFINE(HAVE_IRDP,, IRDP )
fi
if test x"${enable_user}" = x"no"; then if test x"${enable_user}" = x"no"; then
enable_user="" enable_user=""
else else
@ -1479,17 +1475,27 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len,
dnl --------------------------- dnl ---------------------------
dnl IRDP/pktinfo/icmphdr checks dnl IRDP/pktinfo/icmphdr checks
dnl --------------------------- dnl ---------------------------
AC_CHECK_TYPES([struct in_pktinfo],
[AC_CHECK_TYPES([struct icmphdr], AC_CHECK_TYPES([struct in_pktinfo], [
[if test "${enable_irdp}" != "no"; then AC_CHECK_TYPES([struct icmphdr], [
AC_DEFINE(HAVE_IRDP,, IRDP) IRDP=true
fi], ], [
[if test "${enable_irdp}" = "yes"; then IRDP=false
AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!']) ], [FRR_INCLUDES])
fi], [FRR_INCLUDES])], ], [
[if test "${enable_irdp}" = "yes"; then IRDP=false
AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!']) ], [FRR_INCLUDES])
fi], [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 -----------------------
dnl checking for IP_PKTINFO dnl checking for IP_PKTINFO

View file

@ -138,7 +138,6 @@ struct Adv {
int pref; int pref;
}; };
extern void irdp_init(void);
extern void irdp_if_init(void); extern void irdp_if_init(void);
extern int irdp_sock_init(void); extern int irdp_sock_init(void);
extern int irdp_config_write(struct vty *, struct interface *); extern int irdp_config_write(struct vty *, struct interface *);

View file

@ -35,8 +35,6 @@
#include <zebra.h> #include <zebra.h>
#ifdef HAVE_IRDP
#include "if.h" #include "if.h"
#include "vty.h" #include "vty.h"
#include "sockunion.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_packet_cmd);
install_element(INTERFACE_NODE, &ip_irdp_debug_disable_cmd); install_element(INTERFACE_NODE, &ip_irdp_debug_disable_cmd);
} }
#endif /* HAVE_IRDP */

View file

@ -35,8 +35,6 @@
#include <zebra.h> #include <zebra.h>
#ifdef HAVE_IRDP
#include "if.h" #include "if.h"
#include "vty.h" #include "vty.h"
#include "sockunion.h" #include "sockunion.h"
@ -53,6 +51,7 @@
#include "thread.h" #include "thread.h"
#include "privs.h" #include "privs.h"
#include "libfrr.h" #include "libfrr.h"
#include "version.h"
#include "zebra/interface.h" #include "zebra/interface.h"
#include "zebra/rtadv.h" #include "zebra/rtadv.h"
#include "zebra/rib.h" #include "zebra/rib.h"
@ -341,11 +340,23 @@ static int irdp_finish(void)
return 0; return 0;
} }
void irdp_init(void) static int irdp_init(struct thread_master *master)
{ {
irdp_if_init(); irdp_if_init();
hook_register(frr_early_fini, irdp_finish); hook_register(frr_early_fini, irdp_finish);
return 0;
} }
#endif /* HAVE_IRDP */ static int irdp_module_init(void)
{
hook_register(frr_late_init, irdp_init);
return 0;
}
FRR_MODULE_SETUP(
.name = "zebra_irdp",
.version = FRR_VERSION,
.description = "zebra IRDP module",
.init = irdp_module_init,
)

View file

@ -36,8 +36,6 @@
#include <zebra.h> #include <zebra.h>
#ifdef HAVE_IRDP
#include "if.h" #include "if.h"
#include "vty.h" #include "vty.h"
#include "sockunion.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); */ /* printf("TX on %s idx %d\n", ifp->name, ifp->ifindex); */
} }
#endif /* HAVE_IRDP */

View file

@ -292,9 +292,6 @@ int main(int argc, char **argv)
#if defined(HAVE_RTADV) #if defined(HAVE_RTADV)
rtadv_cmd_init(); rtadv_cmd_init();
#endif #endif
#ifdef HAVE_IRDP
irdp_init();
#endif
/* PTM socket */ /* PTM socket */
#ifdef ZEBRA_PTM_SUPPORT #ifdef ZEBRA_PTM_SUPPORT
zebra_ptm_init(); zebra_ptm_init();

View file

@ -6,6 +6,9 @@ if ZEBRA
sbin_PROGRAMS += zebra/zebra sbin_PROGRAMS += zebra/zebra
dist_examples_DATA += zebra/zebra.conf.sample dist_examples_DATA += zebra/zebra.conf.sample
if IRDP
module_LTLIBRARIES += zebra/zebra_irdp.la
endif
if SNMP if SNMP
module_LTLIBRARIES += zebra/zebra_snmp.la module_LTLIBRARIES += zebra/zebra_snmp.la
endif endif
@ -30,9 +33,6 @@ zebra_zebra_SOURCES = \
zebra/ipforward_proc.c \ zebra/ipforward_proc.c \
zebra/ipforward_solaris.c \ zebra/ipforward_solaris.c \
zebra/ipforward_sysctl.c \ zebra/ipforward_sysctl.c \
zebra/irdp_interface.c \
zebra/irdp_main.c \
zebra/irdp_packet.c \
zebra/kernel_netlink.c \ zebra/kernel_netlink.c \
zebra/kernel_socket.c \ zebra/kernel_socket.c \
zebra/label_manager.c \ zebra/label_manager.c \
@ -106,6 +106,13 @@ noinst_HEADERS += \
zebra/zserv.h \ zebra/zserv.h \
# end # 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_SOURCES = zebra/zebra_snmp.c
zebra_zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) zebra_zebra_snmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS)
zebra_zebra_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic zebra_zebra_snmp_la_LDFLAGS = -avoid-version -module -shared -export-dynamic