Merge pull request #4500 from opensourcerouting/clippy-improve

clippy: batch of improvements
This commit is contained in:
Quentin Young 2019-06-13 15:06:24 -04:00 committed by GitHub
commit 42aac9b2ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 349 additions and 1577 deletions

View File

@ -40,6 +40,12 @@ shvar-%:
var-%: var-%:
@echo "$($*)" >&$(VARFD) @echo "$($*)" >&$(VARFD)
if ONLY_CLIPPY
.DEFAULT_GOAL := clippy-only
endif
clippy-only: Makefile lib/clippy config.h
.PHONY: clippy-only
# overwriting these vars breaks cross-compilation. let's be helpful and warn. # overwriting these vars breaks cross-compilation. let's be helpful and warn.
# #
# note: "#AUTODERP# " will be removed from Makefile by configure. These are # note: "#AUTODERP# " will be removed from Makefile by configure. These are

View File

@ -25,9 +25,25 @@ dnl -----------------------------------
AC_CANONICAL_BUILD() AC_CANONICAL_BUILD()
AC_CANONICAL_HOST() AC_CANONICAL_HOST()
AS_IF([test "$host" != "$build"], [ hosttools_clippy="false"
build_clippy="true"
dnl case 1: external clippy
if test -n "$with_clippy" -a "$with_clippy" != "no" -a "$with_clippy" != "yes"; then
if test "$enable_clippy_only" == "yes"; then
AC_MSG_ERROR([--enable-clippy-only does not make sense with --with-clippy])
fi
CLIPPY="$with_clippy"
build_clippy="false"
if test ! -x "$with_clippy"; then
AC_MSG_ERROR([clippy tool ($with_clippy) is not executable])
fi
dnl case 2: cross-compiling internal clippy
elif test "$host" != "$build"; then
if test "$srcdir" = "."; then if test "$srcdir" = "."; then
AC_MSG_ERROR([cross-compilation is only possible with builddir separate from srcdir. create a separate directory and run as .../path-to-frr/configure.]) AC_MSG_ERROR([cross-compilation is only possible with builddir separate from srcdir or by building clippy separately and using the --with-clippy option. create a separate directory and run as .../path-to-frr/configure.])
fi fi
test -d hosttools || mkdir hosttools test -d hosttools || mkdir hosttools
abssrc="`cd \"${srcdir}\"; pwd`" abssrc="`cd \"${srcdir}\"; pwd`"
@ -37,23 +53,47 @@ AS_IF([test "$host" != "$build"], [
AC_MSG_NOTICE([... use HOST_CPPFLAGS / HOST_CFLAGS / HOST_LDFLAGS if neccessary]) AC_MSG_NOTICE([... use HOST_CPPFLAGS / HOST_CFLAGS / HOST_LDFLAGS if neccessary])
AC_MSG_NOTICE([...]) AC_MSG_NOTICE([...])
( CPPFLAGS="$HOST_CPPFLAGS"; \ (
CFLAGS="$HOST_CFLAGS"; \ for var in $ac_precious_vars; do
LDFLAGS="$HOST_LDFLAGS"; \ dnl special cases
cd hosttools; "${abssrc}/configure" "--host=$build" "--build=$build" "--enable-clippy-only" "--disable-nhrpd" "--disable-vtysh"; ) case "$var" in
YACC|YFLAGS) continue;;
PYTHON*) retain=true;;
*) retain=false;
esac
eval "hostvar=\"\${HOST_$var}\""
eval "targetvar=\"\${$var}\""
if test -n "$hostvar"; then
eval "$var='$hostvar'"
_AS_ECHO_LOG([host $var='$hostvar'])
elif $retain; then
_AS_ECHO_LOG([host retain $var='$targetvar'])
else
eval "unset $var"
_AS_ECHO_LOG([host unset $var])
fi
done
cd hosttools
"${abssrc}/configure" "--host=$build" "--build=$build" "--enable-clippy-only" "--disable-nhrpd" "--disable-vtysh"
) || exit 1
AC_MSG_NOTICE([...]) AC_MSG_NOTICE([...])
AC_MSG_NOTICE([... cross-compilation: finished self-configuring for build platform tools]) AC_MSG_NOTICE([... cross-compilation: finished self-configuring for build platform tools])
AC_MSG_NOTICE([...]) AC_MSG_NOTICE([...])
build_clippy="false" build_clippy="false"
HOSTTOOLS="hosttools/" hosttools_clippy="true"
], [ CLIPPY="hosttools/lib/clippy"
build_clippy="true"
HOSTTOOLS="" dnl case 3: normal build internal clippy
]) else
AC_SUBST([HOSTTOOLS]) CLIPPY="lib/clippy\$(EXEEXT)"
fi
AC_SUBST([CLIPPY])
AM_CONDITIONAL([BUILD_CLIPPY], [$build_clippy]) AM_CONDITIONAL([BUILD_CLIPPY], [$build_clippy])
AM_CONDITIONAL([HOSTTOOLS_CLIPPY], [$hosttools_clippy])
AM_CONDITIONAL([ONLY_CLIPPY], [test "$enable_clippy_only" = "yes"])
# Disable portability warnings -- our automake code (in particular # Disable portability warnings -- our automake code (in particular
# common.am) uses some constructs specific to gmake. # common.am) uses some constructs specific to gmake.
@ -138,12 +178,11 @@ CXXFLAGS="$orig_cxxflags"
AC_PROG_CC_C99 AC_PROG_CC_C99
dnl NB: see C11 below dnl NB: see C11 below
AC_PROG_EGREP
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
dnl autoconf 2.59 appears not to support AC_PROG_SED dnl it's 2019, sed is sed.
dnl AC_PROG_SED SED=sed
AC_CHECK_PROG([SED],[sed],[sed],[/bin/false]) AC_SUBST([SED])
dnl try and enable CFLAGS that are useful for FRR dnl try and enable CFLAGS that are useful for FRR
dnl - specifically, options to control warnings dnl - specifically, options to control warnings
@ -328,7 +367,6 @@ dnl Check programs
dnl -------------- dnl --------------
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_LN_S AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_CHECK_TOOL([AR], [ar]) AC_CHECK_TOOL([AR], [ar])
dnl ------- dnl -------
@ -398,6 +436,8 @@ AC_ARG_WITH([pkg-extra-version],
AC_ARG_WITH([pkg-git-version], AC_ARG_WITH([pkg-git-version],
AS_HELP_STRING([--with-pkg-git-version], [add git information to MOTD and build version string]), AS_HELP_STRING([--with-pkg-git-version], [add git information to MOTD and build version string]),
[ test "x$withval" != "xno" && with_pkg_git_version="yes" ]) [ test "x$withval" != "xno" && with_pkg_git_version="yes" ])
AC_ARG_WITH([clippy],
AS_HELP_STRING([--with-clippy=PATH], [use external clippy helper program]))
AC_ARG_WITH([vtysh_pager], AC_ARG_WITH([vtysh_pager],
AS_HELP_STRING([--with-vtysh-pager=PAGER], [control what pager is compiled in as default]), AS_HELP_STRING([--with-vtysh-pager=PAGER], [control what pager is compiled in as default]),
VTYSH_PAGER=$withval, VTYSH_PAGER="more") VTYSH_PAGER=$withval, VTYSH_PAGER="more")
@ -603,8 +643,6 @@ if test "${enable_shell_access}" = "yes"; then
AC_DEFINE([HAVE_SHELL_ACCESS], [1], [Allow user to use ssh/telnet/bash, be aware this is considered insecure]) AC_DEFINE([HAVE_SHELL_ACCESS], [1], [Allow user to use ssh/telnet/bash, be aware this is considered insecure])
fi fi
AM_CONDITIONAL([FPM], [test "x$enable_fpm" = "xyes"])
# #
# Python for clippy # Python for clippy
# #
@ -634,31 +672,6 @@ FRR_PYTHON_MOD_EXEC([sphinx], [--version], [
]) ])
AC_SUBST([PYSPHINX]) AC_SUBST([PYSPHINX])
#
# Logic for protobuf support.
#
if test "$enable_protobuf" = "yes"; then
# Check for protoc & protoc-c
# protoc is not required, it's only for a "be nice" helper target
AC_CHECK_PROGS([PROTOC], [protoc], [/bin/false])
AC_CHECK_PROGS([PROTOC_C], [protoc-c], [/bin/false])
if test "$PROTOC_C" = "/bin/false"; then
AC_MSG_FAILURE([protobuf requested but protoc-c not found. Install protobuf-c.])
fi
PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c >= 0.14],, [
AC_MSG_FAILURE([protobuf requested but libprotobuf-c not found. Install protobuf-c.])
])
AC_CHECK_HEADER([google/protobuf-c/protobuf-c.h], [], [
AC_MSG_FAILURE([protobuf requested but protobuf-c.h not found. Install protobuf-c.])
])
AC_DEFINE([HAVE_PROTOBUF], [1], [protobuf])
fi
AM_CONDITIONAL([HAVE_PROTOBUF], [test "x$enable_protobuf" = "xyes"])
# #
# Logic for old vpn commands support. # Logic for old vpn commands support.
# #
@ -783,25 +796,11 @@ if test -n "$frr_cv_interp"; then
AC_DEFINE_UNQUOTED([INTERP], ["$frr_cv_interp"], [.interp value]) AC_DEFINE_UNQUOTED([INTERP], ["$frr_cv_interp"], [.interp value])
fi fi
dnl ------------------------------------
dnl Check C keywords and standard types
dnl ------------------------------------
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
AC_HEADER_STDC
dnl AC_TYPE_PID_T
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
dnl ------------------------- dnl -------------------------
dnl Check other header files. dnl Check other header files.
dnl ------------------------- dnl -------------------------
AC_CHECK_HEADERS([stropts.h sys/ksym.h \ AC_CHECK_HEADERS([stropts.h sys/ksym.h \
linux/version.h asm/types.h \ linux/version.h asm/types.h])
sys/cdefs.h])
ac_stdatomic_ok=false ac_stdatomic_ok=false
AC_DEFINE([FRR_AUTOCONF_ATOMIC], [1], [did autoconf checks for atomic funcs]) AC_DEFINE([FRR_AUTOCONF_ATOMIC], [1], [did autoconf checks for atomic funcs])
@ -988,7 +987,7 @@ FRR_INCLUDES
AC_CHECK_HEADERS([netinet/in_var.h \ AC_CHECK_HEADERS([netinet/in_var.h \
net/if_dl.h net/netopt.h \ net/if_dl.h net/netopt.h \
inet/nd.h netinet/ip_icmp.h \ inet/nd.h netinet/ip_icmp.h \
sys/sysctl.h sys/sockio.h kvm.h sys/conf.h], sys/sysctl.h sys/sockio.h sys/conf.h],
[], [], [FRR_INCLUDES]) [], [], [FRR_INCLUDES])
AC_CHECK_HEADERS([ucontext.h], [], [], AC_CHECK_HEADERS([ucontext.h], [], [],
@ -1108,7 +1107,48 @@ if test "${enable_realms}" = "yes"; then
;; ;;
esac esac
fi fi
AM_CONDITIONAL([SUPPORT_REALMS], [test "${enable_realms}" = "yes"])
dnl -------------------------------
dnl Endian-ness check
dnl -------------------------------
AC_WORDS_BIGENDIAN
dnl ---------------
dnl other functions
dnl ---------------
AC_CHECK_FUNCS([ \
strlcat strlcpy \
getgrouplist])
dnl ##########################################################################
dnl LARGE if block spans a lot of "configure"!
if test "${enable_clippy_only}" != "yes"; then
dnl ##########################################################################
#
# Logic for protobuf support.
#
if test "$enable_protobuf" = "yes"; then
# Check for protoc & protoc-c
# protoc is not required, it's only for a "be nice" helper target
AC_CHECK_PROGS([PROTOC], [protoc], [/bin/false])
AC_CHECK_PROGS([PROTOC_C], [protoc-c], [/bin/false])
if test "$PROTOC_C" = "/bin/false"; then
AC_MSG_FAILURE([protobuf requested but protoc-c not found. Install protobuf-c.])
fi
PKG_CHECK_MODULES([PROTOBUF_C], [libprotobuf-c >= 0.14],, [
AC_MSG_FAILURE([protobuf requested but libprotobuf-c not found. Install protobuf-c.])
])
AC_CHECK_HEADER([google/protobuf-c/protobuf-c.h], [], [
AC_MSG_FAILURE([protobuf requested but protobuf-c.h not found. Install protobuf-c.])
])
AC_DEFINE([HAVE_PROTOBUF], [1], [protobuf])
fi
dnl --------------------- dnl ---------------------
dnl Integrated VTY option dnl Integrated VTY option
@ -1157,7 +1197,6 @@ case "${enable_vtysh}" in
;; ;;
esac esac
AC_SUBST([LIBREADLINE]) AC_SUBST([LIBREADLINE])
AM_CONDITIONAL([VTYSH], test "x$VTYSH" = "xvtysh")
dnl ---------- dnl ----------
dnl PAM module dnl PAM module
@ -1219,43 +1258,17 @@ AC_CHECK_LIB([pam], [pam_start],
fi fi
AC_SUBST([LIBPAM]) AC_SUBST([LIBPAM])
dnl -------------------------------
dnl Endian-ness check
dnl -------------------------------
AC_WORDS_BIGENDIAN
dnl -------------------------------
dnl check the size in byte of the C
dnl -------------------------------
dnl AC_CHECK_SIZEOF(char)
dnl AC_CHECK_SIZEOF(int)
dnl AC_CHECK_SIZEOF(short)
dnl AC_CHECK_SIZEOF(long)
dnl ----------------------------
dnl check existance of functions
dnl ----------------------------
AC_FUNC_FNMATCH
AC_FUNC_FORK
AC_FUNC_MKTIME
AC_FUNC_STAT
dnl ------------------------------- dnl -------------------------------
dnl bgpd needs pow() and hence libm dnl bgpd needs pow() and hence libm
dnl ------------------------------- dnl -------------------------------
TMPLIBS="$LIBS" TMPLIBS="$LIBS"
AC_CHECK_HEADER([math.h], LIBS=""
[AC_CHECK_LIB([m], [pow], AC_SEARCH_LIBS([pow], [m], [
[LIBM="-lm" LIBM="$LIBS"
LIBS="$LIBS $LIBM" ], [
AC_CHECK_FUNCS(pow,[],[LIBM=""])
])
])
if test x"$LIBM" = x ; then
AC_MSG_WARN([Unable to find working pow function - bgpd may not link]) AC_MSG_WARN([Unable to find working pow function - bgpd may not link])
fi ])
LIBS="$TMPLIBS" LIBS="$TMPLIBS"
AC_SUBST([LIBM]) AC_SUBST([LIBM])
AC_CHECK_FUNCS([ppoll], [ AC_CHECK_FUNCS([ppoll], [
@ -1265,13 +1278,6 @@ AC_CHECK_FUNCS([pollts], [
AC_DEFINE([HAVE_POLLTS], [1], [have NetBSD pollts()]) AC_DEFINE([HAVE_POLLTS], [1], [have NetBSD pollts()])
]) ])
dnl ---------------
dnl other functions
dnl ---------------
AC_CHECK_FUNCS([ \
strlcat strlcpy \
getgrouplist])
AC_CHECK_HEADER([asm-generic/unistd.h], AC_CHECK_HEADER([asm-generic/unistd.h],
[AC_CHECK_DECL(__NR_setns, [AC_CHECK_DECL(__NR_setns,
AC_DEFINE([HAVE_NETNS], [1], [Have netns]),, AC_DEFINE([HAVE_NETNS], [1], [Have netns]),,
@ -1416,6 +1422,28 @@ if test $ac_cv_have_decl_TCP_MD5SIG = no; then
AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)]) AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)])
fi fi
AC_SUBST([SOLARIS])
AC_CHECK_LIB([crypt], [crypt], [],
[AC_CHECK_LIB([crypto], [DES_crypt])])
AC_CHECK_LIB([resolv], [res_init])
dnl ---------------------------
dnl check system has PCRE regexp
dnl ---------------------------
if test "x$enable_pcreposix" = "xyes"; then
AC_CHECK_LIB([pcreposix], [regexec], [], [
AC_MSG_ERROR([--enable-pcreposix given but unable to find libpcreposix])
])
fi
AC_SUBST([HAVE_LIBPCREPOSIX])
dnl ##########################################################################
dnl test "${enable_clippy_only}" != "yes"
fi
dnl END OF LARGE if block
dnl ##########################################################################
dnl ---------------------------------------------------------------------------- dnl ----------------------------------------------------------------------------
dnl figure out if domainname is available in the utsname struct (GNU extension). dnl figure out if domainname is available in the utsname struct (GNU extension).
dnl ---------------------------------------------------------------------------- dnl ----------------------------------------------------------------------------
@ -1448,18 +1476,6 @@ FRR_INCLUDES
dnl -------------------- dnl --------------------
dnl Daemon disable check dnl Daemon disable check
dnl -------------------- dnl --------------------
AM_CONDITIONAL([ZEBRA], [test "${enable_zebra}" != "no"])
if test "${enable_bgpd}" = "no";then
BGPD=""
else
BGPD="bgpd"
fi
AM_CONDITIONAL([BGPD], [test "x$BGPD" = "xbgpd"])
AM_CONDITIONAL([RIPD], [test "${enable_ripd}" != "no"])
AM_CONDITIONAL([OSPFD], [test "${enable_ospfd}" != "no"])
AM_CONDITIONAL([LDPD], [test "${enable_ldpd}" != "no"])
AS_IF([test "${enable_ldpd}" != "no"], [ AS_IF([test "${enable_ldpd}" != "no"], [
AC_DEFINE([HAVE_LDPD], [1], [ldpd]) AC_DEFINE([HAVE_LDPD], [1], [ldpd])
@ -1483,8 +1499,6 @@ else
esac esac
fi fi
AM_CONDITIONAL([BFDD], [test "x$BFDD" = "xbfdd"])
if test "$ac_cv_lib_json_c_json_object_get" = no -a "x$BFDD" = "xbfdd"; then if test "$ac_cv_lib_json_c_json_object_get" = no -a "x$BFDD" = "xbfdd"; then
AC_MSG_ERROR(["you must use json-c library to use bfdd"]) AC_MSG_ERROR(["you must use json-c library to use bfdd"])
fi fi
@ -1502,16 +1516,12 @@ case "$host_os" in
fi fi
;; ;;
esac esac
AM_CONDITIONAL([NHRPD], [test "x$NHRPD" = "xnhrpd"])
AM_CONDITIONAL([EIGRPD], [test "${enable_eigrpd}" != "no"])
if test "${enable_watchfrr}" = "no";then if test "${enable_watchfrr}" = "no";then
WATCHFRR="" WATCHFRR=""
else else
WATCHFRR="watchfrr" WATCHFRR="watchfrr"
fi fi
AM_CONDITIONAL([WATCHFRR], [test "x$WATCHFRR" = "xwatchfrr"])
OSPFCLIENT="" OSPFCLIENT=""
if test "${enable_ospfapi}" != "no";then if test "${enable_ospfapi}" != "no";then
@ -1522,18 +1532,6 @@ if test "${enable_ospfapi}" != "no";then
fi fi
fi fi
AM_CONDITIONAL([OSPFCLIENT], [test "x$OSPFCLIENT" = "xospfclient"])
AM_CONDITIONAL([RIPNGD], [test "${enable_ripngd}" != "no"])
AM_CONDITIONAL([BABELD], [test "${enable_babeld}" != "no"])
AM_CONDITIONAL([OSPF6D], [test "${enable_ospf6d}" != "no"])
AM_CONDITIONAL([ISISD], [test "${enable_isisd}" != "no"])
AM_CONDITIONAL([PIMD], [test "${enable_pimd}" != "no"])
AM_CONDITIONAL([PBRD], [test "${enable_pbrd}" != "no"])
AM_CONDITIONAL([SHARPD], [test "${enable_sharpd}" = "yes"])
AM_CONDITIONAL([STATICD], [test "${enable_staticd}" != "no"])
AM_CONDITIONAL([FABRICD], [test "${enable_fabricd}" != "no"])
AM_CONDITIONAL([VRRPD], [test "${enable_vrrpd}" != "no"])
if test "${enable_bgp_announce}" = "no";then if test "${enable_bgp_announce}" = "no";then
AC_DEFINE([DISABLE_BGP_ANNOUNCE], [1], [Disable BGP installation to zebra]) AC_DEFINE([DISABLE_BGP_ANNOUNCE], [1], [Disable BGP installation to zebra])
else else
@ -1543,22 +1541,11 @@ fi
if test "${enable_bgp_vnc}" != "no";then if test "${enable_bgp_vnc}" != "no";then
AC_DEFINE([ENABLE_BGP_VNC], [1], [Enable BGP VNC support]) AC_DEFINE([ENABLE_BGP_VNC], [1], [Enable BGP VNC support])
fi fi
AM_CONDITIONAL([ENABLE_BGP_VNC], [test x${enable_bgp_vnc} != xno])
AC_SUBST([SOLARIS]) dnl ##########################################################################
AC_CHECK_LIB([crypt], [crypt], [], dnl LARGE if block
[AC_CHECK_LIB([crypto], [DES_crypt])]) if test "${enable_clippy_only}" != "yes"; then
AC_CHECK_LIB([resolv], [res_init]) dnl ##########################################################################
dnl ---------------------------
dnl check system has PCRE regexp
dnl ---------------------------
if test "x$enable_pcreposix" = "xyes"; then
AC_CHECK_LIB([pcreposix], [regexec], [], [
AC_MSG_ERROR([--enable-pcreposix given but unable to find libpcreposix])
])
fi
AC_SUBST([HAVE_LIBPCREPOSIX])
dnl ------------------ dnl ------------------
dnl check C-Ares library dnl check C-Ares library
@ -1610,7 +1597,6 @@ int main(void);
AH_TEMPLATE([SNMP_AGENTX], [Use SNMP AgentX to interface with snmpd]) AH_TEMPLATE([SNMP_AGENTX], [Use SNMP AgentX to interface with snmpd])
AC_DEFINE_UNQUOTED(AS_TR_CPP(SNMP_${SNMP_METHOD}),,[SNMP method to interface with snmpd]) AC_DEFINE_UNQUOTED(AS_TR_CPP(SNMP_${SNMP_METHOD}),,[SNMP method to interface with snmpd])
fi fi
AM_CONDITIONAL([SNMP], [test "x${SNMP_METHOD}" != "x"])
AC_SUBST([SNMP_LIBS]) AC_SUBST([SNMP_LIBS])
AC_SUBST([SNMP_CFLAGS]) AC_SUBST([SNMP_CFLAGS])
@ -1643,7 +1629,6 @@ if test "$enable_config_rollbacks" = "yes"; then
AC_MSG_ERROR([--enable-config-rollbacks given but sqlite3 was not found on your system.]) AC_MSG_ERROR([--enable-config-rollbacks given but sqlite3 was not found on your system.])
]) ])
fi fi
AM_CONDITIONAL([SQLITE3], [$SQLITE3])
dnl --------------- dnl ---------------
dnl confd dnl confd
@ -1659,7 +1644,6 @@ if test "$enable_confd" != "" -a "$enable_confd" != "no"; then
AC_SUBST([CONFD_LIBS]) AC_SUBST([CONFD_LIBS])
AC_DEFINE([HAVE_CONFD], [1], [Enable confd integration]) AC_DEFINE([HAVE_CONFD], [1], [Enable confd integration])
fi fi
AM_CONDITIONAL([CONFD], [test "x$enable_confd" != "x"])
dnl --------------- dnl ---------------
dnl sysrepo dnl sysrepo
@ -1672,7 +1656,6 @@ if test "$enable_sysrepo" = "yes"; then
AC_MSG_ERROR([sysrepo was not found on your system.])] AC_MSG_ERROR([sysrepo was not found on your system.])]
) )
fi fi
AM_CONDITIONAL([SYSREPO], [test "x$enable_sysrepo" = "xyes"])
dnl --------------- dnl ---------------
dnl gRPC dnl gRPC
@ -1691,12 +1674,42 @@ if test "$enable_grpc" = "yes"; then
AC_MSG_ERROR([grpc/grpc++ were not found on your system.]) AC_MSG_ERROR([grpc/grpc++ were not found on your system.])
]) ])
fi fi
AM_CONDITIONAL([GRPC], [test "x$enable_grpc" = "xyes"])
dnl --------------- dnl ------
dnl math dnl ZeroMQ
dnl --------------- dnl ------
AC_SEARCH_LIBS([sqrt], [m]) if test "x$enable_zeromq" != "xno"; then
PKG_CHECK_MODULES([ZEROMQ], [libzmq >= 4.0.0], [
AC_DEFINE([HAVE_ZEROMQ], [1], [Enable ZeroMQ support])
ZEROMQ=true
], [
if test "x$enable_zeromq" = "xyes"; then
AC_MSG_ERROR([configuration specifies --enable-zeromq but libzmq was not found])
fi
])
fi
dnl ------------------------------------
dnl Enable RPKI and add librtr to libs
dnl ------------------------------------
if test "${enable_rpki}" = "yes"; then
PKG_CHECK_MODULES([RTRLIB], [rtrlib >= 0.5.0],
[RPKI=true],
[RPKI=false
AC_MSG_ERROR([rtrlib was not found on your system or is too old.])]
)
fi
dnl ------------------------------------------
dnl Check whether rtrlib was build with ssh support
dnl ------------------------------------------
AC_MSG_CHECKING([whether the RTR Library is compiled with SSH])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "rtrlib/rtrlib.h"]],
[[struct tr_ssh_config config;]])],
[AC_MSG_RESULT([yes])
AC_DEFINE([FOUND_SSH], [1], [found_ssh])],
AC_MSG_RESULT([no])
)
dnl --------------- dnl ---------------
dnl dlopen & dlinfo dnl dlopen & dlinfo
@ -1747,7 +1760,11 @@ if test "$frr_cv_rtld_di_linkmap" = yes; then
AC_DEFINE([HAVE_DLINFO_LINKMAP], [1], [Have dlinfo RTLD_DI_LINKMAP]) AC_DEFINE([HAVE_DLINFO_LINKMAP], [1], [Have dlinfo RTLD_DI_LINKMAP])
fi fi
AM_CONDITIONAL([SNMP], [test "x$SNMP_METHOD" = "xagentx"]) dnl ##########################################################################
dnl test "${enable_clippy_only}" != "yes"
fi
dnl END OF LARGE if block
dnl ##########################################################################
dnl --------------------------- dnl ---------------------------
dnl sockaddr and netinet checks dnl sockaddr and netinet checks
@ -1757,7 +1774,7 @@ AC_CHECK_TYPES([
struct vifctl, struct mfcctl, struct sioc_sg_req, struct vifctl, struct mfcctl, struct sioc_sg_req,
vifi_t, struct sioc_vif_req, struct igmpmsg, vifi_t, struct sioc_vif_req, struct igmpmsg,
struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq, struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq,
struct nd_opt_adv_interval, struct rt_addrinfo, struct nd_opt_adv_interval,
struct nd_opt_homeagent_info, struct nd_opt_adv_interval, struct nd_opt_homeagent_info, struct nd_opt_adv_interval,
struct nd_opt_rdnss, struct nd_opt_dnssl], struct nd_opt_rdnss, struct nd_opt_dnssl],
[], [], FRR_INCLUDES) [], [], FRR_INCLUDES)
@ -1792,7 +1809,6 @@ no)
;; ;;
esac esac
AM_CONDITIONAL([IRDP], [$IRDP])
dnl ----------------------- dnl -----------------------
dnl checking for IP_PKTINFO dnl checking for IP_PKTINFO
@ -1899,7 +1915,7 @@ AC_MSG_CHECKING([version of bison])
frr_ac_bison_version="$(eval $YACC -V | grep bison | head -n 1)" frr_ac_bison_version="$(eval $YACC -V | grep bison | head -n 1)"
frr_ac_bison_version="${frr_ac_bison_version##* }" frr_ac_bison_version="${frr_ac_bison_version##* }"
frr_ac_bison_missing="false" frr_ac_bison_missing="false"
case "x${frr_ac_bison_version}" in case "x${frr_ac_bison_version}x" in
x2.7*) x2.7*)
BISON_OPENBRACE='"' BISON_OPENBRACE='"'
BISON_CLOSEBRACE='"' BISON_CLOSEBRACE='"'
@ -1916,11 +1932,17 @@ case "x${frr_ac_bison_version}" in
AC_MSG_WARN([could not determine bison version. Please install GNU bison 2.7.x or newer.]) AC_MSG_WARN([could not determine bison version. Please install GNU bison 2.7.x or newer.])
frr_ac_bison_missing="true" frr_ac_bison_missing="true"
;; ;;
*) x3.[012][^0-9]*)
BISON_OPENBRACE='{' BISON_OPENBRACE='{'
BISON_CLOSEBRACE='}' BISON_CLOSEBRACE='}'
BISON_VERBOSE='-Dparse.error=verbose' BISON_VERBOSE='-Dparse.error=verbose'
AC_MSG_RESULT([$frr_ac_bison_version - 3.0 or newer]) AC_MSG_RESULT([$frr_ac_bison_version - 3.0 to 3.2])
;;
*)
BISON_OPENBRACE='{'
BISON_CLOSEBRACE='}'
BISON_VERBOSE='-Dparse.error=verbose -Wno-yacc'
AC_MSG_RESULT([$frr_ac_bison_version - 3.3 or newer])
;; ;;
esac esac
AC_SUBST([BISON_OPENBRACE]) AC_SUBST([BISON_OPENBRACE])
@ -2074,21 +2096,6 @@ size_t ac_x; ac_x = malloc_size(NULL);
]) ])
]) ])
dnl ------
dnl ZeroMQ
dnl ------
if test "x$enable_zeromq" != "xno"; then
PKG_CHECK_MODULES([ZEROMQ], [libzmq >= 4.0.0], [
AC_DEFINE([HAVE_ZEROMQ], [1], [Enable ZeroMQ support])
ZEROMQ=true
], [
if test "x$enable_zeromq" = "xyes"; then
AC_MSG_ERROR([configuration specifies --enable-zeromq but libzmq was not found])
fi
])
fi
AM_CONDITIONAL([ZEROMQ], [test "x$ZEROMQ" = "xtrue"])
dnl ---------- dnl ----------
dnl configure date dnl configure date
dnl ---------- dnl ----------
@ -2174,39 +2181,43 @@ AC_DEFINE_UNQUOTED([YANG_MODELS_PATH], ["$CFG_YANGMODELS"], [path to YANG data m
AC_DEFINE_UNQUOTED([LIBYANG_PLUGINS_PATH], ["$CFG_LIBYANG_PLUGINS"], [path to libyang plugins]) AC_DEFINE_UNQUOTED([LIBYANG_PLUGINS_PATH], ["$CFG_LIBYANG_PLUGINS"], [path to libyang plugins])
AC_DEFINE_UNQUOTED([WATCHFRR_SH_PATH], ["${CFG_SBIN%/}/watchfrr.sh"], [path to watchfrr.sh]) AC_DEFINE_UNQUOTED([WATCHFRR_SH_PATH], ["${CFG_SBIN%/}/watchfrr.sh"], [path to watchfrr.sh])
dnl ------------------------------------ dnl various features
dnl Enable RPKI and add librtr to libs AM_CONDITIONAL([SUPPORT_REALMS], [test "${enable_realms}" = "yes"])
dnl ------------------------------------ AM_CONDITIONAL([ENABLE_BGP_VNC], [test x${enable_bgp_vnc} != xno])
if test "${enable_rpki}" = "yes"; then dnl northbound
PKG_CHECK_MODULES([RTRLIB], [rtrlib >= 0.5.0], AM_CONDITIONAL([SQLITE3], [$SQLITE3])
[RPKI=true], AM_CONDITIONAL([CONFD], [test "x$enable_confd" != "x"])
[RPKI=false AM_CONDITIONAL([SYSREPO], [test "x$enable_sysrepo" = "xyes"])
AC_MSG_ERROR([rtrlib was not found on your system or is too old.])] AM_CONDITIONAL([GRPC], [test "x$enable_grpc" = "xyes"])
) AM_CONDITIONAL([ZEROMQ], [test "x$ZEROMQ" = "xtrue"])
fi dnl plugins
AM_CONDITIONAL([RPKI], [test "x$RPKI" = "xtrue"]) AM_CONDITIONAL([RPKI], [test "x$RPKI" = "xtrue"])
AM_CONDITIONAL([SNMP], [test "x$SNMP_METHOD" = "xagentx"])
dnl ------------------------------------------ AM_CONDITIONAL([IRDP], [$IRDP])
dnl Check whether rtrlib was build with ssh support AM_CONDITIONAL([FPM], [test "x$enable_fpm" = "xyes"])
dnl ------------------------------------------ AM_CONDITIONAL([HAVE_PROTOBUF], [test "x$enable_protobuf" = "xyes"])
AC_MSG_CHECKING([whether the RTR Library is compiled with SSH]) dnl daemons
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "rtrlib/rtrlib.h"]], AM_CONDITIONAL([VTYSH], [test "x$VTYSH" = "xvtysh"])
[[struct tr_ssh_config config;]])], AM_CONDITIONAL([ZEBRA], [test "${enable_zebra}" != "no"])
[AC_MSG_RESULT([yes]) AM_CONDITIONAL([BGPD], [test "x${enable_bgpd}" != "no"])
AC_DEFINE([FOUND_SSH], [1], [found_ssh])], AM_CONDITIONAL([RIPD], [test "${enable_ripd}" != "no"])
AC_MSG_RESULT([no]) AM_CONDITIONAL([OSPFD], [test "${enable_ospfd}" != "no"])
) AM_CONDITIONAL([LDPD], [test "${enable_ldpd}" != "no"])
AM_CONDITIONAL([BFDD], [test "x$BFDD" = "xbfdd"])
dnl --------------------------- AM_CONDITIONAL([NHRPD], [test "x$NHRPD" = "xnhrpd"])
dnl Check htonl works correctly AM_CONDITIONAL([EIGRPD], [test "${enable_eigrpd}" != "no"])
dnl --------------------------- AM_CONDITIONAL([WATCHFRR], [test "x$WATCHFRR" = "xwatchfrr"])
AC_MSG_CHECKING([for working htonl]) AM_CONDITIONAL([OSPFCLIENT], [test "x$OSPFCLIENT" = "xospfclient"])
AC_CACHE_VAL(ac_cv_htonl_works, AM_CONDITIONAL([RIPNGD], [test "${enable_ripngd}" != "no"])
[AC_LINK_IFELSE([AC_LANG_PROGRAM([FRR_INCLUDES],[htonl (0);])], AM_CONDITIONAL([BABELD], [test "${enable_babeld}" != "no"])
[ac_cv_htonl_works=yes], [ac_cv_htonl_works=no]) AM_CONDITIONAL([OSPF6D], [test "${enable_ospf6d}" != "no"])
] AM_CONDITIONAL([ISISD], [test "${enable_isisd}" != "no"])
) AM_CONDITIONAL([PIMD], [test "${enable_pimd}" != "no"])
AC_MSG_RESULT([$ac_cv_htonl_works]) AM_CONDITIONAL([PBRD], [test "${enable_pbrd}" != "no"])
AM_CONDITIONAL([SHARPD], [test "${enable_sharpd}" = "yes"])
AM_CONDITIONAL([STATICD], [test "${enable_staticd}" != "no"])
AM_CONDITIONAL([FABRICD], [test "${enable_fabricd}" != "no"])
AM_CONDITIONAL([VRRPD], [test "${enable_vrrpd}" != "no"])
AC_CONFIG_FILES([Makefile],[sed -e 's/^#AUTODERP# //' -i Makefile]) AC_CONFIG_FILES([Makefile],[sed -e 's/^#AUTODERP# //' -i Makefile])

