Merge pull request #8545 from opensourcerouting/assert-our-own

*: make our own assert() actually work
This commit is contained in:
Mark Stapp 2021-05-03 11:17:36 -04:00 committed by GitHub
commit f71e1ff6a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
111 changed files with 718 additions and 238 deletions

View file

@ -11,11 +11,19 @@ AM_CFLAGS = \
$(SAN_FLAGS) \
$(WERROR) \
# end
AM_CPPFLAGS = \
# CPPFLAGS_BASE does not contain the include path for overriding assert.h,
# therefore should be used in tools that do *not* link libfrr or do not want
# assert() overridden
CPPFLAGS_BASE = \
-I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/lib \
-I$(top_builddir) \
$(LUA_INCLUDE) \
# end
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/assert \
$(CPPFLAGS_BASE) \
# end
AM_LDFLAGS = \
-export-dynamic \
$(AC_LDFLAGS) \

View file

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "bgpd/bgp_conditional_adv.h"
#include "bgpd/bgp_vty.h"

View file

@ -32,7 +32,6 @@
#include "stream.h" // for stream_get_endp, stream_getw_from, str...
#include "ringbuf.h" // for ringbuf_remain, ringbuf_peek, ringbuf_...
#include "thread.h" // for THREAD_OFF, THREAD_ARG, thread...
#include "zassert.h" // for assert
#include "bgpd/bgp_io.h"
#include "bgpd/bgp_debug.h" // for bgp_debug_neighbor_events, bgp_type_str

View file

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "bgpd/bgp_nb.h"

View file

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "log.h"

View file

@ -18,6 +18,8 @@
*/
#include <zebra.h>
#include "lib/command.h"
#include "lib/log.h"
#include "lib/northbound.h"

View file

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "lib/command.h"
#include "lib/log.h"
#include "lib/northbound.h"

View file

@ -1,4 +1,6 @@
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE
#include <zebra.h>
#include "bgp_trace.h"

View file

@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "eigrpd/eigrp_structs.h"
#include "eigrpd/eigrpd.h"
#include "eigrpd/eigrp_types.h"

98
lib/assert/assert.h Normal file
View file

@ -0,0 +1,98 @@
/*
* Copyright (c) 2021 David Lamparter, for NetDEF, Inc.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* WARNING: this file is "special" in that it overrides the system-provided
* assert.h by being on the include path before it. That means it should
* provide the functional equivalent.
*
* This is intentional because FRR extends assert() to write to the log and
* add backtraces. Overriding the entire file is the simplest and most
* reliable way to get this to work; there were problems previously with the
* system assert.h getting included afterwards and redefining assert() back to
* the system variant.
*/
#ifndef _FRR_ASSERT_H
#define _FRR_ASSERT_H
#include "xref.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __cplusplus
/* C++ has this built-in, but C provides it in assert.h for >=C11. Since we
* replace assert.h entirely, we need to provide it here too.
*/
#define static_assert _Static_assert
#endif
struct xref_assert {
struct xref xref;
const char *expr;
const char *extra, *args;
};
extern void _zlog_assert_failed(const struct xref_assert *xref,
const char *extra, ...) PRINTFRR(2, 3)
__attribute__((noreturn));
/* the "do { } while (expr_)" is there to get a warning for assignments inside
* the assert expression aka "assert(x = 1)". The (necessary) braces around
* expr_ in the if () statement would suppress these warnings. Since
* _zlog_assert_failed() is noreturn, the while condition will never be
* checked.
*/
#define assert(expr_) \
({ \
static const struct xref_assert _xref __attribute__( \
(used)) = { \
.xref = XREF_INIT(XREFT_ASSERT, NULL, __func__), \
.expr = #expr_, \
}; \
XREF_LINK(_xref.xref); \
if (__builtin_expect((expr_) ? 0 : 1, 0)) \
do { \
_zlog_assert_failed(&_xref, NULL); \
} while (expr_); \
})
#define assertf(expr_, extra_, ...) \
({ \
static const struct xref_assert _xref __attribute__( \
(used)) = { \
.xref = XREF_INIT(XREFT_ASSERT, NULL, __func__), \
.expr = #expr_, \
.extra = extra_, \
.args = #__VA_ARGS__, \
}; \
XREF_LINK(_xref.xref); \
if (__builtin_expect((expr_) ? 0 : 1, 0)) \
do { \
_zlog_assert_failed(&_xref, extra_, \
##__VA_ARGS__); \
} while (expr_); \
})
#define zassert assert
#ifdef __cplusplus
}
#endif
#endif /* _FRR_ASSERT_H */

View file