View File

@ -85,8 +85,6 @@ int main(int argc, char **argv)
if (PyRun_AnyFile(fp, pyfile)) { if (PyRun_AnyFile(fp, pyfile)) {
if (PyErr_Occurred()) if (PyErr_Occurred())
PyErr_Print(); PyErr_Print();
else
printf("unknown python failure (?)\n");
return 1; return 1;
} }
Py_Finalize(); Py_Finalize();

View File

@ -163,7 +163,7 @@ static int yylex_clr(char **retbuf)
return rv; return rv;
} }
static PyObject *get_args(void) static PyObject *get_args(const char *filename, int lineno)
{ {
PyObject *pyObj = PyList_New(0); PyObject *pyObj = PyList_New(0);
PyObject *pyArg = NULL; PyObject *pyArg = NULL;
@ -190,6 +190,13 @@ static PyObject *get_args(void)
free(tval); free(tval);
continue; continue;
} }
if (token == PREPROC) {
free(tval);
Py_DECREF(pyObj);
return PyErr_Format(PyExc_ValueError,
"%s:%d: cannot process CPP directive within argument list",
filename, lineno);
}
if (token == SPECIAL) { if (token == SPECIAL) {
if (depth == 1 && (tval[0] == ',' || tval[0] == ')')) { if (depth == 1 && (tval[0] == ',' || tval[0] == ')')) {
if (pyArg) if (pyArg)
@ -244,7 +251,12 @@ PyObject *clippy_parse(PyObject *self, PyObject *args)
case DEFUNNY: case DEFUNNY:
case INSTALL: case INSTALL:
case AUXILIARY: case AUXILIARY:
pyArgs = get_args(); pyArgs = get_args(filename, lineno);
if (!pyArgs) {
free(tval);
Py_DECREF(pyCont);
return NULL;
}
pyItem = PyDict_New(); pyItem = PyDict_New();
PyDict_SetItemString(pyItem, "type", PyUnicode_FromString(tval)); PyDict_SetItemString(pyItem, "type", PyUnicode_FromString(tval));
PyDict_SetItemString(pyItem, "args", pyArgs); PyDict_SetItemString(pyItem, "args", pyArgs);
@ -260,6 +272,7 @@ PyObject *clippy_parse(PyObject *self, PyObject *args)
pyItem = PyDict_New(); pyItem = PyDict_New();
PyDict_SetItemString(pyItem, "type", PyUnicode_FromString("PREPROC")); PyDict_SetItemString(pyItem, "type", PyUnicode_FromString("PREPROC"));
PyDict_SetItemString(pyItem, "line", PyUnicode_FromString(tval)); PyDict_SetItemString(pyItem, "line", PyUnicode_FromString(tval));
lineno--;
break; break;
} }
if (pyItem) { if (pyItem) {

View File

@ -3,7 +3,7 @@
# #
lib_LTLIBRARIES += lib/libfrr.la lib_LTLIBRARIES += lib/libfrr.la
lib_libfrr_la_LDFLAGS = -version-info 0:0:0 -Xlinker -e_libfrr_version lib_libfrr_la_LDFLAGS = -version-info 0:0:0 -Xlinker -e_libfrr_version
lib_libfrr_la_LIBADD = $(LIBCAP) $(UNWIND_LIBS) $(LIBYANG_LIBS) $(LUA_LIB) lib_libfrr_la_LIBADD = $(LIBCAP) $(UNWIND_LIBS) $(LIBYANG_LIBS) $(LUA_LIB) $(LIBM)
lib_libfrr_la_SOURCES = \ lib_libfrr_la_SOURCES = \
lib/agg_table.c \ lib/agg_table.c \
@ -340,8 +340,10 @@ noinst_PROGRAMS += \
if BUILD_CLIPPY if BUILD_CLIPPY
noinst_PROGRAMS += lib/clippy noinst_PROGRAMS += lib/clippy
else else
$(HOSTTOOLS)lib/clippy: if HOSTTOOLS_CLIPPY
@$(MAKE) -C $(top_builddir)/$(HOSTTOOLS) lib/route_types.h lib/clippy $(CLIPPY):
@$(MAKE) -C $(top_builddir)/hosttools lib/route_types.h lib/clippy
endif
endif endif
lib_grammar_sandbox_SOURCES = \ lib_grammar_sandbox_SOURCES = \
@ -372,13 +374,11 @@ am__v_CLIPPY_ = $(am__v_CLIPPY_$(AM_DEFAULT_VERBOSITY))
am__v_CLIPPY_0 = @echo " CLIPPY " $@; am__v_CLIPPY_0 = @echo " CLIPPY " $@;
am__v_CLIPPY_1 = am__v_CLIPPY_1 =
CLIPPY_DEPS = $(HOSTTOOLS)lib/clippy $(top_srcdir)/python/clidef.py CLIPPY_DEPS = $(CLIPPY) $(top_srcdir)/python/clidef.py
SUFFIXES = _clippy.c .proto .pb-c.c .pb-c.h .pb.h .pb.cc .grpc.pb.cc SUFFIXES = _clippy.c .proto .pb-c.c .pb-c.h .pb.h .pb.cc .grpc.pb.cc
.c_clippy.c: .c_clippy.c:
@{ test -x $(top_builddir)/$(HOSTTOOLS)lib/clippy || \ $(AM_V_CLIPPY) $(CLIPPY) $(top_srcdir)/python/clidef.py -o $@ $<
$(MAKE) -C $(top_builddir)/$(HOSTTOOLS) lib/clippy; }
$(AM_V_CLIPPY) $(top_builddir)/$(HOSTTOOLS)lib/clippy $(top_srcdir)/python/clidef.py -o $@ $<
## automake's "ylwrap" is a great piece of GNU software... not. ## automake's "ylwrap" is a great piece of GNU software... not.
.l.c: .l.c:

View File

@ -8717,9 +8717,6 @@ DEFUN (no_ip_pim_ucast_bsm,
#if HAVE_BFDD > 0 #if HAVE_BFDD > 0
DEFUN_HIDDEN( DEFUN_HIDDEN(
#else
DEFUN(
#endif /* HAVE_BFDD */
ip_pim_bfd_param, ip_pim_bfd_param,
ip_pim_bfd_param_cmd, ip_pim_bfd_param_cmd,
"ip pim bfd (2-255) (50-60000) (50-60000)", "ip pim bfd (2-255) (50-60000) (50-60000)",
@ -8729,6 +8726,18 @@ DEFUN(
"Detect Multiplier\n" "Detect Multiplier\n"
"Required min receive interval\n" "Required min receive interval\n"
"Desired min transmit interval\n") "Desired min transmit interval\n")
#else
DEFUN(
ip_pim_bfd_param,
ip_pim_bfd_param_cmd,
"ip pim bfd (2-255) (50-60000) (50-60000)",
IP_STR
PIM_STR
"Enables BFD support\n"
"Detect Multiplier\n"
"Required min receive interval\n"
"Desired min transmit interval\n")
#endif /* HAVE_BFDD */
{ {
VTY_DECLVAR_CONTEXT(interface, ifp); VTY_DECLVAR_CONTEXT(interface, ifp);
int idx_number = 3; int idx_number = 3;

View File

@ -37,6 +37,7 @@ class RenderHandler(object):
deref = '' deref = ''
drop_str = False drop_str = False
canfail = True canfail = True
canassert = False
class StringHandler(RenderHandler): class StringHandler(RenderHandler):
argtype = 'const char *' argtype = 'const char *'
@ -44,6 +45,7 @@ class StringHandler(RenderHandler):
code = Template('$varname = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg;') code = Template('$varname = (argv[_i]->type == WORD_TKN) ? argv[_i]->text : argv[_i]->arg;')
drop_str = True drop_str = True
canfail = False canfail = False
canassert = True
class LongHandler(RenderHandler): class LongHandler(RenderHandler):
argtype = 'long' argtype = 'long'
@ -111,6 +113,7 @@ if (argv[_i]->text[0] == 'X') {
_fail = !inet_aton(argv[_i]->arg, &s__$varname.sin.sin_addr); _fail = !inet_aton(argv[_i]->arg, &s__$varname.sin.sin_addr);
$varname = &s__$varname; $varname = &s__$varname;
}''') }''')
canassert = True
def mix_handlers(handlers): def mix_handlers(handlers):
def combine(a, b): def combine(a, b):
@ -171,6 +174,7 @@ $argblocks
return CMD_WARNING; return CMD_WARNING;
#endif #endif
#endif #endif
$argassert
return ${fnname}_magic(self, vty, argc, argv$arglist); return ${fnname}_magic(self, vty, argc, argv$arglist);
} }
@ -182,16 +186,72 @@ argblock = Template('''
$code $code
}''') }''')
def process_file(fn, ofd, dumpfd, all_defun): def get_always_args(token, always_args, args = [], stack = []):
if token in stack:
return
if token.type == 'END_TKN':
for arg in list(always_args):
if arg not in args:
always_args.remove(arg)
return
stack = stack + [token]
if token.type in handlers and token.varname is not None:
args = args + [token.varname]
for nexttkn in token.next():
get_always_args(nexttkn, always_args, args, stack)
class Macros(dict):
def load(self, filename):
filedata = clippy.parse(filename)
for entry in filedata['data']:
if entry['type'] != 'PREPROC':
continue
ppdir = entry['line'].lstrip().split(None, 1)
if ppdir[0] != 'define' or len(ppdir) != 2:
continue
ppdef = ppdir[1].split(None, 1)
name = ppdef[0]
if '(' in name:
continue
val = ppdef[1] if len(ppdef) == 2 else ''
val = val.strip(' \t\n\\')
if name in self:
sys.stderr.write('warning: macro %s redefined!\n' % (name))
self[name] = val
def process_file(fn, ofd, dumpfd, all_defun, macros):
errors = 0
filedata = clippy.parse(fn) filedata = clippy.parse(fn)
for entry in filedata['data']: for entry in filedata['data']:
if entry['type'].startswith('DEFPY') or (all_defun and entry['type'].startswith('DEFUN')): if entry['type'].startswith('DEFPY') or (all_defun and entry['type'].startswith('DEFUN')):
if len(entry['args'][0]) != 1:
sys.stderr.write('%s:%d: DEFPY function name not parseable (%r)\n' % (fn, entry['lineno'], entry['args'][0]))
errors += 1
continue
cmddef = entry['args'][2] cmddef = entry['args'][2]
cmddef = ''.join([i[1:-1] for i in cmddef]) cmddefx = []
for i in cmddef:
while i in macros:
i = macros[i]
if i.startswith('"') and i.endswith('"'):
cmddefx.append(i[1:-1])
continue
sys.stderr.write('%s:%d: DEFPY command string not parseable (%r)\n' % (fn, entry['lineno'], cmddef))
errors += 1
cmddefx = None
break
if cmddefx is None:
continue
cmddef = ''.join([i for i in cmddefx])
graph = clippy.Graph(cmddef) graph = clippy.Graph(cmddef)
args = OrderedDict() args = OrderedDict()
always_args = set()
for token, depth in clippy.graph_iterate(graph): for token, depth in clippy.graph_iterate(graph):
if token.type not in handlers: if token.type not in handlers:
continue continue
@ -199,6 +259,9 @@ def process_file(fn, ofd, dumpfd, all_defun):
continue continue
arg = args.setdefault(token.varname, []) arg = args.setdefault(token.varname, [])
arg.append(handlers[token.type](token)) arg.append(handlers[token.type](token))
always_args.add(token.varname)
get_always_args(graph.first(), always_args)
#print('-' * 76) #print('-' * 76)
#pprint(entry) #pprint(entry)
@ -210,30 +273,36 @@ def process_file(fn, ofd, dumpfd, all_defun):
argdecls = [] argdecls = []
arglist = [] arglist = []
argblocks = [] argblocks = []
argassert = []
doc = [] doc = []
canfail = 0 canfail = 0
def do_add(handler, varname, attr = ''): def do_add(handler, basename, varname, attr = ''):
argdefs.append(',\\\n\t%s %s%s' % (handler.argtype, varname, attr)) argdefs.append(',\\\n\t%s %s%s' % (handler.argtype, varname, attr))
argdecls.append('\t%s\n' % (handler.decl.substitute({'varname': varname}).replace('\n', '\n\t'))) argdecls.append('\t%s\n' % (handler.decl.substitute({'varname': varname}).replace('\n', '\n\t')))
arglist.append(', %s%s' % (handler.deref, varname)) arglist.append(', %s%s' % (handler.deref, varname))
if basename in always_args and handler.canassert:
argassert.append('''\tif (!%s) {
\t\tvty_out(vty, "Internal CLI error [%%s]\\n", "%s");
\t\treturn CMD_WARNING;
\t}\n''' % (varname, varname))
if attr == '': if attr == '':
at = handler.argtype at = handler.argtype
if not at.startswith('const '): if not at.startswith('const '):
at = '. . . ' + at at = '. . . ' + at
doc.append('\t%-26s %s' % (at, varname)) doc.append('\t%-26s %s %s' % (at, 'alw' if basename in always_args else 'opt', varname))
for varname in args.keys(): for varname in args.keys():
handler = mix_handlers(args[varname]) handler = mix_handlers(args[varname])
#print(varname, handler) #print(varname, handler)
if handler is None: continue if handler is None: continue
do_add(handler, varname) do_add(handler, varname, varname)
code = handler.code.substitute({'varname': varname}).replace('\n', '\n\t\t\t') code = handler.code.substitute({'varname': varname}).replace('\n', '\n\t\t\t')
if handler.canfail: if handler.canfail:
canfail = 1 canfail = 1
strblock = '' strblock = ''
if not handler.drop_str: if not handler.drop_str:
do_add(StringHandler(None), '%s_str' % (varname), ' __attribute__ ((unused))') do_add(StringHandler(None), varname, '%s_str' % (varname), ' __attribute__ ((unused))')
strblock = '\n\t\t\t%s_str = argv[_i]->arg;' % (varname) strblock = '\n\t\t\t%s_str = argv[_i]->arg;' % (varname)
argblocks.append(argblock.substitute({'varname': varname, 'strblock': strblock, 'code': code})) argblocks.append(argblock.substitute({'varname': varname, 'strblock': strblock, 'code': code}))
@ -249,8 +318,11 @@ def process_file(fn, ofd, dumpfd, all_defun):
params['argblocks'] = ''.join(argblocks) params['argblocks'] = ''.join(argblocks)
params['canfail'] = canfail params['canfail'] = canfail
params['nonempty'] = len(argblocks) params['nonempty'] = len(argblocks)
params['argassert'] = ''.join(argassert)
ofd.write(templ.substitute(params)) ofd.write(templ.substitute(params))
return errors
if __name__ == '__main__': if __name__ == '__main__':
import argparse import argparse
@ -274,7 +346,15 @@ if __name__ == '__main__':
if args.show: if args.show:
dumpfd = sys.stderr dumpfd = sys.stderr
process_file(args.cfile, ofd, dumpfd, args.all_defun) macros = Macros()
macros.load('lib/route_types.h')
macros.load('lib/command.h')
# sigh :(
macros['PROTO_REDIST_STR'] = 'FRR_REDIST_STR_ISISD'
errors = process_file(args.cfile, ofd, dumpfd, args.all_defun, macros)
if errors != 0:
sys.exit(1)
if args.o is not None: if args.o is not None:
clippy.wrdiff(args.o, ofd, [args.cfile, os.path.realpath(__file__), sys.executable]) clippy.wrdiff(args.o, ofd, [args.cfile, os.path.realpath(__file__), sys.executable])

File diff suppressed because it is too large Load Diff

View File

@ -2172,7 +2172,7 @@ DEFPY (show_evpn_mac_vni_all_dad,
DEFPY (show_evpn_mac_vni_dad, DEFPY (show_evpn_mac_vni_dad,
show_evpn_mac_vni_dad_cmd, show_evpn_mac_vni_dad_cmd,
"show evpn mac vni " CMD_VNI_RANGE " duplicate" "[json]", "show evpn mac vni " CMD_VNI_RANGE " duplicate [json]",
SHOW_STR SHOW_STR
"EVPN\n" "EVPN\n"
"MAC addresses\n" "MAC addresses\n"
@ -2182,10 +2182,8 @@ DEFPY (show_evpn_mac_vni_dad,
JSON_STR) JSON_STR)
{ {
struct zebra_vrf *zvrf; struct zebra_vrf *zvrf;
vni_t vni;
bool uj = use_json(argc, argv); bool uj = use_json(argc, argv);
vni = strtoul(argv[4]->arg, NULL, 10);
zvrf = zebra_vrf_get_evpn(); zvrf = zebra_vrf_get_evpn();
zebra_vxlan_print_macs_vni_dad(vty, zvrf, vni, uj); zebra_vxlan_print_macs_vni_dad(vty, zvrf, vni, uj);
@ -2195,7 +2193,7 @@ DEFPY (show_evpn_mac_vni_dad,
DEFPY (show_evpn_neigh_vni_dad, DEFPY (show_evpn_neigh_vni_dad,
show_evpn_neigh_vni_dad_cmd, show_evpn_neigh_vni_dad_cmd,
"show evpn arp-cache vni " CMD_VNI_RANGE "duplicate" "[json]", "show evpn arp-cache vni " CMD_VNI_RANGE "duplicate [json]",
SHOW_STR SHOW_STR
"EVPN\n" "EVPN\n"
"ARP and ND cache\n" "ARP and ND cache\n"
@ -2205,10 +2203,8 @@ DEFPY (show_evpn_neigh_vni_dad,
JSON_STR) JSON_STR)
{ {
struct zebra_vrf *zvrf; struct zebra_vrf *zvrf;
vni_t vni;
bool uj = use_json(argc, argv); bool uj = use_json(argc, argv);
vni = strtoul(argv[4]->arg, NULL, 10);
zvrf = zebra_vrf_get_evpn(); zvrf = zebra_vrf_get_evpn();
zebra_vxlan_print_neigh_vni_dad(vty, zvrf, vni, uj); zebra_vxlan_print_neigh_vni_dad(vty, zvrf, vni, uj);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -2387,7 +2383,7 @@ DEFUN (show_pbr_iptable,
DEFPY (clear_evpn_dup_addr, DEFPY (clear_evpn_dup_addr,
clear_evpn_dup_addr_cmd, clear_evpn_dup_addr_cmd,
"clear evpn dup-addr vni <all$vni_all |" CMD_VNI_RANGE"$vni_val [mac M:A:C$mac_val | ip <A.B.C.D|X:X::X:X>]>", "clear evpn dup-addr vni <all$vni_all |" CMD_VNI_RANGE"$vni [mac M:A:C$mac_val | ip <A.B.C.D|X:X::X:X>]>",
CLEAR_STR CLEAR_STR
"EVPN\n" "EVPN\n"
"Duplicate address \n" "Duplicate address \n"
@ -2401,15 +2397,12 @@ DEFPY (clear_evpn_dup_addr,
"IPv6 address\n") "IPv6 address\n")
{ {
struct zebra_vrf *zvrf; struct zebra_vrf *zvrf;
vni_t vni = 0;
struct ipaddr host_ip = {.ipa_type = IPADDR_NONE }; struct ipaddr host_ip = {.ipa_type = IPADDR_NONE };
struct ethaddr mac_addr; struct ethaddr mac_addr;
int ret = CMD_SUCCESS; int ret = CMD_SUCCESS;
zvrf = zebra_vrf_get_evpn(); zvrf = zebra_vrf_get_evpn();
if (vni_val) { if (vni_str) {
vni = strtoul(vni_val, NULL, 10);
if (mac_val) { if (mac_val) {
prefix_str2mac(mac_val, &mac_addr); prefix_str2mac(mac_val, &mac_addr);
ret = zebra_vxlan_clear_dup_detect_vni_mac(vty, zvrf, ret = zebra_vxlan_clear_dup_detect_vni_mac(vty, zvrf,