@ -106,12 +106,7 @@ int main(int argc, char **argv)
/* and now for the ugly part... provide simplified logging functions so we
* don't need to link libzebra (which would be a circular build dep) */
#ifdef __ASSERT_FUNCTION
#undef __ASSERT_FUNCTION
#endif
#include "log.h"
#include "zassert.h"
void vzlogx(const struct xref_logmsg *xref, int prio,
const char *format, va_list args)
@ -120,15 +115,6 @@ void vzlogx(const struct xref_logmsg *xref, int prio,
fputs("\n", stderr);
}
void _zlog_assert_failed(const char *assertion, const char *file,
unsigned int line, const char *function)
{
fprintf(stderr,
"Assertion `%s' failed in file %s, line %u, function %s",
assertion, file, line, (function ? function : "?"));
abort();
}
void memory_oom(size_t size, const char *name)
{
abort();

View file

@ -373,6 +373,10 @@ CPP_NOTICE("time to remove this CONFDATE block")
#else /* !_FRR_ATTRIBUTE_PRINTFRR */
#define PRINTFRR(a, b) __attribute__((format(printf, a, b)))
/* frr-format plugin is C-only for now, so no point in doing these shenanigans
* for C++... (also they can break some C++ stuff...)
*/
#ifndef __cplusplus
/* these should be typedefs, but might also be #define */
#ifdef uint64_t
#undef uint64_t
@ -400,6 +404,8 @@ _Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8,
#define PRIu64 "llu"
#define PRId64 "lld"
#define PRIx64 "llx"
#endif /* !__cplusplus */
#endif /* !_FRR_ATTRIBUTE_PRINTFRR */
#ifdef __cplusplus

View file

@ -1,4 +1,6 @@
#define TRACEPOINT_CREATE_PROBES
#define TRACEPOINT_DEFINE
#include <zebra.h>
#include "libfrr_trace.h"

View file

@ -22,6 +22,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "if.h"
#include "linklist.h"
#include "log.h"

View file

@ -311,17 +311,6 @@ void zlog_thread_info(int log_level)
zlog(log_level, "Current thread not known/applicable");
}
void _zlog_assert_failed(const char *assertion, const char *file,
unsigned int line, const char *function)
{
zlog(LOG_CRIT, "Assertion `%s' failed in file %s, line %u, function %s",
assertion, file, line, (function ? function : "?"));
zlog_backtrace(LOG_CRIT);
zlog_thread_info(LOG_CRIT);
log_memstats(stderr, "log");
abort();
}
void memory_oom(size_t size, const char *name)
{
zlog(LOG_CRIT,

View file

@ -22,8 +22,6 @@
#ifndef _ZEBRA_LOG_H
#define _ZEBRA_LOG_H
#include "zassert.h"
#include <syslog.h>
#include <stdint.h>
#include <stdbool.h>

View file

@ -16,6 +16,8 @@
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "routing_nb.h"

View file

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "vrf.h"

View file

@ -278,13 +278,14 @@ pkginclude_HEADERS += \
lib/yang.h \
lib/yang_translator.h \
lib/yang_wrappers.h \
lib/zassert.h \
lib/zclient.h \
lib/zebra.h \
lib/zlog.h \
lib/zlog_targets.h \
lib/pbr.h \
lib/routing_nb.h \
\
lib/assert/assert.h \
# end
@ -413,7 +414,7 @@ lib_grammar_sandbox_SOURCES = \
lib_grammar_sandbox_LDADD = \
lib/libfrr.la
lib_clippy_CPPFLAGS = $(AM_CPPFLAGS) -D_GNU_SOURCE -DBUILDING_CLIPPY
lib_clippy_CPPFLAGS = $(CPPFLAGS_BASE) -D_GNU_SOURCE -DBUILDING_CLIPPY
lib_clippy_CFLAGS = $(AC_CFLAGS) $(PYTHON_CFLAGS)
lib_clippy_LDADD = $(PYTHON_LIBS) $(UST_LIBS) -lelf
lib_clippy_LDFLAGS = -export-dynamic

View file

@ -664,7 +664,7 @@ static int time_hhmmss(char *buf, int buf_size, long sec)
long mm;
int wr;
zassert(buf_size >= 8);
assert(buf_size >= 8);
hh = sec / 3600;
sec %= 3600;

View file

@ -33,6 +33,7 @@ enum xref_type {
XREFT_THREADSCHED = 0x100,
XREFT_LOGMSG = 0x200,
XREFT_ASSERT = 0x280,
XREFT_DEFUN = 0x300,
XREFT_INSTALL_ELEMENT = 0x301,

View file

@ -1,45 +0,0 @@
/*
* This file is part of Quagga.
*
* Quagga is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* Quagga is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QUAGGA_ASSERT_H
#define _QUAGGA_ASSERT_H
#ifdef __cplusplus
extern "C" {
#endif
extern void _zlog_assert_failed(const char *assertion, const char *file,
unsigned int line, const char *function)
__attribute__((noreturn));
#undef __ASSERT_FUNCTION
#define __ASSERT_FUNCTION __func__
#define zassert(EX) \
((void)((EX) ? 0 : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \
__ASSERT_FUNCTION), \
0)))
#undef assert
#define assert(EX) zassert(EX)
#ifdef __cplusplus
}
#endif
#endif /* _QUAGGA_ASSERT_H */

View file

@ -206,7 +206,7 @@
#define __attribute__(x)
#endif /* !__GNUC__ || VTYSH_EXTRACT_PL */
#include "zassert.h"
#include <assert.h>
/*
* Add explicit static cast only when using a C++ compiler.

View file

@ -526,6 +526,36 @@ void zlog_sigsafe(const char *text, size_t len)
}
}
void _zlog_assert_failed(const struct xref_assert *xref, const char *extra, ...)
{
va_list ap;
static bool assert_in_assert; /* "global-ish" variable, init to 0 */
if (assert_in_assert)
abort();
assert_in_assert = true;
if (extra) {
struct va_format vaf;
va_start(ap, extra);
vaf.fmt = extra;
vaf.va = &ap;
zlog(LOG_CRIT,
"%s:%d: %s(): assertion (%s) failed, extra info: %pVA",
xref->xref.file, xref->xref.line, xref->xref.func,
xref->expr, &vaf);
va_end(ap);
} else
zlog(LOG_CRIT, "%s:%d: %s(): assertion (%s) failed",
xref->xref.file, xref->xref.line, xref->xref.func,
xref->expr);
/* abort() prints backtrace & memstats in SIGABRT handler */
abort();
}
int zlog_msg_prio(struct zlog_msg *msg)
{

View file

@ -25,6 +25,8 @@
#include <unistd.h>
#include <sys/uio.h>
#include <assert.h>
#include "atomlist.h"
#include "frrcu.h"
#include "memory.h"

View file

@ -72,7 +72,7 @@ static void nhrp_cache_free(struct nhrp_cache *c)
debugf(NHRP_DEBUG_COMMON, "Deleting cache entry");
nhrp_cache_counts[c->cur.type]--;
notifier_call(&c->notifier_list, NOTIFY_CACHE_DELETE);
zassert(!notifier_active(&c->notifier_list));
assert(!notifier_active(&c->notifier_list));
hash_release(nifp->cache_hash, c);
THREAD_OFF(c->t_timeout);
THREAD_OFF(c->t_auth);

View file

@ -14,7 +14,7 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "zassert.h"
#include <assert.h>
#include "zbuf.h"
#include "memory.h"
#include "nhrpd.h"
@ -59,7 +59,7 @@ void zbuf_reset(struct zbuf *zb)
void zbuf_reset_head(struct zbuf *zb, void *ptr)
{
zassert((void *)zb->buf <= ptr && ptr <= (void *)zb->tail);
assert((void *)zb->buf <= ptr && ptr <= (void *)zb->tail);
zb->head = ptr;
}

View file

@ -15,7 +15,6 @@
#include <endian.h>
#include <sys/types.h>
#include "zassert.h"
#include "list.h"
struct zbuf {

View file

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "lib/northbound.h"
#include "lib/routemap.h"
#include "ospf6_routemap_nb.h"

View file

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "lib/command.h"
#include "lib/log.h"
#include "lib/northbound.h"

View file

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "lib/northbound.h"
#include "lib/routemap.h"
#include "ospf_routemap_nb.h"

View file

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "lib/command.h"
#include "lib/log.h"
#include "lib/northbound.h"

View file

@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <float.h>
#include <math.h>
#include <zebra.h>

View file

@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>

View file

@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <northbound.h>
#include <yang.h>
#include <printfrr.h>

View file

@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>

View file

@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "thread.h"
#include "log.h"
#include "lib_errors.h"

View file

@ -50,8 +50,8 @@ struct pbr_interface *pbr_if_new(struct interface *ifp)
{
struct pbr_interface *pbr_ifp;
zassert(ifp);
zassert(!ifp->info);
assert(ifp);
assert(!ifp->info);
pbr_ifp = XCALLOC(MTYPE_PBR_INTERFACE, sizeof(*pbr_ifp));

View file

@ -25,6 +25,10 @@
* This is the implementation of a High Level PCEP message API.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <arpa/inet.h>
#include <stdarg.h>

View file

@ -25,6 +25,10 @@
* Encoding and decoding for PCEP messages.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

View file

@ -19,6 +19,10 @@
* Author : Brady Johnson <brady@voltanet.io>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include "pcep_msg_object_error_types.h"

View file

@ -25,6 +25,10 @@
* This is the implementation of a High Level PCEP message object API.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <arpa/inet.h>
#include <stdarg.h>

View file

@ -25,6 +25,10 @@
* Encoding and decoding for PCEP Objects.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>

View file

@ -25,6 +25,10 @@
* This is the implementation of a High Level PCEP message object TLV API.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdbool.h>
#include <stdint.h>
#include <string.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <errno.h>
#include <stdio.h>
#include <string.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <errno.h>
#include <limits.h>
#include <pthread.h>

View file

@ -25,6 +25,10 @@
* PCEP session logic counters configuration.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <time.h>

View file

@ -20,6 +20,10 @@
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>

View file

@ -20,6 +20,10 @@
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>

View file

@ -27,6 +27,10 @@
* created.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <netinet/in.h>
#include <stdbool.h>
#include <stdlib.h>

View file

@ -25,6 +25,10 @@
* Implementation of public API timer functions.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <limits.h>
#include <pthread.h>
#include <stddef.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <errno.h>
#include <stddef.h>
#include <stdbool.h>

View file

@ -20,6 +20,10 @@
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stddef.h>
#include <string.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdarg.h>
#include <stdio.h>
#include "pcep_utils_logging.h"

View file

@ -20,6 +20,10 @@
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <string.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdbool.h>
#include <stdio.h>
#include <string.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <CUnit/CUnit.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <CUnit/CUnit.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <CUnit/CUnit.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <netdb.h> // gethostbyname
#include <pthread.h>
#include <stdlib.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <pthread.h>
#include <stdlib.h>
#include <string.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <time.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <pthread.h>
#include <stdlib.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <netinet/in.h>
#include <CUnit/CUnit.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <CUnit/CUnit.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdbool.h>
#include <CUnit/CUnit.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <CUnit/CUnit.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/CUnit.h>
#include "pcep_utils_double_linked_list.h"

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdint.h>

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/CUnit.h>
#include "pcep_utils_ordered_list.h"

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/CUnit.h>
#include "pcep_utils_queue.h"

View file

@ -21,6 +21,10 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>
#include <CUnit/TestDB.h>

View file

@ -304,7 +304,7 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh,
msg_metric.ip_address = src_addr;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
++pim_ifp->pim_ifstat_assert_recv;
return dispatch_assert(ifp, msg_source_addr.u.prefix4, sg.grp,

View file

@ -141,14 +141,14 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr,
on_trace(__func__, ifp, src_addr);
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
++pim_ifp->pim_ifstat_hello_recv;
/*
Parse PIM hello TLVs
*/
zassert(tlv_buf_size >= 0);
assert(tlv_buf_size >= 0);
tlv_curr = tlv_buf;
tlv_pastend = tlv_buf + tlv_buf_size;
@ -539,11 +539,11 @@ void pim_hello_require(struct interface *ifp)
{
struct pim_interface *pim_ifp;
zassert(ifp);
assert(ifp);
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
if (pim_ifp->pim_ifstat_hello_sent)
return;

View file

@ -115,8 +115,8 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
{
struct pim_interface *pim_ifp;
zassert(ifp);
zassert(!ifp->info);
assert(ifp);
assert(!ifp->info);
pim_ifp = XCALLOC(MTYPE_PIM_INTERFACE, sizeof(*pim_ifp));
@ -145,8 +145,8 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
The number of seconds represented by the [Query Response Interval]
must be less than the [Query Interval].
*/
zassert(pim_ifp->igmp_query_max_response_time_dsec
< pim_ifp->igmp_default_query_interval);
assert(pim_ifp->igmp_query_max_response_time_dsec
< pim_ifp->igmp_default_query_interval);
if (pim)
PIM_IF_DO_PIM(pim_ifp->options);
@ -198,9 +198,9 @@ void pim_if_delete(struct interface *ifp)
struct pim_interface *pim_ifp;
struct pim_ifchannel *ch;
zassert(ifp);
assert(ifp);
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
if (pim_ifp->igmp_join_list) {
pim_if_igmp_join_del_all(ifp);
@ -238,7 +238,7 @@ void pim_if_update_could_assert(struct interface *ifp)
struct pim_ifchannel *ch;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
pim_ifchannel_update_could_assert(ch);
@ -251,7 +251,7 @@ static void pim_if_update_my_assert_metric(struct interface *ifp)
struct pim_ifchannel *ch;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
pim_ifchannel_update_my_assert_metric(ch);
@ -263,7 +263,7 @@ static void pim_addr_change(struct interface *ifp)
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
pim_if_dr_election(ifp); /* router's own DR Priority (addr) changes --
Done TODO T30 */
@ -507,10 +507,10 @@ void pim_if_addr_add(struct connected *ifc)
struct in_addr ifaddr;
bool vxlan_term;
zassert(ifc);
assert(ifc);
ifp = ifc->ifp;
zassert(ifp);
assert(ifp);
pim_ifp = ifp->info;
if (!pim_ifp)
return;
@ -708,9 +708,9 @@ void pim_if_addr_del(struct connected *ifc, int force_prim_as_any)
{
struct interface *ifp;
zassert(ifc);
assert(ifc);
ifp = ifc->ifp;
zassert(ifp);
assert(ifp);
if (PIM_DEBUG_ZEBRA)
zlog_debug("%s: %s ifindex=%d disconnected IP address %pFX %s",
@ -945,7 +945,7 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term)
struct in_addr ifaddr;
unsigned char flags = 0;
zassert(pim_ifp);
assert(pim_ifp);
if (pim_ifp->mroute_vif_index > 0) {
zlog_warn("%s: vif_index=%d > 0 on interface %s ifindex=%d",
@ -1063,8 +1063,8 @@ int pim_if_lan_delay_enabled(struct interface *ifp)
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
zassert(pim_ifp);
zassert(pim_ifp->pim_number_of_nonlandelay_neighbors >= 0);
assert(pim_ifp);
assert(pim_ifp->pim_number_of_nonlandelay_neighbors >= 0);
return pim_ifp->pim_number_of_nonlandelay_neighbors == 0;
}
@ -1128,7 +1128,7 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
struct pim_interface *pim_ifp;
struct prefix p;
zassert(ifp);
assert(ifp);
pim_ifp = ifp->info;
if (!pim_ifp) {
@ -1171,7 +1171,7 @@ long pim_if_t_suppressed_msec(struct interface *ifp)
uint32_t ramount = 0;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
/* join suppression disabled ? */
if (PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPPRESSION(pim_ifp->options))
@ -1196,7 +1196,7 @@ static struct igmp_join *igmp_join_find(struct list *join_list,
struct listnode *node;
struct igmp_join *ij;
zassert(join_list);
assert(join_list);
for (ALL_LIST_ELEMENTS_RO(join_list, node, ij)) {
if ((group_addr.s_addr == ij->group_addr.s_addr)
@ -1245,7 +1245,7 @@ static struct igmp_join *igmp_join_new(struct interface *ifp,
int join_fd;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
join_fd = igmp_join_sock(ifp->name, ifp->ifindex, group_addr,
source_addr);
@ -1416,7 +1416,7 @@ void pim_if_assert_on_neighbor_down(struct interface *ifp,
struct pim_ifchannel *ch;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) {
/* Is (S,G,I) assert loser ? */

View file

@ -498,7 +498,7 @@ void pim_ifchannel_membership_clear(struct interface *ifp)
struct pim_ifchannel *ch;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb)
ifmembership_set(ch, PIM_IFMEMBERSHIP_NOINFO);
@ -510,7 +510,7 @@ void pim_ifchannel_delete_on_noinfo(struct interface *ifp)
struct pim_ifchannel *ch, *ch_tmp;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
RB_FOREACH_SAFE (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb, ch_tmp)
delete_on_noinfo(ch);
@ -825,7 +825,7 @@ static int nonlocal_upstream(int is_join, struct interface *recv_ifp,
int is_local; /* boolean */
recv_pim_ifp = recv_ifp->info;
zassert(recv_pim_ifp);
assert(recv_pim_ifp);
is_local = (upstream.s_addr == recv_pim_ifp->primary_address.s_addr);
@ -913,7 +913,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,
}
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
switch (ch->ifjoin_state) {
case PIM_IFJOIN_NOINFO:
@ -939,7 +939,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr,
}
break;
case PIM_IFJOIN_JOIN:
zassert(!ch->t_ifjoin_prune_pending_timer);
assert(!ch->t_ifjoin_prune_pending_timer);
/*
In the JOIN state ch->t_ifjoin_expiry_timer may be NULL due to

View file

@ -159,7 +159,7 @@ static int pim_igmp_other_querier_expire(struct thread *t)
igmp = THREAD_ARG(t);
zassert(!igmp->t_igmp_query_timer);
assert(!igmp->t_igmp_query_timer);
if (PIM_DEBUG_IGMP_TRACE) {
char ifaddr_str[INET_ADDRSTRLEN];
@ -185,9 +185,9 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
long other_querier_present_interval_msec;
struct pim_interface *pim_ifp;
zassert(igmp);
zassert(igmp->interface);
zassert(igmp->interface->info);
assert(igmp);
assert(igmp->interface);
assert(igmp->interface->info);
pim_ifp = igmp->interface->info;
@ -218,7 +218,7 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
Since this socket is starting the other-querier-present timer,
there should not be periodic query timer for this socket.
*/
zassert(!igmp->t_igmp_query_timer);
assert(!igmp->t_igmp_query_timer);
/*
RFC 3376: 8.5. Other Querier Present Interval
@ -255,7 +255,7 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
void pim_igmp_other_querier_timer_off(struct igmp_sock *igmp)
{
zassert(igmp);
assert(igmp);
if (PIM_DEBUG_IGMP_TRACE) {
if (igmp->t_other_querier_timer) {
@ -589,9 +589,9 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp)
Since this socket is starting as querier,
there should not exist a timer for other-querier-present.
*/
zassert(!igmp->t_other_querier_timer);
assert(!igmp->t_other_querier_timer);
pim_ifp = igmp->interface->info;
zassert(pim_ifp);
assert(pim_ifp);
/*
RFC 3376: 8.6. Startup Query Interval
@ -638,7 +638,7 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp)
void pim_igmp_general_query_off(struct igmp_sock *igmp)
{
zassert(igmp);
assert(igmp);
if (PIM_DEBUG_IGMP_TRACE) {
if (igmp->t_igmp_query_timer) {
@ -664,8 +664,8 @@ static int pim_igmp_general_query(struct thread *t)
igmp = THREAD_ARG(t);
zassert(igmp->interface);
zassert(igmp->interface->info);
assert(igmp->interface);
assert(igmp->interface->info);
pim_ifp = igmp->interface->info;
@ -835,19 +835,19 @@ void igmp_group_delete(struct igmp_group *group)
void igmp_group_delete_empty_include(struct igmp_group *group)
{
zassert(!group->group_filtermode_isexcl);
zassert(!listcount(group->group_source_list));
assert(!group->group_filtermode_isexcl);
assert(!listcount(group->group_source_list));
igmp_group_delete(group);
}
void igmp_sock_free(struct igmp_sock *igmp)
{
zassert(!igmp->t_igmp_read);
zassert(!igmp->t_igmp_query_timer);
zassert(!igmp->t_other_querier_timer);
zassert(igmp->igmp_group_list);
zassert(!listcount(igmp->igmp_group_list));
assert(!igmp->t_igmp_read);
assert(!igmp->t_igmp_query_timer);
assert(!igmp->t_other_querier_timer);
assert(igmp->igmp_group_list);
assert(!listcount(igmp->igmp_group_list));
list_delete(&igmp->igmp_group_list);
hash_free(igmp->igmp_group_hash);
@ -1076,7 +1076,7 @@ static int igmp_group_timer(struct thread *t)
group_str, group->group_igmp_sock->interface->name);
}
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
group->group_filtermode_isexcl = 0;
@ -1085,7 +1085,7 @@ static int igmp_group_timer(struct thread *t)
igmp_source_delete_expired(group->group_source_list);
zassert(!group->group_filtermode_isexcl);
assert(!group->group_filtermode_isexcl);
/*
RFC 3376: 6.2.2. Definition of Group Timers
@ -1137,7 +1137,7 @@ void igmp_group_timer_on(struct igmp_group *group, long interval_msec,
it represents the time for the *filter-mode* of the group to
expire and switch to INCLUDE mode.
*/
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
thread_add_timer_msec(router->master, igmp_group_timer, group,
interval_msec, &group->t_group_timer);
@ -1228,8 +1228,8 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp,
it represents the time for the *filter-mode* of the group to
expire and switch to INCLUDE mode.
*/
zassert(!group->group_filtermode_isexcl); /* INCLUDE mode */
zassert(!group->t_group_timer); /* group timer == 0 */
assert(!group->group_filtermode_isexcl); /* INCLUDE mode */
assert(!group->t_group_timer); /* group timer == 0 */
/* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */
igmp_anysource_forward_stop(group);

View file

@ -54,7 +54,7 @@ void igmp_v2_send_query(struct igmp_group *group, int fd, const char *ifname,
/* max_resp_code must be non-zero else this will look like an IGMP v1
* query */
max_resp_code = igmp_msg_encode16to8(query_max_response_time_dsec);
zassert(max_resp_code > 0);
assert(max_resp_code > 0);
query_buf[0] = PIM_IGMP_MEMBERSHIP_QUERY;
query_buf[1] = max_resp_code;

View file

@ -103,7 +103,7 @@ void igmp_group_reset_gmi(struct igmp_group *group)
it represents the time for the *filter-mode* of the group to
expire and switch to INCLUDE mode.
*/
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
igmp_group_timer_on(group, group_membership_interval_msec, ifp->name);
}
@ -314,7 +314,7 @@ static void group_exclude_fwd_anysrc_ifempty(struct igmp_group *group)
{
struct pim_interface *pim_ifp = group->group_igmp_sock->interface->info;
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
if (listcount(group->group_source_list) < 1) {
igmp_anysource_forward_start(pim_ifp->pim, group);
@ -324,7 +324,7 @@ static void group_exclude_fwd_anysrc_ifempty(struct igmp_group *group)
void igmp_source_free(struct igmp_source *source)
{
/* make sure there is no source timer running */
zassert(!source->t_source_timer);
assert(!source->t_source_timer);
XFREE(MTYPE_PIM_IGMP_GROUP_SOURCE, source);
}
@ -557,7 +557,7 @@ static void isex_excl(struct igmp_group *group, int num_sources,
int i;
/* EXCLUDE mode */
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
/* E.1: set deletion flag for known sources (X,Y) */
source_mark_delete_flag(group);
@ -577,10 +577,10 @@ static void isex_excl(struct igmp_group *group, int num_sources,
/* E.4: if not found, create source with timer=GMI:
* (A-X-Y) */
source = source_new(group, *src_addr);
zassert(!source->t_source_timer); /* timer == 0 */
assert(!source->t_source_timer); /* timer == 0 */
igmp_source_reset_gmi(group->group_igmp_sock, group,
source);
zassert(source->t_source_timer); /* (A-X-Y) timer > 0 */
assert(source->t_source_timer); /* (A-X-Y) timer > 0 */
}
} /* scan received sources */
@ -610,7 +610,7 @@ static void isex_incl(struct igmp_group *group, int num_sources,
int i;
/* INCLUDE mode */
zassert(!group->group_filtermode_isexcl);
assert(!group->group_filtermode_isexcl);
/* I.1: set deletion flag for known sources (A) */
source_mark_delete_flag(group);
@ -631,7 +631,7 @@ static void isex_incl(struct igmp_group *group, int num_sources,
/* I.4: if not found, create source with timer=0 (B-A)
*/
source = source_new(group, *src_addr);
zassert(!source->t_source_timer); /* (B-A) timer=0 */
assert(!source->t_source_timer); /* (B-A) timer=0 */
}
} /* scan received sources */
@ -641,7 +641,7 @@ static void isex_incl(struct igmp_group *group, int num_sources,
group->group_filtermode_isexcl = 1; /* boolean=true */
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
group_exclude_fwd_anysrc_ifempty(group);
}
@ -675,10 +675,10 @@ void igmpv3_report_isex(struct igmp_sock *igmp, struct in_addr from,
} else {
/* INCLUDE mode */
isex_incl(group, num_sources, sources);
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
}
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
igmp_group_reset_gmi(group);
}
@ -807,7 +807,7 @@ static void toex_incl(struct igmp_group *group, int num_sources,
int num_sources_tosend = 0;
int i;
zassert(!group->group_filtermode_isexcl);
assert(!group->group_filtermode_isexcl);
/* Set DELETE flag for all known sources (A) */
source_mark_delete_flag(group);
@ -834,7 +834,7 @@ static void toex_incl(struct igmp_group *group, int num_sources,
/* If source not found, create source with timer=0:
* (B-A)=0 */
source = source_new(group, *src_addr);
zassert(!source->t_source_timer); /* (B-A) timer=0 */
assert(!source->t_source_timer); /* (B-A) timer=0 */
}
} /* Scan received sources (B) */
@ -849,7 +849,7 @@ static void toex_incl(struct igmp_group *group, int num_sources,
source_query_send_by_flag(group, num_sources_tosend);
}
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
group_exclude_fwd_anysrc_ifempty(group);
}
@ -894,17 +894,17 @@ static void toex_excl(struct igmp_group *group, int num_sources,
long group_timer_msec;
source = source_new(group, *src_addr);
zassert(!source->t_source_timer); /* timer == 0 */
assert(!source->t_source_timer); /* timer == 0 */
group_timer_msec = igmp_group_timer_remain_msec(group);
igmp_source_timer_on(group, source, group_timer_msec);
zassert(source->t_source_timer); /* (A-X-Y) timer > 0 */
assert(source->t_source_timer); /* (A-X-Y) timer > 0 */
/* make sure source is created with DELETE flag unset */
zassert(!IGMP_SOURCE_TEST_DELETE(source->source_flags));
assert(!IGMP_SOURCE_TEST_DELETE(source->source_flags));
}
/* make sure reported source has DELETE flag unset */
zassert(!IGMP_SOURCE_TEST_DELETE(source->source_flags));
assert(!IGMP_SOURCE_TEST_DELETE(source->source_flags));
if (source->t_source_timer) {
/* if source timer>0 mark SEND flag: Q(G,A-Y) */
@ -948,9 +948,9 @@ void igmpv3_report_toex(struct igmp_sock *igmp, struct in_addr from,
} else {
/* INCLUDE mode */
toex_incl(group, num_sources, sources);
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
}
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
/* Group Timer=GMI */
igmp_group_reset_gmi(group);
@ -1347,7 +1347,7 @@ static void source_query_send_by_flag(struct igmp_group *group,
long lmqi_msec; /* Last Member Query Interval */
long lmqt_msec; /* Last Member Query Time */
zassert(num_sources_tosend > 0);
assert(num_sources_tosend > 0);
igmp = group->group_igmp_sock;
pim_ifp = igmp->interface->info;
@ -1408,10 +1408,10 @@ static void block_excl(struct igmp_group *group, int num_sources,
long group_timer_msec;
source = source_new(group, *src_addr);
zassert(!source->t_source_timer); /* timer == 0 */
assert(!source->t_source_timer); /* timer == 0 */
group_timer_msec = igmp_group_timer_remain_msec(group);
igmp_source_timer_on(group, source, group_timer_msec);
zassert(source->t_source_timer); /* (A-X-Y) timer > 0 */
assert(source->t_source_timer); /* (A-X-Y) timer > 0 */
}
if (source->t_source_timer) {
@ -1523,7 +1523,7 @@ void igmp_group_timer_lower_to_lmqt(struct igmp_group *group)
lmqt_msec);
}
zassert(group->group_filtermode_isexcl);
assert(group->group_filtermode_isexcl);
igmp_group_timer_on(group, lmqt_msec, ifname);
}
@ -1581,7 +1581,7 @@ void igmp_v3_send_query(struct igmp_group *group, int fd, const char *ifname,
socklen_t tolen;
uint16_t checksum;
zassert(num_sources >= 0);
assert(num_sources >= 0);
msg_size = IGMP_V3_SOURCES_OFFSET + (num_sources << 2);
if (msg_size > query_buf_size) {
@ -1593,7 +1593,7 @@ void igmp_v3_send_query(struct igmp_group *group, int fd, const char *ifname,
}
s_flag = PIM_FORCE_BOOLEAN(s_flag);
zassert((s_flag == 0) || (s_flag == 1));
assert((s_flag == 0) || (s_flag == 1));
max_resp_code = igmp_msg_encode16to8(query_max_response_time_dsec);
qqic = igmp_msg_encode16to8(querier_query_interval);

View file

@ -71,7 +71,7 @@ static void recv_join(struct interface *ifp, struct pim_neighbor *neigh,
}
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
++pim_ifp->pim_ifstat_join_recv;
@ -134,7 +134,7 @@ static void recv_prune(struct interface *ifp, struct pim_neighbor *neigh,
}
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
++pim_ifp->pim_ifstat_prune_recv;

View file

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "pimd.h"
#include "pim_nb.h"
#include "lib/northbound_cli.h"
@ -36,7 +38,7 @@ static void pim_if_membership_clear(struct interface *ifp)
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
if (PIM_IF_TEST_PIM(pim_ifp->options)
&& PIM_IF_TEST_IGMP(pim_ifp->options)) {
@ -62,7 +64,7 @@ static void pim_if_membership_refresh(struct interface *ifp)
struct igmp_sock *igmp;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
if (!PIM_IF_TEST_PIM(pim_ifp->options))
return;
@ -576,7 +578,7 @@ static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
struct interface *ifp;
struct pim_interface *pim_ifp;
zassert(igmp);
assert(igmp);
/* other querier present? */
@ -585,8 +587,8 @@ static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
/* this is the querier */
zassert(igmp->interface);
zassert(igmp->interface->info);
assert(igmp->interface);
assert(igmp->interface->info);
ifp = igmp->interface;
pim_ifp = ifp->info;
@ -616,25 +618,25 @@ static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
if (igmp->t_igmp_query_timer) {
/* other querier present */
zassert(igmp->t_igmp_query_timer);
zassert(!igmp->t_other_querier_timer);
assert(igmp->t_igmp_query_timer);
assert(!igmp->t_other_querier_timer);
pim_igmp_general_query_off(igmp);
pim_igmp_general_query_on(igmp);
zassert(igmp->t_igmp_query_timer);
zassert(!igmp->t_other_querier_timer);
assert(igmp->t_igmp_query_timer);
assert(!igmp->t_other_querier_timer);
} else {
/* this is the querier */
zassert(!igmp->t_igmp_query_timer);
zassert(igmp->t_other_querier_timer);
assert(!igmp->t_igmp_query_timer);
assert(igmp->t_other_querier_timer);
pim_igmp_other_querier_timer_off(igmp);
pim_igmp_other_querier_timer_on(igmp);
zassert(!igmp->t_igmp_query_timer);
zassert(igmp->t_other_querier_timer);
assert(!igmp->t_igmp_query_timer);
assert(igmp->t_other_querier_timer);
}
}

View file

@ -49,7 +49,7 @@ static void dr_election_by_addr(struct interface *ifp)
struct pim_neighbor *neigh;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
pim_ifp->pim_dr_addr = pim_ifp->primary_address;
@ -73,7 +73,7 @@ static void dr_election_by_pri(struct interface *ifp)
uint32_t dr_pri;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
pim_ifp->pim_dr_addr = pim_ifp->primary_address;
dr_pri = pim_ifp->pim_dr_priority;
@ -310,9 +310,9 @@ pim_neighbor_new(struct interface *ifp, struct in_addr source_addr,
struct pim_neighbor *neigh;
char src_str[INET_ADDRSTRLEN];
zassert(ifp);
assert(ifp);
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
neigh = XCALLOC(MTYPE_PIM_NEIGHBOR, sizeof(*neigh));
@ -412,7 +412,7 @@ static void delete_prefix_list(struct pim_neighbor *neigh)
void pim_neighbor_free(struct pim_neighbor *neigh)
{
zassert(!neigh->t_expire_timer);
assert(!neigh->t_expire_timer);
delete_prefix_list(neigh);
@ -503,7 +503,7 @@ pim_neighbor_add(struct interface *ifp, struct in_addr source_addr,
}
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
listnode_add(pim_ifp->pim_neighbor_list, neigh);
@ -566,7 +566,7 @@ static uint16_t find_neighbors_next_highest_propagation_delay_msec(
uint16_t next_highest_delay_msec;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
next_highest_delay_msec = pim_ifp->pim_propagation_delay_msec;
@ -590,7 +590,7 @@ static uint16_t find_neighbors_next_highest_override_interval_msec(
uint16_t next_highest_interval_msec;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
next_highest_interval_msec = pim_ifp->pim_override_interval_msec;
@ -613,7 +613,7 @@ void pim_neighbor_delete(struct interface *ifp, struct pim_neighbor *neigh,
char src_str[INET_ADDRSTRLEN];
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
pim_inet4_dump("<src?>", neigh->source_addr, src_str, sizeof(src_str));
zlog_info("PIM NEIGHBOR DOWN: neighbor %s on interface %s: %s", src_str,
@ -637,10 +637,10 @@ void pim_neighbor_delete(struct interface *ifp, struct pim_neighbor *neigh,
--pim_ifp->pim_dr_num_nondrpri_neighbors;
}
zassert(neigh->propagation_delay_msec
<= pim_ifp->pim_neighbors_highest_propagation_delay_msec);
zassert(neigh->override_interval_msec
<= pim_ifp->pim_neighbors_highest_override_interval_msec);
assert(neigh->propagation_delay_msec
<= pim_ifp->pim_neighbors_highest_propagation_delay_msec);
assert(neigh->override_interval_msec
<= pim_ifp->pim_neighbors_highest_override_interval_msec);
if (pim_if_lan_delay_enabled(ifp)) {
@ -683,7 +683,7 @@ void pim_neighbor_delete_all(struct interface *ifp, const char *delete_message)
struct pim_neighbor *neigh;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
for (ALL_LIST_ELEMENTS(pim_ifp->pim_neighbor_list, neigh_node,
neigh_nextnode, neigh)) {
@ -728,9 +728,9 @@ static void delete_from_neigh_addr(struct interface *ifp,
struct pim_interface *pim_ifp;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
zassert(addr_list);
assert(addr_list);
/*
Scan secondary address list

View file

@ -219,8 +219,8 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif,
{
struct pim_interface *pim_ifp;
zassert(channel_oil);
zassert(oif);
assert(channel_oil);
assert(oif);
pim_ifp = oif->info;

View file

@ -407,8 +407,8 @@ static void pim_sock_read_on(struct interface *ifp)
{
struct pim_interface *pim_ifp;
zassert(ifp);
zassert(ifp->info);
assert(ifp);
assert(ifp->info);
pim_ifp = ifp->info;
@ -444,7 +444,7 @@ void pim_ifstat_reset(struct interface *ifp)
{
struct pim_interface *pim_ifp;
zassert(ifp);
assert(ifp);
pim_ifp = ifp->info;
if (!pim_ifp) {
@ -462,8 +462,8 @@ void pim_sock_reset(struct interface *ifp)
{
struct pim_interface *pim_ifp;
zassert(ifp);
zassert(ifp->info);
assert(ifp);
assert(ifp->info);
pim_ifp = ifp->info;
@ -671,8 +671,8 @@ static int hello_send(struct interface *ifp, uint16_t holdtime)
pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN;
zassert(pim_msg_size >= PIM_PIM_MIN_LEN);
zassert(pim_msg_size <= PIM_PIM_BUFSIZE_WRITE);
assert(pim_msg_size >= PIM_PIM_MIN_LEN);
assert(pim_msg_size <= PIM_PIM_BUFSIZE_WRITE);
pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_HELLO, false);
@ -846,7 +846,7 @@ int pim_sock_add(struct interface *ifp)
uint32_t old_genid;
pim_ifp = ifp->info;
zassert(pim_ifp);
assert(pim_ifp);
if (pim_ifp->pim_sock_fd >= 0) {
if (PIM_DEBUG_PIM_PACKETS)

View file

@ -41,12 +41,12 @@ void pim_ssmpingd_init(struct pim_instance *pim)
{
int result;
zassert(!pim->ssmpingd_list);
assert(!pim->ssmpingd_list);
result = inet_pton(AF_INET, PIM_SSMPINGD_REPLY_GROUP,
&pim->ssmpingd_group_addr);
zassert(result > 0);
assert(result > 0);
}
void pim_ssmpingd_destroy(struct pim_instance *pim)
@ -197,7 +197,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)
static void ssmpingd_delete(struct ssmpingd_sock *ss)
{
zassert(ss);
assert(ss);
THREAD_OFF(ss->t_sock_read);

View file

@ -106,7 +106,7 @@ int pim_time_mmss(char *buf, int buf_size, long sec)
long mm;
int wr;
zassert(buf_size >= 5);
assert(buf_size >= 5);
mm = sec / 60;
sec %= 60;
@ -122,7 +122,7 @@ static int pim_time_hhmmss(char *buf, int buf_size, long sec)
long mm;
int wr;
zassert(buf_size >= 8);
assert(buf_size >= 8);
hh = sec / 3600;
sec %= 3600;
@ -156,7 +156,7 @@ void pim_time_timer_to_hhmmss(char *buf, int buf_size, struct thread *t_timer)
void pim_time_uptime(char *buf, int buf_size, int64_t uptime_sec)
{
zassert(buf_size >= 8);
assert(buf_size >= 8);
pim_time_hhmmss(buf, buf_size, uptime_sec);
}

View file

@ -662,7 +662,7 @@ int pim_tlv_parse_addr_list(const char *ifname, struct in_addr src_addr,
const uint8_t *addr;
const uint8_t *pastend;
zassert(hello_option_addr_list);
assert(hello_option_addr_list);
/*
Scan addr list

View file

@ -471,8 +471,8 @@ void igmp_anysource_forward_start(struct pim_instance *pim,
struct igmp_source *source;
struct in_addr src_addr = {.s_addr = 0};
/* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */
zassert(group->group_filtermode_isexcl);
zassert(listcount(group->group_source_list) < 1);
assert(group->group_filtermode_isexcl);
assert(listcount(group->group_source_list) < 1);
source = source_new(group, src_addr);
if (!source) {

View file

@ -126,7 +126,7 @@ void pim_init(void)
"%s %s: could not solve %s to group address: errno=%d: %s",
__FILE__, __func__, PIM_ALL_PIM_ROUTERS, errno,
safe_strerror(errno));
zassert(0);
assert(0);
return;
}

View file

@ -1,30 +1,90 @@
#
# check that the first header included in C files is either
# zebra.h or config.h
#
# Copyright (C) 2020 David Lamparter for NetDEF, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; see the file COPYING; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import sys, os, re, subprocess
import sys
import os
import re
import subprocess
import argparse
argp = argparse.ArgumentParser(description="include fixer")
argp.add_argument("--autofix", action="store_const", const=True)
argp.add_argument("--warn-empty", action="store_const", const=True)
argp.add_argument("--pipe", action="store_const", const=True)
include_re = re.compile('^#\s*include\s+["<]([^ ">]+)[">]', re.M)
errors = 0
ignore = [
lambda fn: fn.startswith("tools/"),
lambda fn: fn
in [
"lib/elf_py.c",
],
]
def run(args):
out = []
files = subprocess.check_output(["git", "ls-files"]).decode("ASCII")
for fn in files.splitlines():
if not fn.endswith(".c"):
continue
if max([i(fn) for i in ignore]):
continue
with open(fn, "r") as fd:
data = fd.read()
files = subprocess.check_output(["git", "ls-files"]).decode("ASCII")
for fn in files.splitlines():
if not fn.endswith(".c"):
continue
if fn.startswith("tools/"):
continue
with open(fn, "r") as fd:
data = fd.read()
m = include_re.search(data)
if m is None:
# sys.stderr.write('no #include in %s?\n' % (fn))
if args.warn_empty:
sys.stderr.write("no #include in %s?\n" % (fn))
continue
if m.group(1) in ["config.h", "zebra.h", "lib/zebra.h"]:
continue
sys.stderr.write("%s: %s\n" % (fn, m.group(0)))
errors += 1
if errors:
sys.exit(1)
if args.autofix:
sys.stderr.write("%s: %s - fixing\n" % (fn, m.group(0)))
if fn.startswith("pceplib/"):
insert = '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n'
else:
insert = "#include <zebra.h>\n\n"
pos = m.span()[0]
data = data[:pos] + insert + data[pos:]
with open(fn + ".new", "w") as fd:
fd.write(data)
os.rename(fn + ".new", fn)
else:
sys.stderr.write("%s: %s\n" % (fn, m.group(0)))
out.append(fn)
if len(out):
if args.pipe:
# for "vim `firstheader.py`"
print("\n".join(out))
return 1
return 0
if __name__ == "__main__":
args = argp.parse_args()
sys.exit(run(args))

View file

@ -16,6 +16,8 @@
* with this program; see the file COPYING; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "northbound.h"
#include "libfrr.h"
#include "static_nb.h"

Some files were not shown because too many files have changed in this diff Show more