diff options
147 files changed, 1499 insertions, 243 deletions
@@ -18,6 +18,8 @@ FRR currently supports the following protocols: * LDP * BFD * Babel +* PBR +* OpenFabric * EIGRP (alpha) * NHRP (alpha) diff --git a/bfdd/Makefile b/bfdd/Makefile new file mode 100644 index 0000000000..dfe78232c4 --- /dev/null +++ b/bfdd/Makefile @@ -0,0 +1,10 @@ +all: ALWAYS + @$(MAKE) -s -C .. bfdd/bfdd +%: ALWAYS + @$(MAKE) -s -C .. bfdd/$@ + +Makefile: + #nothing +ALWAYS: +.PHONY: ALWAYS makefiles +.SUFFIXES: diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index 8f8fff6b18..3476e16210 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -968,6 +968,18 @@ static void _bfdd_peer_write_config(struct hash_backet *hb, void *arg) vty_out(vty, " !\n"); } +DEFUN_NOSH(show_debugging_bfd, + show_debugging_bfd_cmd, + "show debugging [bfd]", + SHOW_STR + DEBUG_STR + "BFD daemon\n") +{ + vty_out(vty, "BFD debugging status:\n"); + + return CMD_SUCCESS; +} + static int bfdd_peer_write_config(struct vty *vty) { bfd_id_iterate(_bfdd_peer_write_config, vty); @@ -993,6 +1005,7 @@ void bfdd_vty_init(void) install_element(ENABLE_NODE, &bfd_show_peers_cmd); install_element(ENABLE_NODE, &bfd_show_peer_cmd); install_element(CONFIG_NODE, &bfd_enter_cmd); + install_element(ENABLE_NODE, &show_debugging_bfd_cmd); /* Install BFD node and commands. */ install_node(&bfd_node, bfdd_write_config); diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 03f31eddfc..aa271da07f 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -2227,11 +2227,12 @@ bgp_attr_pmsi_tunnel(struct bgp_attr_parser_args *args) struct attr *const attr = args->attr; const bgp_size_t length = args->length; uint8_t tnl_type; + int attr_parse_len = 2 + BGP_LABEL_BYTES; /* Verify that the receiver is expecting "ingress replication" as we * can only support that. */ - if (length < 2) { + if (length < attr_parse_len) { flog_err(EC_BGP_ATTR_LEN, "Bad PMSI tunnel attribute length %d", length); return bgp_attr_malformed(args, BGP_NOTIFY_UPDATE_ATTR_LENG_ERR, @@ -2258,9 +2259,10 @@ bgp_attr_pmsi_tunnel(struct bgp_attr_parser_args *args) attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL); attr->pmsi_tnl_type = tnl_type; + stream_get(&attr->label, peer->curr, BGP_LABEL_BYTES); /* Forward read pointer of input stream. */ - stream_forward_getp(peer->curr, length - 2); + stream_forward_getp(peer->curr, length - attr_parse_len); return BGP_ATTR_PARSE_PROCEED; } @@ -3445,7 +3447,7 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer, stream_putc(s, BGP_ATTR_PMSI_TUNNEL); stream_putc(s, 9); // Length stream_putc(s, 0); // Flags - stream_putc(s, PMSI_TNLTYPE_INGR_REPL); // IR (6) + stream_putc(s, attr->pmsi_tnl_type); stream_put(s, &(attr->label), BGP_LABEL_BYTES); // MPLS Label / VXLAN VNI stream_put_ipv4(s, attr->nexthop.s_addr); diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 5a67cc4209..bf162b201a 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1769,8 +1769,10 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn, ZEBRA_MACIP_TYPE_ROUTER_FLAG) ? 1 : 0; /* PMSI is only needed for type-3 routes */ - if (p->prefix.route_type == BGP_EVPN_IMET_ROUTE) + if (p->prefix.route_type == BGP_EVPN_IMET_ROUTE) { attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL); + attr.pmsi_tnl_type = PMSI_TNLTYPE_INGR_REPL; + } /* router mac is only needed for type-2 routes here. */ if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 59ca223a2d..466d79ff60 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8405,11 +8405,15 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p, json_pmsi = json_object_new_object(); json_object_string_add(json_pmsi, "tunnelType", str); + json_object_int_add(json_pmsi, + "label", + label2vni(&attr->label)); json_object_object_add(json_path, "pmsi", json_pmsi); } else - vty_out(vty, " PMSI Tunnel Type: %s\n", - str); + vty_out(vty, + " PMSI Tunnel Type: %s, label: %d\n", + str, label2vni(&attr->label)); } } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index a6d985ab9f..93d89668e7 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1945,7 +1945,7 @@ DEFUN (no_bgp_graceful_restart, DEFUN (bgp_graceful_restart_stalepath_time, bgp_graceful_restart_stalepath_time_cmd, - "bgp graceful-restart stalepath-time (1-3600)", + "bgp graceful-restart stalepath-time (1-4095)", "BGP specific commands\n" "Graceful restart capability parameters\n" "Set the max time to hold onto restarting peer's stale paths\n" @@ -1962,7 +1962,7 @@ DEFUN (bgp_graceful_restart_stalepath_time, DEFUN (bgp_graceful_restart_restart_time, bgp_graceful_restart_restart_time_cmd, - "bgp graceful-restart restart-time (1-3600)", + "bgp graceful-restart restart-time (1-4095)", "BGP specific commands\n" "Graceful restart capability parameters\n" "Set the time to wait to delete stale routes before a BGP open message is received\n" @@ -1979,7 +1979,7 @@ DEFUN (bgp_graceful_restart_restart_time, DEFUN (no_bgp_graceful_restart_stalepath_time, no_bgp_graceful_restart_stalepath_time_cmd, - "no bgp graceful-restart stalepath-time [(1-3600)]", + "no bgp graceful-restart stalepath-time [(1-4095)]", NO_STR "BGP specific commands\n" "Graceful restart capability parameters\n" @@ -1994,7 +1994,7 @@ DEFUN (no_bgp_graceful_restart_stalepath_time, DEFUN (no_bgp_graceful_restart_restart_time, no_bgp_graceful_restart_restart_time_cmd, - "no bgp graceful-restart restart-time [(1-3600)]", + "no bgp graceful-restart restart-time [(1-4095)]", NO_STR "BGP specific commands\n" "Graceful restart capability parameters\n" diff --git a/bgpd/subdir.am b/bgpd/subdir.am index 40ea976634..aed2939d3e 100644 --- a/bgpd/subdir.am +++ b/bgpd/subdir.am @@ -191,12 +191,15 @@ noinst_HEADERS += \ bgpd_bgpd_SOURCES = bgpd/bgp_main.c bgpd_bgp_btoa_SOURCES = bgpd/bgp_btoa.c +bgpd_bgpd_CFLAGS = $(AM_CFLAGS) +bgpd_bgp_btoa_CFLAGS = $(AM_CFLAGS) + if ENABLE_BGP_VNC bgpd_bgpd_SOURCES += bgpd/rfapi/rfapi_descriptor_rfp_utils.c -bgpd_bgpd_CFLAGS = $(AM_CFLAGS) -Irfapi -I@top_srcdir@/$(RFPINC) +bgpd_bgpd_CFLAGS += -Irfapi -I@top_srcdir@/$(RFPINC) bgpd_bgp_btoa_SOURCES += bgpd/rfapi/rfapi_descriptor_rfp_utils.c -bgpd_bgp_btoa_CFLAGS = $(AM_CFLAGS) -Irfapi -I@top_srcdir@/$(RFPINC) +bgpd_bgp_btoa_CFLAGS += -Irfapi -I@top_srcdir@/$(RFPINC) endif # RFPLDADD is set in bgpd/rfp-example/librfp/subdir.am diff --git a/configure.ac b/configure.ac index 17227f2e0b..936e1ccda6 100755 --- a/configure.ac +++ b/configure.ac @@ -147,7 +147,7 @@ dnl - specifically, options to control warnings AC_USE_SYSTEM_EXTENSIONS AC_DEFUN([AC_C_FLAG], [{ - m4_pushdef([cachename],[m4_translit([frr_cv_$1],[ =-],[___])]) + m4_pushdef([cachename],[m4_translit([frr_cv_$1],[ =-+],[____])]) AC_CACHE_CHECK([[whether $CC supports $1]], cachename, [ AC_LANG_PUSH([C]) ac_c_flag_save="$CFLAGS" @@ -261,6 +261,9 @@ fi AC_C_FLAG([-Wno-unused-parameter]) AC_C_FLAG([-Wno-missing-field-initializers]) +AC_C_FLAG([-Wc++-compat], [], [CXX_COMPAT_CFLAGS="-Wc++-compat"]) +AC_SUBST([CXX_COMPAT_CFLAGS]) + dnl ICC emits a broken warning for const char *x = a ? "b" : "c"; dnl for some reason the string consts get 'promoted' to char *, dnl triggering a const to non-const conversion warning. diff --git a/doc/developer/memtypes.rst b/doc/developer/memtypes.rst index d43bc2555e..43cbe002cf 100644 --- a/doc/developer/memtypes.rst +++ b/doc/developer/memtypes.rst @@ -95,7 +95,7 @@ Usage .. c:function:: void *XCALLOC(struct memtype *mtype, size_t size) -.. c:function:: void *XSTRDUP(struct memtype *mtype, size_t size) +.. c:function:: void *XSTRDUP(struct memtype *mtype, const char *name) Allocation wrappers for malloc/calloc/realloc/strdup, taking an extra mtype parameter. diff --git a/doc/user/sharp.rst b/doc/user/sharp.rst index a78fac8fc1..ca8f1f512f 100644 --- a/doc/user/sharp.rst +++ b/doc/user/sharp.rst @@ -71,10 +71,15 @@ keyword. At present, no sharp commands will be preserved in the config. be used for pop and forward operations when the specified label is seen. .. index:: sharp watch -.. clicmd:: sharp watch nexthop <A.B.C.D|X:X::X:X> +.. clicmd:: [no] sharp watch <nexthop|import> <A.B.C.D|X:X::X:X> [connected] Instruct zebra to monitor and notify sharp when the specified nexthop is changed. The notification from zebra is written into the debug log. + The nexthop or import choice chooses the type of nexthop we are asking + zebra to watch for us. This choice affects zebra's decision on what + matches. Connected tells zebra whether or not that we want the route + matched against to be a static or connected route. The no form of + the command obviously turns this watching off. .. index:: sharp data nexthop .. clicmd:: sharp data nexthop diff --git a/docker/debian/Dockerfile b/docker/debian/Dockerfile new file mode 100644 index 0000000000..4f192ec33e --- /dev/null +++ b/docker/debian/Dockerfile @@ -0,0 +1,10 @@ +FROM debian:stretch +MAINTAINER Rob Gil (rob@rem5.com) +RUN apt-get update +RUN apt-get install -y libpcre3-dev apt-transport-https ca-certificates curl wget logrotate \ + libc-ares2 libjson-c3 vim systemd procps +RUN curl -sLO https://ci1.netdef.org/artifact/LIBYANG-YANGRELEASE/shared/build-1/Debian-9-x86_64-Packages/libyang_0.16.46_amd64.deb && dpkg -i libyang_0.16.46_amd64.deb +RUN curl -sLO https://github.com/FRRouting/frr/releases/download/frr-6.0.2/frr_6.0.2-0.deb9u1_amd64.deb && dpkg -i frr_6.0.2-0.deb9u1_amd64.deb +ADD daemons /etc/frr/daemons +ADD docker-start /usr/sbin/docker-start +ENTRYPOINT ["/usr/sbin/docker-start"] diff --git a/docker/debian/README.md b/docker/debian/README.md new file mode 100644 index 0000000000..b10d696a78 --- /dev/null +++ b/docker/debian/README.md @@ -0,0 +1,17 @@ +# Debian9 Docker +This is a binary docker container build of debian9. + +# Build +``` +docker build --rm -t frr:6.0.2 . +``` + +# Running +``` +docker run -itd --privileged --name frr frr:latest +``` + +vtysh +``` +docker exec -it frr vtysh +``` diff --git a/docker/debian/daemons b/docker/debian/daemons new file mode 100644 index 0000000000..ed4d98e1f8 --- /dev/null +++ b/docker/debian/daemons @@ -0,0 +1,65 @@ +# This file tells the frr package which daemons to start. +# +# Sample configurations for these daemons can be found in +# /usr/share/doc/frr/examples/. +# +# ATTENTION: +# +# When activation a daemon at the first time, a config file, even if it is +# empty, has to be present *and* be owned by the user and group "frr", else +# the daemon will not be started by /etc/init.d/frr. The permissions should +# be u=rw,g=r,o=. +# When using "vtysh" such a config file is also needed. It should be owned by +# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too. +# +# The watchfrr and zebra daemons are always started. +# +bgpd=yes +ospfd=no +ospf6d=no +ripd=no +ripngd=no +isisd=no +pimd=no +ldpd=no +nhrpd=no +eigrpd=no +babeld=no +sharpd=no +pbrd=no +bfdd=no +fabricd=no + +# +# If this option is set the /etc/init.d/frr script automatically loads +# the config via "vtysh -b" when the servers are started. +# Check /etc/pam.d/frr if you intend to use "vtysh"! +# +vtysh_enable=yes +zebra_options=" -A 127.0.0.1 -s 90000000" +bgpd_options=" -A 127.0.0.1" +ospfd_options=" -A 127.0.0.1" +ospf6d_options=" -A ::1" +ripd_options=" -A 127.0.0.1" +ripngd_options=" -A ::1" +isisd_options=" -A 127.0.0.1" +pimd_options=" -A 127.0.0.1" +ldpd_options=" -A 127.0.0.1" +nhrpd_options=" -A 127.0.0.1" +eigrpd_options=" -A 127.0.0.1" +babeld_options=" -A 127.0.0.1" +sharpd_options=" -A 127.0.0.1" +pbrd_options=" -A 127.0.0.1" +staticd_options="-A 127.0.0.1" +bfdd_options=" -A 127.0.0.1" +fabricd_options="-A 127.0.0.1" + +# The list of daemons to watch is automatically generated by the init script. +watchfrr_options="-r '/usr/lib/frr/watchfrr.sh restart %s' -s '/usr/lib/frr/watchfrr.sh start %s' -k '/usr/lib/frr/watchfrr.sh stop %s'" + +# for debugging purposes, you can specify a "wrap" command to start instead +# of starting the daemon directly, e.g. to use valgrind on ospfd: +# ospfd_wrap="/usr/bin/valgrind" +# or you can use "all_wrap" for all daemons, e.g. to use perf record: +# all_wrap="/usr/bin/perf record --call-graph -" +# the normal daemon command is added to this at the end. diff --git a/docker/debian/docker-start b/docker/debian/docker-start new file mode 100755 index 0000000000..43854ab142 --- /dev/null +++ b/docker/debian/docker-start @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +## +# For volume mounts... +## +chown -R frr:frr /etc/frr +/etc/init.d/frr start +exec sleep 10000d diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index c68f49f92d..bd8b58e8f0 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -89,7 +89,7 @@ DEFPY(no_router_isis, no_router_isis_cmd, "no router isis WORD$tag", return CMD_ERR_NOTHING_TODO; } - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); area = isis_area_lookup(tag); if (area && area->circuit_list && listcount(area->circuit_list)) { for (ALL_LIST_ELEMENTS(area->circuit_list, node, nnode, @@ -103,7 +103,7 @@ DEFPY(no_router_isis, no_router_isis_cmd, "no router isis WORD$tag", temp_xpath, XPATH_MAXLEN, "/frr-interface:lib/interface[name='%s'][vrf='%s']/frr-isisd:isis", circuit->interface->name, vrf_name); - nb_cli_enqueue_change(vty, temp_xpath, NB_OP_DELETE, + nb_cli_enqueue_change(vty, temp_xpath, NB_OP_DESTROY, NULL); } } @@ -289,7 +289,7 @@ DEFPY(no_ip_router_isis, no_ip_router_isis_cmd, && !yang_dnode_get_bool(dnode, "./frr-isisd:isis/ipv4-routing")) nb_cli_enqueue_change(vty, "./frr-isisd:isis", - NB_OP_DELETE, NULL); + NB_OP_DESTROY, NULL); else nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv6-routing", @@ -299,7 +299,7 @@ DEFPY(no_ip_router_isis, no_ip_router_isis_cmd, && !yang_dnode_get_bool(dnode, "./frr-isisd:isis/ipv6-routing")) nb_cli_enqueue_change(vty, "./frr-isisd:isis", - NB_OP_DELETE, NULL); + NB_OP_DESTROY, NULL); else nb_cli_enqueue_change(vty, "./frr-isisd:isis/ipv4-routing", @@ -336,7 +336,7 @@ DEFPY(net, net_cmd, "[no] net WORD", "XX.XXXX. ... .XXX.XX Network entity title (NET)\n") { nb_cli_enqueue_change(vty, "./area-address", - no ? NB_OP_DELETE : NB_OP_CREATE, net); + no ? NB_OP_DESTROY : NB_OP_CREATE, net); return nb_cli_apply_changes(vty, NULL); } @@ -589,7 +589,7 @@ DEFPY(no_area_passwd, no_area_passwd_cmd, "Configure the authentication password for an area\n" "Set the authentication password for a routing domain\n") { - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, "./%s", cmd); } @@ -892,7 +892,7 @@ DEFPY(no_spf_delay_ietf, no_spf_delay_ietf_cmd, "Maximum duration needed to learn all the events related to a single failure\n" "Maximum duration needed to learn all the events related to a single failure (in milliseconds)\n") { - nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay", NB_OP_DELETE, + nb_cli_enqueue_change(vty, "./spf/ietf-backoff-delay", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); @@ -947,7 +947,7 @@ DEFPY(no_isis_mpls_te_on, no_isis_mpls_te_on_cmd, "no mpls-te [on]", "Disable the MPLS-TE functionality\n" "Enable the MPLS-TE functionality\n") { - nb_cli_enqueue_change(vty, "/frr-isisd:isis/mpls-te", NB_OP_DELETE, + nb_cli_enqueue_change(vty, "/frr-isisd:isis/mpls-te", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); @@ -1014,16 +1014,16 @@ DEFPY(isis_default_originate, isis_default_originate_cmd, "Pointer to route-map entries\n") { if (no) - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); else { nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); nb_cli_enqueue_change(vty, "./always", NB_OP_MODIFY, always ? "true" : "false"); nb_cli_enqueue_change(vty, "./route-map", - rmap ? NB_OP_MODIFY : NB_OP_DELETE, + rmap ? NB_OP_MODIFY : NB_OP_DESTROY, rmap ? rmap : NULL); nb_cli_enqueue_change(vty, "./metric", - metric ? NB_OP_MODIFY : NB_OP_DELETE, + metric ? NB_OP_MODIFY : NB_OP_DESTROY, metric ? metric_str : NULL); if (strmatch(ip, "ipv6") && !always) { vty_out(vty, @@ -1094,14 +1094,14 @@ DEFPY(isis_redistribute, isis_redistribute_cmd, "Pointer to route-map entries\n") { if (no) - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); else { nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); nb_cli_enqueue_change(vty, "./route-map", - route_map ? NB_OP_MODIFY : NB_OP_DELETE, + route_map ? NB_OP_MODIFY : NB_OP_DESTROY, route_map ? route_map : NULL); nb_cli_enqueue_change(vty, "./metric", - metric ? NB_OP_MODIFY : NB_OP_DELETE, + metric ? NB_OP_MODIFY : NB_OP_DESTROY, metric ? metric_str : NULL); } @@ -1182,7 +1182,7 @@ DEFPY(isis_topology, isis_topology_cmd, topology); if (no) - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); else { nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); nb_cli_enqueue_change(vty, "./overload", NB_OP_MODIFY, @@ -1297,7 +1297,7 @@ DEFPY(no_isis_passwd, no_isis_passwd_cmd, "no isis password [<md5|clear> WORD]", "Cleartext password\n" "Circuit password\n") { - nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_DELETE, + nb_cli_enqueue_change(vty, "./frr-isisd:isis/password", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 658624370b..b56a56fa3f 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -1930,6 +1930,27 @@ int lsp_tick(struct thread *thread) area->area_tag, lsp->level, rawlspid_print(lsp->hdr.lsp_id), lsp->hdr.seqno); + + /* if we're aging out fragment 0, + * lsp_destroy() below will delete all + * other fragments too, so we need to + * skip over those + */ + while (!LSP_FRAGMENT(lsp->hdr.lsp_id) + && dnode_next) { + struct isis_lsp *nextlsp; + + nextlsp = dnode_get(dnode_next); + if (memcmp(nextlsp->hdr.lsp_id, + lsp->hdr.lsp_id, + ISIS_SYS_ID_LEN + 1)) + break; + + dnode_next = dict_next( + area->lspdb[level], + dnode_next); + } + lsp_destroy(lsp); lsp = NULL; dict_delete_free(area->lspdb[level], diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c index 9c2bb1728e..3364a9f0be 100644 --- a/isisd/isis_northbound.c +++ b/isisd/isis_northbound.c @@ -72,7 +72,7 @@ static int isis_instance_create(enum nb_event event, return NB_OK; } -static int isis_instance_delete(enum nb_event event, +static int isis_instance_destroy(enum nb_event event, const struct lyd_node *dnode) { const char *area_tag; @@ -193,7 +193,7 @@ static int isis_instance_area_address_create(enum nb_event event, return NB_OK; } -static int isis_instance_area_address_delete(enum nb_event event, +static int isis_instance_area_address_destroy(enum nb_event event, const struct lyd_node *dnode) { struct area_addr addr, *addrp = NULL; @@ -536,7 +536,7 @@ isis_instance_spf_ietf_backoff_delay_create(enum nb_event event, } static int -isis_instance_spf_ietf_backoff_delay_delete(enum nb_event event, +isis_instance_spf_ietf_backoff_delay_destroy(enum nb_event event, const struct lyd_node *dnode) { struct isis_area *area; @@ -676,7 +676,7 @@ static int isis_instance_area_password_create(enum nb_event event, return NB_OK; } -static int isis_instance_area_password_delete(enum nb_event event, +static int isis_instance_area_password_destroy(enum nb_event event, const struct lyd_node *dnode) { struct isis_area *area; @@ -755,7 +755,7 @@ static int isis_instance_domain_password_create(enum nb_event event, return NB_OK; } -static int isis_instance_domain_password_delete(enum nb_event event, +static int isis_instance_domain_password_destroy(enum nb_event event, const struct lyd_node *dnode) { struct isis_area *area; @@ -851,7 +851,7 @@ static int isis_instance_default_information_originate_ipv4_create( return NB_OK; } -static int isis_instance_default_information_originate_ipv4_delete( +static int isis_instance_default_information_originate_ipv4_destroy( enum nb_event event, const struct lyd_node *dnode) { struct isis_area *area; @@ -889,7 +889,7 @@ static int isis_instance_default_information_originate_ipv4_route_map_modify( return NB_OK; } -static int isis_instance_default_information_originate_ipv4_route_map_delete( +static int isis_instance_default_information_originate_ipv4_route_map_destroy( enum nb_event event, const struct lyd_node *dnode) { /* It's all done by default_info_origin_apply_finish */ @@ -907,7 +907,7 @@ static int isis_instance_default_information_originate_ipv4_metric_modify( return NB_OK; } -static int isis_instance_default_information_originate_ipv4_metric_delete( +static int isis_instance_default_information_originate_ipv4_metric_destroy( enum nb_event event, const struct lyd_node *dnode) { /* It's all done by default_info_origin_apply_finish */ @@ -925,7 +925,7 @@ static int isis_instance_default_information_originate_ipv6_create( return NB_OK; } -static int isis_instance_default_information_originate_ipv6_delete( +static int isis_instance_default_information_originate_ipv6_destroy( enum nb_event event, const struct lyd_node *dnode) { struct isis_area *area; @@ -963,7 +963,7 @@ static int isis_instance_default_information_originate_ipv6_route_map_modify( return NB_OK; } -static int isis_instance_default_information_originate_ipv6_route_map_delete( +static int isis_instance_default_information_originate_ipv6_route_map_destroy( enum nb_event event, const struct lyd_node *dnode) { /* It's all done by default_info_origin_apply_finish */ @@ -981,7 +981,7 @@ static int isis_instance_default_information_originate_ipv6_metric_modify( return NB_OK; } -static int isis_instance_default_information_originate_ipv6_metric_delete( +static int isis_instance_default_information_originate_ipv6_metric_destroy( enum nb_event event, const struct lyd_node *dnode) { /* It's all done by default_info_origin_apply_finish */ @@ -1029,7 +1029,7 @@ static int isis_instance_redistribute_ipv4_create(enum nb_event event, return NB_OK; } -static int isis_instance_redistribute_ipv4_delete(enum nb_event event, +static int isis_instance_redistribute_ipv4_destroy(enum nb_event event, const struct lyd_node *dnode) { struct isis_area *area; @@ -1059,7 +1059,7 @@ isis_instance_redistribute_ipv4_route_map_modify(enum nb_event event, } static int -isis_instance_redistribute_ipv4_route_map_delete(enum nb_event event, +isis_instance_redistribute_ipv4_route_map_destroy(enum nb_event event, const struct lyd_node *dnode) { /* It's all done by redistribute_apply_finish */ @@ -1079,7 +1079,7 @@ isis_instance_redistribute_ipv4_metric_modify(enum nb_event event, } static int -isis_instance_redistribute_ipv4_metric_delete(enum nb_event event, +isis_instance_redistribute_ipv4_metric_destroy(enum nb_event event, const struct lyd_node *dnode) { /* It's all done by redistribute_apply_finish */ @@ -1097,7 +1097,7 @@ static int isis_instance_redistribute_ipv6_create(enum nb_event event, return NB_OK; } -static int isis_instance_redistribute_ipv6_delete(enum nb_event event, +static int isis_instance_redistribute_ipv6_destroy(enum nb_event event, const struct lyd_node *dnode) { struct isis_area *area; @@ -1127,7 +1127,7 @@ isis_instance_redistribute_ipv6_route_map_modify(enum nb_event event, } static int -isis_instance_redistribute_ipv6_route_map_delete(enum nb_event event, +isis_instance_redistribute_ipv6_route_map_destroy(enum nb_event event, const struct lyd_node *dnode) { /* It's all done by redistribute_apply_finish */ @@ -1147,7 +1147,7 @@ isis_instance_redistribute_ipv6_metric_modify(enum nb_event event, } static int -isis_instance_redistribute_ipv6_metric_delete(enum nb_event event, +isis_instance_redistribute_ipv6_metric_destroy(enum nb_event event, const struct lyd_node *dnode) { /* It's all done by redistribute_apply_finish */ @@ -1217,7 +1217,7 @@ isis_instance_multi_topology_ipv4_multicast_create(enum nb_event event, } static int -isis_instance_multi_topology_ipv4_multicast_delete(enum nb_event event, +isis_instance_multi_topology_ipv4_multicast_destroy(enum nb_event event, const struct lyd_node *dnode) { return isis_multi_topology_common(event, dnode, "ipv4-multicast", @@ -1245,7 +1245,7 @@ static int isis_instance_multi_topology_ipv4_management_create( return isis_multi_topology_common(event, dnode, "ipv4-mgmt", true); } -static int isis_instance_multi_topology_ipv4_management_delete( +static int isis_instance_multi_topology_ipv4_management_destroy( enum nb_event event, const struct lyd_node *dnode) { return isis_multi_topology_common(event, dnode, "ipv4-mgmt", false); @@ -1273,7 +1273,7 @@ isis_instance_multi_topology_ipv6_unicast_create(enum nb_event event, } static int -isis_instance_multi_topology_ipv6_unicast_delete(enum nb_event event, +isis_instance_multi_topology_ipv6_unicast_destroy(enum nb_event event, const struct lyd_node *dnode) { return isis_multi_topology_common(event, dnode, "ipv6-unicast", false); @@ -1302,7 +1302,7 @@ isis_instance_multi_topology_ipv6_multicast_create(enum nb_event event, } static int -isis_instance_multi_topology_ipv6_multicast_delete(enum nb_event event, +isis_instance_multi_topology_ipv6_multicast_destroy(enum nb_event event, const struct lyd_node *dnode) { return isis_multi_topology_common(event, dnode, "ipv6-multicast", @@ -1330,7 +1330,7 @@ static int isis_instance_multi_topology_ipv6_management_create( return isis_multi_topology_common(event, dnode, "ipv6-mgmt", true); } -static int isis_instance_multi_topology_ipv6_management_delete( +static int isis_instance_multi_topology_ipv6_management_destroy( enum nb_event event, const struct lyd_node *dnode) { return isis_multi_topology_common(event, dnode, "ipv6-mgmt", false); @@ -1358,7 +1358,7 @@ isis_instance_multi_topology_ipv6_dstsrc_create(enum nb_event event, } static int -isis_instance_multi_topology_ipv6_dstsrc_delete(enum nb_event event, +isis_instance_multi_topology_ipv6_dstsrc_destroy(enum nb_event event, const struct lyd_node *dnode) { return isis_multi_topology_common(event, dnode, "ipv6-dstsrc", false); @@ -1436,7 +1436,7 @@ static int isis_mpls_te_create(enum nb_event event, return NB_OK; } -static int isis_mpls_te_delete(enum nb_event event, +static int isis_mpls_te_destroy(enum nb_event event, const struct lyd_node *dnode) { struct listnode *node; @@ -1494,7 +1494,7 @@ static int isis_mpls_te_router_address_modify(enum nb_event event, return NB_OK; } -static int isis_mpls_te_router_address_delete(enum nb_event event, +static int isis_mpls_te_router_address_destroy(enum nb_event event, const struct lyd_node *dnode) { struct listnode *node; @@ -1555,7 +1555,7 @@ static int lib_interface_isis_create(enum nb_event event, return NB_OK; } -static int lib_interface_isis_delete(enum nb_event event, +static int lib_interface_isis_destroy(enum nb_event event, const struct lyd_node *dnode) { struct isis_circuit *circuit; @@ -2062,7 +2062,7 @@ static int lib_interface_isis_password_create(enum nb_event event, return NB_OK; } -static int lib_interface_isis_password_delete(enum nb_event event, +static int lib_interface_isis_password_destroy(enum nb_event event, const struct lyd_node *dnode) { struct isis_circuit *circuit; @@ -2749,7 +2749,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance", .cbs.create = isis_instance_create, - .cbs.delete = isis_instance_delete, + .cbs.destroy = isis_instance_destroy, .cbs.cli_show = cli_show_router_isis, .priority = NB_DFLT_PRIORITY - 1, }, @@ -2761,7 +2761,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/area-address", .cbs.create = isis_instance_area_address_create, - .cbs.delete = isis_instance_area_address_delete, + .cbs.destroy = isis_instance_area_address_destroy, .cbs.cli_show = cli_show_isis_area_address, }, { @@ -2833,7 +2833,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/spf/ietf-backoff-delay", .cbs.create = isis_instance_spf_ietf_backoff_delay_create, - .cbs.delete = isis_instance_spf_ietf_backoff_delay_delete, + .cbs.destroy = isis_instance_spf_ietf_backoff_delay_destroy, .cbs.apply_finish = ietf_backoff_delay_apply_finish, .cbs.cli_show = cli_show_isis_spf_ietf_backoff, }, @@ -2872,7 +2872,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/area-password", .cbs.create = isis_instance_area_password_create, - .cbs.delete = isis_instance_area_password_delete, + .cbs.destroy = isis_instance_area_password_destroy, .cbs.apply_finish = area_password_apply_finish, .cbs.cli_show = cli_show_isis_area_pwd, }, @@ -2891,7 +2891,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/domain-password", .cbs.create = isis_instance_domain_password_create, - .cbs.delete = isis_instance_domain_password_delete, + .cbs.destroy = isis_instance_domain_password_destroy, .cbs.apply_finish = domain_password_apply_finish, .cbs.cli_show = cli_show_isis_domain_pwd, }, @@ -2910,7 +2910,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4", .cbs.create = isis_instance_default_information_originate_ipv4_create, - .cbs.delete = isis_instance_default_information_originate_ipv4_delete, + .cbs.destroy = isis_instance_default_information_originate_ipv4_destroy, .cbs.apply_finish = default_info_origin_ipv4_apply_finish, .cbs.cli_show = cli_show_isis_def_origin_ipv4, }, @@ -2921,17 +2921,17 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/route-map", .cbs.modify = isis_instance_default_information_originate_ipv4_route_map_modify, - .cbs.delete = isis_instance_default_information_originate_ipv4_route_map_delete, + .cbs.destroy = isis_instance_default_information_originate_ipv4_route_map_destroy, }, { .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv4/metric", .cbs.modify = isis_instance_default_information_originate_ipv4_metric_modify, - .cbs.delete = isis_instance_default_information_originate_ipv4_metric_delete, + .cbs.destroy = isis_instance_default_information_originate_ipv4_metric_destroy, }, { .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6", .cbs.create = isis_instance_default_information_originate_ipv6_create, - .cbs.delete = isis_instance_default_information_originate_ipv6_delete, + .cbs.destroy = isis_instance_default_information_originate_ipv6_destroy, .cbs.apply_finish = default_info_origin_ipv6_apply_finish, .cbs.cli_show = cli_show_isis_def_origin_ipv6, }, @@ -2942,51 +2942,51 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/route-map", .cbs.modify = isis_instance_default_information_originate_ipv6_route_map_modify, - .cbs.delete = isis_instance_default_information_originate_ipv6_route_map_delete, + .cbs.destroy = isis_instance_default_information_originate_ipv6_route_map_destroy, }, { .xpath = "/frr-isisd:isis/instance/default-information-originate/ipv6/metric", .cbs.modify = isis_instance_default_information_originate_ipv6_metric_modify, - .cbs.delete = isis_instance_default_information_originate_ipv6_metric_delete, + .cbs.destroy = isis_instance_default_information_originate_ipv6_metric_destroy, }, { .xpath = "/frr-isisd:isis/instance/redistribute/ipv4", .cbs.create = isis_instance_redistribute_ipv4_create, - .cbs.delete = isis_instance_redistribute_ipv4_delete, + .cbs.destroy = isis_instance_redistribute_ipv4_destroy, .cbs.apply_finish = redistribute_ipv4_apply_finish, .cbs.cli_show = cli_show_isis_redistribute_ipv4, }, { .xpath = "/frr-isisd:isis/instance/redistribute/ipv4/route-map", .cbs.modify = isis_instance_redistribute_ipv4_route_map_modify, - .cbs.delete = isis_instance_redistribute_ipv4_route_map_delete, + .cbs.destroy = isis_instance_redistribute_ipv4_route_map_destroy, }, { .xpath = "/frr-isisd:isis/instance/redistribute/ipv4/metric", .cbs.modify = isis_instance_redistribute_ipv4_metric_modify, - .cbs.delete = isis_instance_redistribute_ipv4_metric_delete, + .cbs.destroy = isis_instance_redistribute_ipv4_metric_destroy, }, { .xpath = "/frr-isisd:isis/instance/redistribute/ipv6", .cbs.create = isis_instance_redistribute_ipv6_create, - .cbs.delete = isis_instance_redistribute_ipv6_delete, + .cbs.destroy = isis_instance_redistribute_ipv6_destroy, .cbs.apply_finish = redistribute_ipv6_apply_finish, .cbs.cli_show = cli_show_isis_redistribute_ipv6, }, { .xpath = "/frr-isisd:isis/instance/redistribute/ipv6/route-map", .cbs.modify = isis_instance_redistribute_ipv6_route_map_modify, - .cbs.delete = isis_instance_redistribute_ipv6_route_map_delete, + .cbs.destroy = isis_instance_redistribute_ipv6_route_map_destroy, }, { .xpath = "/frr-isisd:isis/instance/redistribute/ipv6/metric", .cbs.modify = isis_instance_redistribute_ipv6_metric_modify, - .cbs.delete = isis_instance_redistribute_ipv6_metric_delete, + .cbs.destroy = isis_instance_redistribute_ipv6_metric_destroy, }, { .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-multicast", .cbs.create = isis_instance_multi_topology_ipv4_multicast_create, - .cbs.delete = isis_instance_multi_topology_ipv4_multicast_delete, + .cbs.destroy = isis_instance_multi_topology_ipv4_multicast_destroy, .cbs.cli_show = cli_show_isis_mt_ipv4_multicast, }, { @@ -2996,7 +2996,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/multi-topology/ipv4-management", .cbs.create = isis_instance_multi_topology_ipv4_management_create, - .cbs.delete = isis_instance_multi_topology_ipv4_management_delete, + .cbs.destroy = isis_instance_multi_topology_ipv4_management_destroy, .cbs.cli_show = cli_show_isis_mt_ipv4_mgmt, }, { @@ -3006,7 +3006,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-unicast", .cbs.create = isis_instance_multi_topology_ipv6_unicast_create, - .cbs.delete = isis_instance_multi_topology_ipv6_unicast_delete, + .cbs.destroy = isis_instance_multi_topology_ipv6_unicast_destroy, .cbs.cli_show = cli_show_isis_mt_ipv6_unicast, }, { @@ -3016,7 +3016,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-multicast", .cbs.create = isis_instance_multi_topology_ipv6_multicast_create, - .cbs.delete = isis_instance_multi_topology_ipv6_multicast_delete, + .cbs.destroy = isis_instance_multi_topology_ipv6_multicast_destroy, .cbs.cli_show = cli_show_isis_mt_ipv6_multicast, }, { @@ -3026,7 +3026,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-management", .cbs.create = isis_instance_multi_topology_ipv6_management_create, - .cbs.delete = isis_instance_multi_topology_ipv6_management_delete, + .cbs.destroy = isis_instance_multi_topology_ipv6_management_destroy, .cbs.cli_show = cli_show_isis_mt_ipv6_mgmt, }, { @@ -3036,7 +3036,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/multi-topology/ipv6-dstsrc", .cbs.create = isis_instance_multi_topology_ipv6_dstsrc_create, - .cbs.delete = isis_instance_multi_topology_ipv6_dstsrc_delete, + .cbs.destroy = isis_instance_multi_topology_ipv6_dstsrc_destroy, .cbs.cli_show = cli_show_isis_mt_ipv6_dstsrc, }, { @@ -3051,19 +3051,19 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/mpls-te", .cbs.create = isis_mpls_te_create, - .cbs.delete = isis_mpls_te_delete, + .cbs.destroy = isis_mpls_te_destroy, .cbs.cli_show = cli_show_isis_mpls_te, }, { .xpath = "/frr-isisd:isis/mpls-te/router-address", .cbs.modify = isis_mpls_te_router_address_modify, - .cbs.delete = isis_mpls_te_router_address_delete, + .cbs.destroy = isis_mpls_te_router_address_destroy, .cbs.cli_show = cli_show_isis_mpls_te_router_addr, }, { .xpath = "/frr-interface:lib/interface/frr-isisd:isis", .cbs.create = lib_interface_isis_create, - .cbs.delete = lib_interface_isis_delete, + .cbs.destroy = lib_interface_isis_destroy, }, { .xpath = "/frr-interface:lib/interface/frr-isisd:isis/area-tag", @@ -3174,7 +3174,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-interface:lib/interface/frr-isisd:isis/password", .cbs.create = lib_interface_isis_password_create, - .cbs.delete = lib_interface_isis_password_delete, + .cbs.destroy = lib_interface_isis_password_destroy, .cbs.cli_show = cli_show_ip_isis_password, }, { diff --git a/lib/agg_table.h b/lib/agg_table.h index dc2ff03b67..40ffe8c755 100644 --- a/lib/agg_table.h +++ b/lib/agg_table.h @@ -23,6 +23,10 @@ #include "prefix.h" #include "table.h" +#ifdef __cplusplus +extern "C" { +#endif + struct agg_table { struct route_table *route_table; @@ -150,4 +154,9 @@ static inline struct agg_table *agg_get_table(struct agg_node *node) { return (struct agg_table *)route_table_get_info(node->table); } + +#ifdef __cplusplus +} +#endif + #endif @@ -26,6 +26,10 @@ #include "lib/json.h" #include "lib/zclient.h" +#ifdef __cplusplus +extern "C" { +#endif + #define BFD_DEF_MIN_RX 300 #define BFD_MIN_MIN_RX 50 #define BFD_MAX_MIN_RX 60000 @@ -104,4 +108,8 @@ extern void bfd_gbl_init(void); extern void bfd_gbl_exit(void); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_BFD_H */ diff --git a/lib/bitfield.h b/lib/bitfield.h index 0e031ccc49..eebfc049d9 100644 --- a/lib/bitfield.h +++ b/lib/bitfield.h @@ -44,6 +44,10 @@ #include <string.h> #include <stdlib.h> +#ifdef __cplusplus +extern "C" { +#endif + typedef unsigned int word_t; #define WORD_MAX 0xFFFFFFFF #define WORD_SIZE (sizeof(word_t) * 8) @@ -153,4 +157,8 @@ typedef unsigned int word_t; } \ } while (0) +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/buffer.h b/lib/buffer.h index 0c945a2acf..8b5a89825f 100644 --- a/lib/buffer.h +++ b/lib/buffer.h @@ -22,6 +22,10 @@ #ifndef _ZEBRA_BUFFER_H #define _ZEBRA_BUFFER_H +#ifdef __cplusplus +extern "C" { +#endif + /* Create a new buffer. Memory will be allocated in chunks of the given size. If the argument is 0, the library will supply a reasonable default size suitable for buffering socket I/O. */ @@ -99,4 +103,8 @@ extern buffer_status_t buffer_flush_all(struct buffer *, int fd); extern buffer_status_t buffer_flush_window(struct buffer *, int fd, int width, int height, int erase, int no_more); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_BUFFER_H */ diff --git a/lib/checksum.h b/lib/checksum.h index c2764e35fb..7d50371439 100644 --- a/lib/checksum.h +++ b/lib/checksum.h @@ -1,4 +1,12 @@ +#ifdef __cplusplus +extern "C" { +#endif + extern int in_cksum(void *, int); #define FLETCHER_CHECKSUM_VALIDATE 0xffff extern uint16_t fletcher_checksum(uint8_t *, const size_t len, const uint16_t offset); + +#ifdef __cplusplus +} +#endif diff --git a/lib/clippy.h b/lib/clippy.h index 8df98cbb8e..be4db6e638 100644 --- a/lib/clippy.h +++ b/lib/clippy.h @@ -22,7 +22,15 @@ #include <Python.h> +#ifdef __cplusplus +extern "C" { +#endif + extern PyObject *clippy_parse(PyObject *self, PyObject *args); extern PyMODINIT_FUNC command_py_init(void); +#ifdef __cplusplus +} +#endif + #endif /* _FRR_CLIPPY_H */ diff --git a/lib/command.c b/lib/command.c index 06879f6854..b46241ac87 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1009,7 +1009,7 @@ enum node_type node_parent(enum node_type node) } /* Execute command by argument vline vector. */ -static int cmd_execute_command_real(vector vline, enum filter_type filter, +static int cmd_execute_command_real(vector vline, enum cmd_filter_type filter, struct vty *vty, const struct cmd_element **cmd) { diff --git a/lib/command.h b/lib/command.h index 11514fd5e8..0faaa426ac 100644 --- a/lib/command.h +++ b/lib/command.h @@ -30,6 +30,10 @@ #include "hash.h" #include "command_graph.h" +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(HOST) DECLARE_MTYPE(COMPLETION) @@ -488,4 +492,9 @@ cmd_variable_handler_register(const struct cmd_variable_handler *cvh); extern char *cmd_variable_comp2str(vector comps, unsigned short cols); extern void command_setup_early_logging(const char *dest, const char *level); + +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_COMMAND_H */ diff --git a/lib/command_graph.h b/lib/command_graph.h index 82d562694c..903d515834 100644 --- a/lib/command_graph.h +++ b/lib/command_graph.h @@ -32,6 +32,10 @@ #include "vector.h" #include "graph.h" +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(CMD_ARG) struct vty; @@ -114,7 +118,7 @@ extern void cmd_token_varname_set(struct cmd_token *token, const char *varname); extern void cmd_graph_parse(struct graph *graph, struct cmd_element *cmd); extern void cmd_graph_names(struct graph *graph); -extern void cmd_graph_merge(struct graph *old, struct graph *new, +extern void cmd_graph_merge(struct graph *old, struct graph *n, int direction); /* * Print callback for DOT dumping. @@ -133,4 +137,8 @@ extern void cmd_graph_node_print_cb(struct graph_node *gn, struct buffer *buf); */ char *cmd_graph_dump_dot(struct graph *cmdgraph); +#ifdef __cplusplus +} +#endif + #endif /* _FRR_COMMAND_GRAPH_H */ diff --git a/lib/command_match.h b/lib/command_match.h index c636d2dd95..fcb333120f 100644 --- a/lib/command_match.h +++ b/lib/command_match.h @@ -28,10 +28,14 @@ #include "linklist.h" #include "command.h" +#ifdef __cplusplus +extern "C" { +#endif + /* These definitions exist in command.c in the current engine but should be * relocated here in the new engine */ -enum filter_type { FILTER_RELAXED, FILTER_STRICT }; +enum cmd_filter_type { FILTER_RELAXED, FILTER_STRICT }; /* matcher result value */ enum matcher_rv { @@ -98,4 +102,8 @@ enum matcher_rv command_match(struct graph *cmdgraph, vector vline, enum matcher_rv command_complete(struct graph *cmdgraph, vector vline, struct list **completions); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_COMMAND_MATCH_H */ diff --git a/lib/compiler.h b/lib/compiler.h index 24b8fafd10..cb4f7531ec 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -17,6 +17,10 @@ #ifndef _FRR_COMPILER_H #define _FRR_COMPILER_H +#ifdef __cplusplus +extern "C" { +#endif + /* function attributes, use like * void prototype(void) __attribute__((_CONSTRUCTOR(100))); */ @@ -88,4 +92,8 @@ #define CPP_NOTICE(text) #endif +#ifdef __cplusplus +} +#endif + #endif /* _FRR_COMPILER_H */ @@ -70,6 +70,10 @@ #include <stdarg.h> #include <sys/queue.h> +#ifdef __cplusplus +extern "C" { +#endif + typedef struct _csv_field_t_ csv_field_t; typedef struct _csv_record_t_ csv_record_t; typedef struct _csv_t_ csv_t; @@ -185,4 +189,8 @@ void csv_clone_record(csv_t *csv, csv_record_t *in_rec, csv_record_t **out_rec); */ int csv_num_records(csv_t *csv); +#ifdef __cplusplus +} +#endif + #endif @@ -38,6 +38,10 @@ #include <sqlite3.h> +#ifdef __cplusplus +extern "C" { +#endif + extern int db_init(const char *path_fmt, ...); extern int db_close(void); extern int db_bindf(struct sqlite3_stmt *ss, const char *fmt, ...); @@ -48,5 +52,9 @@ extern int db_loadf(struct sqlite3_stmt *ss, const char *fmt, ...); extern void db_finalize(struct sqlite3_stmt **ss); extern int db_execute(const char *stmt_fmt, ...); +#ifdef __cplusplus +} +#endif + #endif /* HAVE_SQLITE3 */ #endif /* _FRR_DB_H_ */ diff --git a/lib/debug.h b/lib/debug.h index d0fa27d3fe..ace060d057 100644 --- a/lib/debug.h +++ b/lib/debug.h @@ -24,6 +24,10 @@ #include "command.h" #include "frratomic.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Debugging modes. * @@ -76,7 +80,7 @@ * Human-readable description of this debugging record. */ struct debug { - _Atomic uint32_t flags; + atomic_uint_fast32_t flags; const char *desc; }; @@ -231,4 +235,8 @@ struct debug_callbacks { */ void debug_init(const struct debug_callbacks *cb); +#ifdef __cplusplus +} +#endif + #endif /* _FRRDEBUG_H */ diff --git a/lib/distribute.h b/lib/distribute.h index 44c699b38a..4016d3b133 100644 --- a/lib/distribute.h +++ b/lib/distribute.h @@ -25,6 +25,10 @@ #include "if.h" #include "filter.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Disctirubte list types. */ enum distribute_type { DISTRIBUTE_V4_IN, @@ -81,4 +85,8 @@ extern enum filter_type distribute_apply_in(struct interface *, extern enum filter_type distribute_apply_out(struct interface *, struct prefix *); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_DISTRIBUTE_H */ diff --git a/lib/event_counter.h b/lib/event_counter.h index de5dbc0665..8ae276ffef 100644 --- a/lib/event_counter.h +++ b/lib/event_counter.h @@ -43,6 +43,10 @@ #ifndef _ZEBRA_EVENT_COUNTER_H #define _ZEBRA_EVENT_COUNTER_H +#ifdef __cplusplus +extern "C" { +#endif + struct event_counter { unsigned long long count; time_t last; @@ -51,4 +55,8 @@ struct event_counter { void event_counter_inc(struct event_counter *counter); const char *event_counter_format(const struct event_counter *counter); +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/ferr.h b/lib/ferr.h index 335875c166..93d0ced538 100644 --- a/lib/ferr.h +++ b/lib/ferr.h @@ -27,6 +27,10 @@ #include "vty.h" +#ifdef __cplusplus +extern "C" { +#endif + /* return type when this error indication stuff is used. * * guaranteed to have boolean evaluation to "false" when OK, "true" when error @@ -253,4 +257,8 @@ DEFUN("bla") #endif /* THIS_IS_AN_EXAMPLE */ +#ifdef __cplusplus +} +#endif + #endif /* _FERR_H */ diff --git a/lib/fifo.h b/lib/fifo.h index f59e4dc6cd..6f9c59b5c1 100644 --- a/lib/fifo.h +++ b/lib/fifo.h @@ -20,6 +20,10 @@ #ifndef __LIB_FIFO_H__ #define __LIB_FIFO_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* FIFO -- first in first out structure and macros. */ struct fifo { struct fifo *next; @@ -55,4 +59,8 @@ struct fifo { #define FIFO_TOP(F) (FIFO_EMPTY(F) ? NULL : ((struct fifo *)(F))->next) +#ifdef __cplusplus +} +#endif + #endif /* __LIB_FIFO_H__ */ diff --git a/lib/filter.h b/lib/filter.h index 97854b1e97..3dd2eaaf15 100644 --- a/lib/filter.h +++ b/lib/filter.h @@ -24,6 +24,10 @@ #include "if.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Maximum ACL name length */ #define ACL_NAMSIZ 128 @@ -62,4 +66,8 @@ extern struct access_list *access_list_lookup(afi_t, const char *); extern enum filter_type access_list_apply(struct access_list *access, const void *object); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_FILTER_H */ diff --git a/lib/freebsd-queue.h b/lib/freebsd-queue.h index 4fcfe85a68..793cfff8d3 100644 --- a/lib/freebsd-queue.h +++ b/lib/freebsd-queue.h @@ -33,6 +33,10 @@ #ifndef _SYS_QUEUE_H_ #define _SYS_QUEUE_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* * This file defines four types of data structures: singly-linked lists, * singly-linked tail queues, lists and tail queues. @@ -675,4 +679,8 @@ struct qm_trace { (head2)->tqh_last = &(head2)->tqh_first; \ } while (0) +#ifdef __cplusplus +} +#endif + #endif /* !_SYS_QUEUE_H_ */ diff --git a/lib/frr_pthread.h b/lib/frr_pthread.h index e6b3f031b3..9bc7b94033 100644 --- a/lib/frr_pthread.h +++ b/lib/frr_pthread.h @@ -25,6 +25,10 @@ #include "memory.h" #include "thread.h" +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(FRR_PTHREAD); DECLARE_MTYPE(PTHREAD_PRIM); @@ -73,7 +77,7 @@ struct frr_pthread { */ pthread_cond_t *running_cond; pthread_mutex_t *running_cond_mtx; - _Atomic bool running; + atomic_bool running; /* * Fake thread-specific storage. No constraints on usage. Helpful when @@ -211,4 +215,8 @@ void frr_pthread_stop_all(void); #define pthread_condattr_setclock(A, B) #endif +#ifdef __cplusplus +} +#endif + #endif /* _FRR_PTHREAD_H */ diff --git a/lib/frr_zmq.h b/lib/frr_zmq.h index 1146b87964..4303df9ccd 100644 --- a/lib/frr_zmq.h +++ b/lib/frr_zmq.h @@ -23,6 +23,10 @@ #include "thread.h" #include <zmq.h> +#ifdef __cplusplus +extern "C" { +#endif + /* linking/packaging note: this is a separate library that needs to be * linked into any daemon/library/module that wishes to use its * functionality. The purpose of this is to encapsulate the libzmq @@ -124,4 +128,8 @@ extern void frrzmq_thread_cancel(struct frrzmq_cb **cb, struct cb_core *core); extern void frrzmq_check_events(struct frrzmq_cb **cbp, struct cb_core *core, int event); +#ifdef __cplusplus +} +#endif + #endif /* _FRRZMQ_H */ diff --git a/lib/frratomic.h b/lib/frratomic.h index 1f1d1b569a..e86030f83c 100644 --- a/lib/frratomic.h +++ b/lib/frratomic.h @@ -26,7 +26,23 @@ #endif /* ISO C11 */ -#ifdef HAVE_STDATOMIC_H +#ifdef __cplusplus +#include <stdint.h> +#include <atomic> +using std::atomic_int; +using std::memory_order; +using std::memory_order_relaxed; +using std::memory_order_acquire; +using std::memory_order_release; +using std::memory_order_acq_rel; +using std::memory_order_consume; +using std::memory_order_seq_cst; + +typedef std::atomic<bool> atomic_bool; +typedef std::atomic<size_t> atomic_size_t; +typedef std::atomic<uint_fast32_t> atomic_uint_fast32_t; + +#elif defined(HAVE_STDATOMIC_H) #include <stdatomic.h> /* These are available in gcc, but not in stdatomic */ @@ -39,6 +55,7 @@ #elif defined(HAVE___ATOMIC) #define _Atomic volatile +#define _ATOMIC_WANT_TYPEDEFS #define memory_order_relaxed __ATOMIC_RELAXED #define memory_order_consume __ATOMIC_CONSUME @@ -74,6 +91,7 @@ #elif defined(HAVE___SYNC) #define _Atomic volatile +#define _ATOMIC_WANT_TYPEDEFS #define memory_order_relaxed 0 #define memory_order_consume 0 @@ -198,4 +216,15 @@ #error no atomic functions... #endif +#ifdef _ATOMIC_WANT_TYPEDEFS +#undef _ATOMIC_WANT_TYPEDEFS + +#include <stdint.h> +#include <stdbool.h> + +typedef _Atomic bool atomic_bool; +typedef _Atomic size_t atomic_size_t; +typedef _Atomic uint_fast32_t atomic_uint_fast32_t; +#endif + #endif /* _FRRATOMIC_H */ diff --git a/lib/frrstr.h b/lib/frrstr.h index 891a3f337c..8b591849a3 100644 --- a/lib/frrstr.h +++ b/lib/frrstr.h @@ -27,6 +27,10 @@ #include "vector.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Tokenizes a string, storing tokens in a vector. Whitespace is ignored. * Delimiter characters are not included. @@ -108,4 +112,8 @@ bool begins_with(const char *str, const char *prefix); */ int all_digit(const char *str); +#ifdef __cplusplus +} +#endif + #endif /* _FRRSTR_H_ */ diff --git a/lib/graph.h b/lib/graph.h index 87262a07b8..8e126e6be4 100644 --- a/lib/graph.h +++ b/lib/graph.h @@ -28,6 +28,10 @@ #include "vector.h" #include "buffer.h" +#ifdef __cplusplus +extern "C" { +#endif + struct graph { vector nodes; }; @@ -164,4 +168,9 @@ char *graph_dump_dot(struct graph *graph, struct graph_node *start, void (*pcb)(struct graph_node *, struct buffer *buf)); #endif /* BUILDING_CLIPPY */ + +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_COMMAND_GRAPH_H */ diff --git a/lib/hash.h b/lib/hash.h index 45ae6ce60a..8c695d2381 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -24,6 +24,10 @@ #include "memory.h" #include "frratomic.h" +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(HASH) DECLARE_MTYPE(HASH_BACKET) @@ -54,9 +58,9 @@ struct hash_backet { struct hashstats { /* number of empty hash buckets */ - _Atomic uint_fast32_t empty; + atomic_uint_fast32_t empty; /* sum of squares of bucket length */ - _Atomic uint_fast32_t ssq; + atomic_uint_fast32_t ssq; }; struct hash { @@ -325,4 +329,8 @@ extern unsigned int string_hash_make(const char *); */ extern void hash_cmd_init(void); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_HASH_H */ diff --git a/lib/hook.h b/lib/hook.h index 96fec97d7e..f7fb7b8a5c 100644 --- a/lib/hook.h +++ b/lib/hook.h @@ -22,6 +22,10 @@ #include "module.h" #include "memory.h" +#ifdef __cplusplus +extern "C" { +#endif + /* type-safe subscribable hook points * * where "type-safe" applies to the function pointers used for subscriptions @@ -219,4 +223,8 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg, #define DEFINE_KOOH(hookname, arglist, passlist) \ DEFINE_HOOK_INT(hookname, arglist, passlist, true) +#ifdef __cplusplus +} +#endif + #endif /* _FRR_HOOK_H */ diff --git a/lib/id_alloc.h b/lib/id_alloc.h index efe355658a..8705ffb37d 100644 --- a/lib/id_alloc.h +++ b/lib/id_alloc.h @@ -24,6 +24,10 @@ #include <limits.h> #include <stdint.h> +#ifdef __cplusplus +extern "C" { +#endif + #define IDALLOC_INVALID 0 #define IDALLOC_DIR_BITS 8 @@ -87,4 +91,8 @@ uint32_t idalloc_reserve(struct id_alloc *alloc, uint32_t id); struct id_alloc *idalloc_new(const char *name); void idalloc_destroy(struct id_alloc *alloc); +#ifdef __cplusplus +} +#endif + #endif @@ -1160,7 +1160,7 @@ DEFPY (no_interface, if (!vrfname) vrfname = VRF_DEFAULT_NAME; - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); return nb_cli_apply_changes( vty, "/frr-interface:lib/interface[name='%s'][vrf='%s']", @@ -1207,7 +1207,7 @@ DEFPY (no_interface_desc, NO_STR "Interface specific description\n") { - nb_cli_enqueue_change(vty, "./description", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, "./description", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); } @@ -1379,13 +1379,13 @@ const struct frr_yang_module_info frr_interface_info = { { .xpath = "/frr-interface:lib/interface", .cbs.create = lib_interface_create, - .cbs.delete = lib_interface_delete, + .cbs.destroy = lib_interface_delete, .cbs.cli_show = cli_show_interface, }, { .xpath = "/frr-interface:lib/interface/description", .cbs.modify = lib_interface_description_modify, - .cbs.delete = lib_interface_description_delete, + .cbs.destroy = lib_interface_description_delete, .cbs.cli_show = cli_show_interface_desc, }, { @@ -27,6 +27,10 @@ #include "qobj.h" #include "hook.h" +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(IF) DECLARE_MTYPE(CONNECTED_LABEL) @@ -290,9 +294,9 @@ struct interface { }; RB_HEAD(if_name_head, interface); -RB_PROTOTYPE(if_name_head, interface, name_entry, if_cmp_func); +RB_PROTOTYPE(if_name_head, interface, name_entry, if_cmp_func) RB_HEAD(if_index_head, interface); -RB_PROTOTYPE(if_index_head, interface, index_entry, if_cmp_func); +RB_PROTOTYPE(if_index_head, interface, index_entry, if_cmp_func) DECLARE_QOBJ_TYPE(interface) #define IFNAME_RB_INSERT(vrf, ifp) \ @@ -545,4 +549,8 @@ void if_link_params_free(struct interface *); extern void if_cmd_init(void); extern const struct frr_yang_module_info frr_interface_info; +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_IF_H */ diff --git a/lib/if_rmap.h b/lib/if_rmap.h index 4468b9fb9c..8dded2cb48 100644 --- a/lib/if_rmap.h +++ b/lib/if_rmap.h @@ -21,6 +21,10 @@ #ifndef _ZEBRA_IF_RMAP_H #define _ZEBRA_IF_RMAP_H +#ifdef __cplusplus +extern "C" { +#endif + enum if_rmap_type { IF_RMAP_IN, IF_RMAP_OUT, IF_RMAP_MAX }; struct if_rmap { @@ -37,4 +41,8 @@ extern void if_rmap_hook_delete(void (*)(struct if_rmap *)); extern struct if_rmap *if_rmap_lookup(const char *); extern int config_write_if_rmap(struct vty *); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_IF_RMAP_H */ diff --git a/lib/imsg.h b/lib/imsg.h index eed7074e4a..3f81b76bea 100644 --- a/lib/imsg.h +++ b/lib/imsg.h @@ -21,6 +21,10 @@ #ifndef _IMSG_H_ #define _IMSG_H_ +#ifdef __cplusplus +extern "C" { +#endif + #define IBUF_READ_SIZE 65535 #define IMSG_HEADER_SIZE sizeof(struct imsg_hdr) #define MAX_IMSGSIZE 16384 @@ -108,4 +112,8 @@ void imsg_free(struct imsg *); int imsg_flush(struct imsgbuf *); void imsg_clear(struct imsgbuf *); +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/ipaddr.h b/lib/ipaddr.h index 7f2d06548b..f4ddadc66e 100644 --- a/lib/ipaddr.h +++ b/lib/ipaddr.h @@ -25,6 +25,10 @@ #include <zebra.h> +#ifdef __cplusplus +extern "C" { +#endif + /* * Generic IP address - union of IPv4 and IPv6 address. */ @@ -112,4 +116,8 @@ static inline void ipv4_mapped_ipv6_to_ipv4(struct in6_addr *in6, memcpy(in, (char *)in6 + 12, sizeof(struct in_addr)); } +#ifdef __cplusplus +} +#endif + #endif /* __IPADDR_H__ */ diff --git a/lib/jhash.h b/lib/jhash.h index f8ab4209a8..977421495c 100644 --- a/lib/jhash.h +++ b/lib/jhash.h @@ -20,6 +20,10 @@ #ifndef _QUAGGA_JHASH_H #define _QUAGGA_JHASH_H +#ifdef __cplusplus +extern "C" { +#endif + /* The most generic version, hashes an arbitrary sequence * of bytes. No alignment or length assumptions are made about * the input key. @@ -42,4 +46,8 @@ extern uint32_t jhash_3words(uint32_t a, uint32_t b, uint32_t c, extern uint32_t jhash_2words(uint32_t a, uint32_t b, uint32_t initval); extern uint32_t jhash_1word(uint32_t a, uint32_t initval); +#ifdef __cplusplus +} +#endif + #endif /* _QUAGGA_JHASH_H */ diff --git a/lib/json.h b/lib/json.h index d349162304..a5251662be 100644 --- a/lib/json.h +++ b/lib/json.h @@ -21,6 +21,10 @@ #ifndef _QUAGGA_JSON_H #define _QUAGGA_JSON_H +#ifdef __cplusplus +extern "C" { +#endif + #if defined(HAVE_JSON_C_JSON_H) #include <json-c/json.h> @@ -81,4 +85,8 @@ extern void json_object_free(struct json_object *obj); #define JSON_C_TO_STRING_NOSLASHESCAPE (1<<4) #endif +#ifdef __cplusplus +} +#endif + #endif /* _QUAGGA_JSON_H */ diff --git a/lib/keychain.h b/lib/keychain.h index 49da9ba459..e5cf39f7c6 100644 --- a/lib/keychain.h +++ b/lib/keychain.h @@ -23,6 +23,10 @@ #include "qobj.h" +#ifdef __cplusplus +extern "C" { +#endif + struct keychain { char *name; @@ -57,4 +61,8 @@ extern struct key *key_lookup_for_accept(const struct keychain *, uint32_t); extern struct key *key_match_for_accept(const struct keychain *, const char *); extern struct key *key_lookup_for_send(const struct keychain *); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_KEYCHAIN_H */ diff --git a/lib/lib_errors.h b/lib/lib_errors.h index 86a83df46c..fc405c2098 100644 --- a/lib/lib_errors.h +++ b/lib/lib_errors.h @@ -23,6 +23,10 @@ #include "lib/ferr.h" +#ifdef __cplusplus +extern "C" { +#endif + enum lib_log_refs { EC_LIB_PRIVILEGES = LIB_FERR_START, EC_LIB_VRF_START, @@ -82,4 +86,8 @@ enum lib_log_refs { extern void lib_error_init(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/libfrr.h b/lib/libfrr.h index 2705397b85..891e2c1282 100644 --- a/lib/libfrr.h +++ b/lib/libfrr.h @@ -30,6 +30,10 @@ #include "hook.h" #include "northbound.h" +#ifdef __cplusplus +extern "C" { +#endif + /* The following options disable specific command line options that * are not applicable for a particular daemon. */ @@ -152,4 +156,8 @@ extern char frr_protonameinst[]; extern bool debug_memstats_at_exit; +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_FRR_H */ diff --git a/lib/libospf.h b/lib/libospf.h index 45aedb6a7d..d2bb29d80e 100644 --- a/lib/libospf.h +++ b/lib/libospf.h @@ -22,6 +22,10 @@ #ifndef _LIBOSPFD_H #define _LIBOSPFD_H +#ifdef __cplusplus +extern "C" { +#endif + /* IP precedence. */ #ifndef IPTOS_PREC_INTERNETCONTROL #define IPTOS_PREC_INTERNETCONTROL 0xC0 @@ -94,4 +98,8 @@ #define OSPF_LSA_MAXAGE_CHECK_INTERVAL 30 #define OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT 60 +#ifdef __cplusplus +} +#endif + #endif /* _LIBOSPFD_H */ diff --git a/lib/linklist.h b/lib/linklist.h index 0475391e9f..76fad45d08 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -21,6 +21,10 @@ #ifndef _ZEBRA_LINKLIST_H #define _ZEBRA_LINKLIST_H +#ifdef __cplusplus +extern "C" { +#endif + /* listnodes must always contain data to be valid. Adding an empty node * to a list is invalid */ @@ -291,7 +295,8 @@ extern void list_add_list(struct list *list, struct list *add); #define ALL_LIST_ELEMENTS(list, node, nextnode, data) \ (node) = listhead(list), ((data) = NULL); \ (node) != NULL \ - && ((data) = listgetdata(node), (nextnode) = node->next, 1); \ + && ((data) = static_cast(data, listgetdata(node)), \ + (nextnode) = node->next, 1); \ (node) = (nextnode), ((data) = NULL) /* read-only list iteration macro. @@ -302,7 +307,7 @@ extern void list_add_list(struct list *list, struct list *add); */ #define ALL_LIST_ELEMENTS_RO(list, node, data) \ (node) = listhead(list), ((data) = NULL); \ - (node) != NULL && ((data) = listgetdata(node), 1); \ + (node) != NULL && ((data) = static_cast(data, listgetdata(node)), 1); \ (node) = listnextnode(node), ((data) = NULL) /* these *do not* cleanup list nodes and referenced data, as the functions @@ -336,4 +341,8 @@ extern void list_add_list(struct list *list, struct list *add); (L)->count--; \ } while (0) +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_LINKLIST_H */ @@ -29,6 +29,10 @@ #include <stdarg.h> #include "lib/hook.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Hook for external logging function */ DECLARE_HOOK(zebra_ext_log, (int priority, const char *format, va_list args), (priority, format, args)); @@ -93,11 +97,11 @@ extern void zlog_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2); /* For logs which have error codes associated with them */ #define flog_err(ferr_id, format, ...) \ - zlog_err("[EC %"PRIu32"] " format, ferr_id, ##__VA_ARGS__) + zlog_err("[EC %" PRIu32 "] " format, ferr_id, ##__VA_ARGS__) #define flog_err_sys(ferr_id, format, ...) \ flog_err(ferr_id, format, ##__VA_ARGS__) #define flog_warn(ferr_id, format, ...) \ - zlog_warn("[EC %"PRIu32"] " format, ferr_id, ##__VA_ARGS__) + zlog_warn("[EC %" PRIu32 "] " format, ferr_id, ##__VA_ARGS__) extern void zlog_thread_info(int log_level); @@ -196,4 +200,8 @@ struct timestamp_control { "Local use\n" \ "Local use\n" +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_LOG_H */ diff --git a/lib/log_int.h b/lib/log_int.h index a7f8be9ae7..58ae031e1b 100644 --- a/lib/log_int.h +++ b/lib/log_int.h @@ -24,6 +24,10 @@ #include "log.h" +#ifdef __cplusplus +extern "C" { +#endif + struct zlog { const char *ident; /* daemon name (first arg to openlog) */ const char *protoname; @@ -49,4 +53,8 @@ extern const char *zlog_priority[]; extern void vzlog(int priority, const char *format, va_list args); extern void zlog(int priority, const char *format, ...) PRINTF_ATTRIBUTE(2, 3); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_LOG_PRIVATE_H */ diff --git a/lib/logicalrouter.h b/lib/logicalrouter.h index 5a0780c009..d18832ef70 100644 --- a/lib/logicalrouter.h +++ b/lib/logicalrouter.h @@ -20,6 +20,10 @@ #ifndef _ZEBRA_LOGICAL_ROUTER_H #define _ZEBRA_LOGICAL_ROUTER_H +#ifdef __cplusplus +extern "C" { +#endif + /* Logical Router Backend defines */ #define LOGICALROUTER_BACKEND_OFF 0 #define LOGICALROUTER_BACKEND_NETNS 1 @@ -38,4 +42,8 @@ extern void logicalrouter_terminate(void); */ extern void logicalrouter_configure_backend(int backend_netns); +#ifdef __cplusplus +} +#endif + #endif /*_ZEBRA_LOGICAL_ROUTER_H*/ @@ -29,6 +29,10 @@ #include <lualib.h> #include <lauxlib.h> +#ifdef __cplusplus +extern "C" { +#endif + /* * These functions are helper functions that * try to glom some of the lua_XXX functionality @@ -75,5 +79,10 @@ enum lua_rm_status lua_run_rm_rule(lua_State *L, const char *rule); */ const char *get_string(lua_State *L, const char *key); int get_integer(lua_State *L, const char *key); + +#ifdef __cplusplus +} +#endif + #endif #endif @@ -38,6 +38,10 @@ #ifndef _LIBZEBRA_MD5_H_ #define _LIBZEBRA_MD5_H_ +#ifdef __cplusplus +extern "C" { +#endif + #define MD5_BUFLEN 64 typedef struct { @@ -82,4 +86,8 @@ extern void md5_result(uint8_t *, md5_ctxt *); void hmac_md5(unsigned char *text, int text_len, unsigned char *key, int key_len, uint8_t *digest); +#ifdef __cplusplus +} +#endif + #endif /* ! _LIBZEBRA_MD5_H_*/ diff --git a/lib/memory.h b/lib/memory.h index 1a0269f8bb..91a02b7966 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -22,6 +22,10 @@ #include <frratomic.h> #include "compiler.h" +#ifdef __cplusplus +extern "C" { +#endif + #define array_size(ar) (sizeof(ar) / sizeof(ar[0])) #if defined(HAVE_MALLOC_SIZE) && !defined(HAVE_MALLOC_USABLE_SIZE) @@ -33,12 +37,12 @@ struct memtype { struct memtype *next, **ref; const char *name; - _Atomic size_t n_alloc; - _Atomic size_t n_max; - _Atomic size_t size; + atomic_size_t n_alloc; + atomic_size_t n_max; + atomic_size_t size; #ifdef HAVE_MALLOC_USABLE_SIZE - _Atomic size_t total; - _Atomic size_t max_size; + atomic_size_t total; + atomic_size_t max_size; #endif }; @@ -176,4 +180,8 @@ extern int log_memstats(FILE *fp, const char *); extern void memory_oom(size_t size, const char *name); +#ifdef __cplusplus +} +#endif + #endif /* _QUAGGA_MEMORY_H */ diff --git a/lib/memory_vty.h b/lib/memory_vty.h index b66c3b6d6e..941255be1d 100644 --- a/lib/memory_vty.h +++ b/lib/memory_vty.h @@ -23,9 +23,18 @@ #include "memory.h" +#ifdef __cplusplus +extern "C" { +#endif + extern void memory_init(void); /* Human friendly string for given byte count */ #define MTYPE_MEMSTR_LEN 20 extern const char *mtype_memstr(char *, size_t, unsigned long); + +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_MEMORY_VTY_H */ diff --git a/lib/mlag.h b/lib/mlag.h index 73725ca3fd..2b904d44f4 100644 --- a/lib/mlag.h +++ b/lib/mlag.h @@ -22,6 +22,10 @@ #ifndef __MLAG_H__ #define __MLAG_H__ +#ifdef __cplusplus +extern "C" { +#endif + enum mlag_role { MLAG_ROLE_NONE, MLAG_ROLE_PRIMARY, @@ -29,4 +33,9 @@ enum mlag_role { }; extern char *mlag_role2str(enum mlag_role role, char *buf, size_t size); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/module.h b/lib/module.h index 68ed959270..c5f96db85b 100644 --- a/lib/module.h +++ b/lib/module.h @@ -20,6 +20,10 @@ #include <stdint.h> #include <stdbool.h> +#ifdef __cplusplus +extern "C" { +#endif + #if !defined(__GNUC__) #error module code needs GCC visibility extensions #elif __GNUC__ < 4 @@ -78,9 +82,10 @@ extern union _frrmod_runtime_u _frrmod_this_module; #define FRR_COREMOD_SETUP(...) \ static const struct frrmod_info _frrmod_info = {__VA_ARGS__}; \ - DSO_LOCAL union _frrmod_runtime_u _frrmod_this_module = { \ - .r.info = &_frrmod_info, \ - }; + DSO_LOCAL union _frrmod_runtime_u _frrmod_this_module = {{ \ + NULL, \ + &_frrmod_info, \ + }}; #define FRR_MODULE_SETUP(...) \ FRR_COREMOD_SETUP(__VA_ARGS__) \ DSO_SELF struct frrmod_runtime *frr_module = &_frrmod_this_module.r; @@ -95,4 +100,8 @@ extern struct frrmod_runtime *frrmod_load(const char *spec, const char *dir, extern void frrmod_unload(struct frrmod_runtime *module); #endif +#ifdef __cplusplus +} +#endif + #endif /* _FRR_MODULE_H */ diff --git a/lib/monotime.h b/lib/monotime.h index 00b9400462..6aac966ea1 100644 --- a/lib/monotime.h +++ b/lib/monotime.h @@ -21,6 +21,10 @@ #include <time.h> #include <sys/time.h> +#ifdef __cplusplus +extern "C" { +#endif + #ifndef TIMESPEC_TO_TIMEVAL /* should be in sys/time.h on BSD & Linux libcs */ #define TIMESPEC_TO_TIMEVAL(tv, ts) \ @@ -91,4 +95,8 @@ static inline char *time_to_string(time_t ts) return ctime(&tbuf); } +#ifdef __cplusplus +} +#endif + #endif /* _FRR_MONOTIME_H */ diff --git a/lib/mpls.h b/lib/mpls.h index 6146985610..b140c8e317 100644 --- a/lib/mpls.h +++ b/lib/mpls.h @@ -25,6 +25,10 @@ #include <zebra.h> #include <arpa/inet.h> +#ifdef __cplusplus +extern "C" { +#endif + #ifdef MPLS_LABEL_MAX #undef MPLS_LABEL_MAX #endif @@ -209,4 +213,8 @@ int mpls_str2label(const char *label_str, uint8_t *num_labels, char *mpls_label2str(uint8_t num_labels, mpls_label_t *labels, char *buf, int len, int pretty); +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/network.h b/lib/network.h index 4703dc9b63..a00c5a0a65 100644 --- a/lib/network.h +++ b/lib/network.h @@ -22,6 +22,10 @@ #ifndef _ZEBRA_NETWORK_H #define _ZEBRA_NETWORK_H +#ifdef __cplusplus +extern "C" { +#endif + /* Both readn and writen are deprecated and will be removed. They are not suitable for use with non-blocking file descriptors. */ @@ -41,4 +45,8 @@ extern int set_cloexec(int fd); extern float htonf(float); extern float ntohf(float); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_NETWORK_H */ diff --git a/lib/nexthop.h b/lib/nexthop.h index e4af405d5f..c79ec590a8 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -26,6 +26,10 @@ #include "prefix.h" #include "mpls.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Maximum next hop string length - gateway + ifindex */ #define NEXTHOP_STRLEN (INET6_ADDRSTRLEN + 30) @@ -146,4 +150,9 @@ extern int nexthop_same_firsthop(struct nexthop *next1, struct nexthop *next2); extern const char *nexthop2str(const struct nexthop *nexthop, char *str, int size); extern struct nexthop *nexthop_next(struct nexthop *nexthop); extern unsigned int nexthop_level(struct nexthop *nexthop); + +#ifdef __cplusplus +} +#endif + #endif /*_LIB_NEXTHOP_H */ diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h index 473ecb34fc..b14cbb5b5c 100644 --- a/lib/nexthop_group.h +++ b/lib/nexthop_group.h @@ -23,6 +23,10 @@ #include <vty.h> +#ifdef __cplusplus +extern "C" { +#endif + /* * What is a nexthop group? * @@ -92,12 +96,12 @@ DECLARE_QOBJ_TYPE(nexthop_group_cmd) * code */ void nexthop_group_init( - void (*new)(const char *name), + void (*create)(const char *name), void (*add_nexthop)(const struct nexthop_group_cmd *nhgc, const struct nexthop *nhop), void (*del_nexthop)(const struct nexthop_group_cmd *nhgc, const struct nexthop *nhop), - void (*delete)(const char *name)); + void (*destroy)(const char *name)); void nexthop_group_enable_vrf(struct vrf *vrf); void nexthop_group_disable_vrf(struct vrf *vrf); @@ -110,4 +114,9 @@ extern struct nexthop *nexthop_exists(struct nexthop_group *nhg, extern struct nexthop_group_cmd *nhgc_find(const char *name); extern void nexthop_group_write_nexthop(struct vty *vty, struct nexthop *nh); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/northbound.c b/lib/northbound.c index 6fe612d72a..15139aa8d0 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -184,8 +184,8 @@ static unsigned int nb_node_validate_cbs(const struct nb_node *nb_node) !!nb_node->cbs.create, false); error += nb_node_validate_cb(nb_node, NB_OP_MODIFY, !!nb_node->cbs.modify, false); - error += nb_node_validate_cb(nb_node, NB_OP_DELETE, - !!nb_node->cbs.delete, false); + error += nb_node_validate_cb(nb_node, NB_OP_DESTROY, + !!nb_node->cbs.destroy, false); error += nb_node_validate_cb(nb_node, NB_OP_MOVE, !!nb_node->cbs.move, false); error += nb_node_validate_cb(nb_node, NB_OP_APPLY_FINISH, @@ -417,7 +417,7 @@ static void nb_config_diff(const struct nb_config *config1, break; case LYD_DIFF_DELETED: dnode = diff->first[i]; - operation = NB_OP_DELETE; + operation = NB_OP_DESTROY; break; case LYD_DIFF_CHANGED: dnode = diff->second[i]; @@ -485,7 +485,7 @@ int nb_candidate_edit(struct nb_config *candidate, lyd_validate(&dnode, LYD_OPT_CONFIG, ly_native_ctx); } break; - case NB_OP_DELETE: + case NB_OP_DESTROY: dnode = yang_dnode_get(candidate->dnode, xpath_edit); if (!dnode) /* @@ -741,8 +741,8 @@ static int nb_configuration_callback(const enum nb_event event, case NB_OP_MODIFY: ret = (*nb_node->cbs.modify)(event, dnode, resource); break; - case NB_OP_DELETE: - ret = (*nb_node->cbs.delete)(event, dnode); + case NB_OP_DESTROY: + ret = (*nb_node->cbs.destroy)(event, dnode); break; case NB_OP_MOVE: ret = (*nb_node->cbs.move)(event, dnode); @@ -912,7 +912,7 @@ static void nb_transaction_apply_finish(struct nb_transaction *transaction) * (the 'apply_finish' callbacks from the node ancestors should * be called though). */ - if (change->cb.operation == NB_OP_DELETE) { + if (change->cb.operation == NB_OP_DESTROY) { char xpath[XPATH_MAXLEN]; dnode = dnode->parent; @@ -1359,7 +1359,7 @@ bool nb_operation_is_valid(enum nb_operation operation, return false; } return true; - case NB_OP_DELETE: + case NB_OP_DESTROY: if (!CHECK_FLAG(snode->flags, LYS_CONFIG_W)) return false; @@ -1511,8 +1511,8 @@ const char *nb_operation_name(enum nb_operation operation) return "create"; case NB_OP_MODIFY: return "modify"; - case NB_OP_DELETE: - return "delete"; + case NB_OP_DESTROY: + return "destroy"; case NB_OP_MOVE: return "move"; case NB_OP_APPLY_FINISH: diff --git a/lib/northbound.h b/lib/northbound.h index 9d35a4e64a..bb6b62af7d 100644 --- a/lib/northbound.h +++ b/lib/northbound.h @@ -27,6 +27,10 @@ #include "yang.h" #include "yang_translator.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Forward declaration(s). */ struct vty; @@ -65,7 +69,7 @@ enum nb_event { enum nb_operation { NB_OP_CREATE, NB_OP_MODIFY, - NB_OP_DELETE, + NB_OP_DESTROY, NB_OP_MOVE, NB_OP_APPLY_FINISH, NB_OP_GET_ELEM, @@ -168,7 +172,7 @@ struct nb_callbacks { * - NB_ERR_INCONSISTENCY when an inconsistency was detected. * - NB_ERR for other errors. */ - int (*delete)(enum nb_event event, const struct lyd_node *dnode); + int (*destroy)(enum nb_event event, const struct lyd_node *dnode); /* * Configuration callback. @@ -839,4 +843,8 @@ extern void nb_init(struct thread_master *tm, const struct frr_yang_module_info */ extern void nb_terminate(void); +#ifdef __cplusplus +} +#endif + #endif /* _FRR_NORTHBOUND_H_ */ diff --git a/lib/northbound_cli.h b/lib/northbound_cli.h index 884f250941..209239ca63 100644 --- a/lib/northbound_cli.h +++ b/lib/northbound_cli.h @@ -22,6 +22,10 @@ #include "northbound.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Possible formats in which a configuration can be displayed. */ enum nb_cfg_format { NB_CFG_FMT_CMDS = 0, @@ -111,4 +115,8 @@ extern void nb_cli_install_default(int node); extern void nb_cli_init(struct thread_master *tm); extern void nb_cli_terminate(void); +#ifdef __cplusplus +} +#endif + #endif /* _FRR_NORTHBOUND_CLI_H_ */ diff --git a/lib/northbound_confd.c b/lib/northbound_confd.c index 53149d0fd2..a8e0017819 100644 --- a/lib/northbound_confd.c +++ b/lib/northbound_confd.c @@ -228,7 +228,7 @@ frr_confd_cdb_diff_iter(confd_hkeypath_t *kp, enum cdb_iter_op cdb_op, nb_op = NB_OP_CREATE; break; case MOP_DELETED: - nb_op = NB_OP_DELETE; + nb_op = NB_OP_DESTROY; break; case MOP_VALUE_SET: if (nb_operation_is_valid(NB_OP_MODIFY, nb_node->snode)) diff --git a/lib/northbound_db.h b/lib/northbound_db.h index ad60966441..14df09caa3 100644 --- a/lib/northbound_db.h +++ b/lib/northbound_db.h @@ -22,6 +22,10 @@ #include "northbound.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * Initialize the northbound database. * @@ -101,4 +105,8 @@ extern int nb_db_transactions_iterate( const char *date, const char *comment), void *arg); +#ifdef __cplusplus +} +#endif + #endif /* _FRR_NORTHBOUND_DB_H_ */ diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c index 860c27edbd..f426f52bd9 100644 --- a/lib/northbound_sysrepo.c +++ b/lib/northbound_sysrepo.c @@ -202,10 +202,10 @@ static int frr_sr_process_change(struct nb_config *candidate, * notified about the removal of all of its leafs, even the ones * that are non-optional. We need to ignore these notifications. */ - if (!nb_operation_is_valid(NB_OP_DELETE, nb_node->snode)) + if (!nb_operation_is_valid(NB_OP_DESTROY, nb_node->snode)) return NB_OK; - nb_op = NB_OP_DELETE; + nb_op = NB_OP_DESTROY; break; case SR_OP_MOVED: nb_op = NB_OP_MOVE; @@ -26,6 +26,10 @@ #include "linklist.h" #include "vty.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef uint32_t ns_id_t; /* the default NS ID */ @@ -174,4 +178,8 @@ extern int ns_enable(struct ns *ns, void (*func)(ns_id_t, void *)); extern struct ns *ns_get_created(struct ns *ns, char *name, ns_id_t ns_id); extern void ns_disable(struct ns *ns); +#ifdef __cplusplus +} +#endif + #endif /*_ZEBRA_NS_H*/ diff --git a/lib/openbsd-queue.h b/lib/openbsd-queue.h index e09cc3d4e5..d4c08a3be8 100644 --- a/lib/openbsd-queue.h +++ b/lib/openbsd-queue.h @@ -35,6 +35,10 @@ #ifndef _SYS_QUEUE_H_ #define _SYS_QUEUE_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* * This file defines five types of data structures: singly-linked lists, * lists, simple queues, tail queues and XOR simple queues. @@ -572,4 +576,8 @@ } \ } while (0) +#ifdef __cplusplus +} +#endif + #endif /* !_SYS_QUEUE_H_ */ diff --git a/lib/openbsd-tree.h b/lib/openbsd-tree.h index 1383ef6de0..d2f0781333 100644 --- a/lib/openbsd-tree.h +++ b/lib/openbsd-tree.h @@ -27,6 +27,10 @@ #ifndef _SYS_TREE_H_ #define _SYS_TREE_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* * This file defines data structures for different types of trees: * splay trees and red-black trees. @@ -397,31 +401,36 @@ int _rb_check(const struct rb_type *, void *, unsigned long); __attribute__((__unused__)) static inline struct _type \ *_name##_RB_INSERT(struct _name *head, struct _type *elm) \ { \ - return _rb_insert(_name##_RB_TYPE, &head->rbh_root, elm); \ + return (struct _type *)_rb_insert( \ + _name##_RB_TYPE, &head->rbh_root, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_REMOVE(struct _name *head, struct _type *elm) \ { \ - return _rb_remove(_name##_RB_TYPE, &head->rbh_root, elm); \ + return (struct _type *)_rb_remove( \ + _name##_RB_TYPE, &head->rbh_root, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_FIND(struct _name *head, const struct _type *key) \ { \ - return _rb_find(_name##_RB_TYPE, &head->rbh_root, key); \ + return (struct _type *)_rb_find( \ + _name##_RB_TYPE, &head->rbh_root, key); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_NFIND(struct _name *head, const struct _type *key) \ { \ - return _rb_nfind(_name##_RB_TYPE, &head->rbh_root, key); \ + return (struct _type *)_rb_nfind( \ + _name##_RB_TYPE, &head->rbh_root, key); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_ROOT(struct _name *head) \ { \ - return _rb_root(_name##_RB_TYPE, &head->rbh_root); \ + return (struct _type *)_rb_root( \ + _name##_RB_TYPE, &head->rbh_root); \ } \ \ __attribute__((__unused__)) static inline int _name##_RB_EMPTY( \ @@ -433,43 +442,45 @@ int _rb_check(const struct rb_type *, void *, unsigned long); __attribute__((__unused__)) static inline struct _type \ *_name##_RB_MIN(struct _name *head) \ { \ - return _rb_min(_name##_RB_TYPE, &head->rbh_root); \ + return (struct _type *)_rb_min( \ + _name##_RB_TYPE, &head->rbh_root); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_MAX(struct _name *head) \ { \ - return _rb_max(_name##_RB_TYPE, &head->rbh_root); \ + return (struct _type *)_rb_max( \ + _name##_RB_TYPE, &head->rbh_root); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_NEXT(struct _type *elm) \ { \ - return _rb_next(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_next(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_PREV(struct _type *elm) \ { \ - return _rb_prev(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_prev(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_LEFT(struct _type *elm) \ { \ - return _rb_left(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_left(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_RIGHT(struct _type *elm) \ { \ - return _rb_right(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_right(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_PARENT(struct _type *elm) \ { \ - return _rb_parent(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_parent(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline void _name##_RB_SET_LEFT( \ @@ -560,4 +571,8 @@ int _rb_check(const struct rb_type *, void *, unsigned long); for ((_e) = RB_MAX(_name, (_head)); \ (_e) != NULL && ((_n) = RB_PREV(_name, (_e)), 1); (_e) = (_n)) +#ifdef __cplusplus +} +#endif + #endif /* _SYS_TREE_H_ */ @@ -24,6 +24,10 @@ #include "stream.h" #include "prefix.h" +#ifdef __cplusplus +extern "C" { +#endif + #define PBR_STR "Policy Based Routing\n" /* @@ -121,4 +125,8 @@ struct pbr_rule { extern int zapi_pbr_rule_encode(uint8_t cmd, struct stream *s, struct pbr_rule *zrule); +#ifdef __cplusplus +} +#endif + #endif /* _PBR_H */ diff --git a/lib/plist.h b/lib/plist.h index 8a4fa8d3ce..ba2846d74a 100644 --- a/lib/plist.h +++ b/lib/plist.h @@ -27,6 +27,10 @@ #include "stream.h" #include "vty.h" +#ifdef __cplusplus +extern "C" { +#endif + enum prefix_list_type { PREFIX_DENY, PREFIX_PERMIT, @@ -75,4 +79,8 @@ extern void prefix_bgp_orf_remove_all(afi_t, char *); extern int prefix_bgp_show_prefix_list(struct vty *vty, afi_t afi, char *name, bool use_json); +#ifdef __cplusplus +} +#endif + #endif /* _QUAGGA_PLIST_H */ diff --git a/lib/plist_int.h b/lib/plist_int.h index 6bc2d034d6..443b0c614d 100644 --- a/lib/plist_int.h +++ b/lib/plist_int.h @@ -22,6 +22,10 @@ #ifndef _QUAGGA_PLIST_INT_H #define _QUAGGA_PLIST_INT_H +#ifdef __cplusplus +extern "C" { +#endif + enum prefix_name_type { PREFIX_TYPE_STRING, PREFIX_TYPE_NUMBER }; struct pltrie_table; @@ -68,4 +72,8 @@ struct prefix_list_entry { struct prefix_list_entry *next_best; }; +#ifdef __cplusplus +} +#endif + #endif /* _QUAGGA_PLIST_INT_H */ diff --git a/lib/pqueue.h b/lib/pqueue.h index 53e5aa8332..032ee9db4c 100644 --- a/lib/pqueue.h +++ b/lib/pqueue.h @@ -21,6 +21,10 @@ #ifndef _ZEBRA_PQUEUE_H #define _ZEBRA_PQUEUE_H +#ifdef __cplusplus +extern "C" { +#endif + struct pqueue { void **array; int array_size; @@ -43,4 +47,8 @@ extern void pqueue_remove(void *data, struct pqueue *queue); extern void trickle_down(int index, struct pqueue *queue); extern void trickle_up(int index, struct pqueue *queue); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_PQUEUE_H */ diff --git a/lib/prefix.h b/lib/prefix.h index aaffb1e0c5..ae931288c0 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -35,6 +35,10 @@ #include "ipaddr.h" #include "compiler.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef ETH_ALEN #define ETH_ALEN 6 #endif @@ -276,20 +280,29 @@ struct prefix_sg { * side, which strips type safety since the cast will accept any pointer * type.) */ +#ifndef __cplusplus +#define prefixtype(uname, typename, fieldname) \ + typename *fieldname; +#else +#define prefixtype(uname, typename, fieldname) \ + typename *fieldname; \ + uname(typename *x) { this->fieldname = x; } +#endif + union prefixptr { - struct prefix *p; - struct prefix_ipv4 *p4; - struct prefix_ipv6 *p6; - struct prefix_evpn *evp; - const struct prefix_fs *fs; + prefixtype(prefixptr, struct prefix, p) + prefixtype(prefixptr, struct prefix_ipv4, p4) + prefixtype(prefixptr, struct prefix_ipv6, p6) + prefixtype(prefixptr, struct prefix_evpn, evp) + prefixtype(prefixptr, struct prefix_fs, fs) } __attribute__((transparent_union)); union prefixconstptr { - const struct prefix *p; - const struct prefix_ipv4 *p4; - const struct prefix_ipv6 *p6; - const struct prefix_evpn *evp; - const struct prefix_fs *fs; + prefixtype(prefixconstptr, const struct prefix, p) + prefixtype(prefixconstptr, const struct prefix_ipv4, p4) + prefixtype(prefixconstptr, const struct prefix_ipv6, p6) + prefixtype(prefixconstptr, const struct prefix_evpn, evp) + prefixtype(prefixconstptr, const struct prefix_fs, fs) } __attribute__((transparent_union)); #ifndef INET_ADDRSTRLEN @@ -497,4 +510,9 @@ static inline int is_host_route(struct prefix *p) return (p->prefixlen == IPV6_MAX_BITLEN); return 0; } + +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_PREFIX_H */ diff --git a/lib/privs.c b/lib/privs.c index 838ff8fc92..2932800070 100644 --- a/lib/privs.c +++ b/lib/privs.c @@ -789,7 +789,7 @@ void zprivs_preinit(struct zebra_privs_t *zprivs) void zprivs_init(struct zebra_privs_t *zprivs) { - gid_t groups[NGROUPS_MAX]; + gid_t groups[NGROUPS_MAX] = {}; int i, ngroups = 0; int found = 0; @@ -799,7 +799,7 @@ void zprivs_init(struct zebra_privs_t *zprivs) return; if (zprivs->user) { - ngroups = sizeof(groups); + ngroups = array_size(groups); if (getgrouplist(zprivs->user, zprivs_state.zgid, groups, &ngroups) < 0) { diff --git a/lib/privs.h b/lib/privs.h index b061370b75..1fee423a95 100644 --- a/lib/privs.h +++ b/lib/privs.h @@ -23,6 +23,10 @@ #ifndef _ZEBRA_PRIVS_H #define _ZEBRA_PRIVS_H +#ifdef __cplusplus +extern "C" { +#endif + /* list of zebra capabilities */ typedef enum { ZCAP_SETID, @@ -120,4 +124,8 @@ extern void _zprivs_lower(struct zebra_privs_t **privs); _zprivs_raise(privs, __func__); \ _once == NULL; _once = (void *)1) +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_PRIVS_H */ diff --git a/lib/ptm_lib.h b/lib/ptm_lib.h index fc4d520dcb..c2170407c0 100644 --- a/lib/ptm_lib.h +++ b/lib/ptm_lib.h @@ -20,6 +20,10 @@ #ifndef __PTM_LIB_H__ #define __PTM_LIB_H__ +#ifdef __cplusplus +extern "C" { +#endif + #define PTMLIB_MSG_SZ 1024 #define PTMLIB_MSG_HDR_LEN 37 #define PTMLIB_MSG_VERSION 2 @@ -65,4 +69,8 @@ int ptm_lib_append_msg(ptm_lib_handle_t *, void *, const char *, const char *); int ptm_lib_complete_msg(ptm_lib_handle_t *, void *, char *, int *); int ptm_lib_cleanup_msg(ptm_lib_handle_t *, void *); +#ifdef __cplusplus +} +#endif + #endif @@ -20,6 +20,10 @@ #ifndef _FRR_PW_H #define _FRR_PW_H +#ifdef __cplusplus +extern "C" { +#endif + /* L2VPN name length. */ #define L2VPN_NAME_LEN 32 @@ -44,9 +48,10 @@ union pw_protocol_fields { uint32_t pwid; char vpn_name[L2VPN_NAME_LEN]; } ldp; - struct { - /* TODO */ - } bgp; }; +#ifdef __cplusplus +} +#endif + #endif /* _FRR_PW_H */ diff --git a/lib/qobj.h b/lib/qobj.h index b701eeec5f..d63988cbab 100644 --- a/lib/qobj.h +++ b/lib/qobj.h @@ -21,6 +21,10 @@ #include <stdlib.h> #include <stddef.h> +#ifdef __cplusplus +extern "C" { +#endif + /* reserve a specific amount of bytes for a struct, which can grow up to * that size (or be dummy'd out if not needed) * @@ -28,11 +32,17 @@ * this is intentional to prevent the struct from growing beyond the allocated * space. */ +#ifndef __cplusplus #define RESERVED_SPACE_STRUCT(name, fieldname, size) \ struct { \ struct name fieldname; \ char padding##fieldname[size - sizeof(struct name)]; \ }; +#else +#define RESERVED_SPACE_STRUCT(name, fieldname, size) \ + struct name fieldname; \ + char padding##fieldname[size - sizeof(struct name)]; +#endif /* don't need struct definitions for these here. code actually using * these needs to define the struct *before* including this header. @@ -127,4 +137,8 @@ void *qobj_get_typed(uint64_t id, struct qobj_nodetype *type); void qobj_init(void); void qobj_finish(void); +#ifdef __cplusplus +} +#endif + #endif /* _QOBJ_H */ diff --git a/lib/queue.h b/lib/queue.h index 11e28b4c91..dab43e3c54 100644 --- a/lib/queue.h +++ b/lib/queue.h @@ -19,6 +19,10 @@ #ifndef _FRR_QUEUE_H #define _FRR_QUEUE_H +#ifdef __cplusplus +extern "C" { +#endif + #if defined(__OpenBSD__) && !defined(STAILQ_HEAD) #include "openbsd-queue.h" @@ -85,4 +89,8 @@ }; _elm; }) #endif +#ifdef __cplusplus +} +#endif + #endif /* _FRR_QUEUE_H */ diff --git a/lib/ringbuf.h b/lib/ringbuf.h index 15049e3eea..b8f4d9798d 100644 --- a/lib/ringbuf.h +++ b/lib/ringbuf.h @@ -25,6 +25,10 @@ #include "memory.h" +#ifdef __cplusplus +extern "C" { +#endif + struct ringbuf { size_t size; ssize_t start; @@ -122,4 +126,8 @@ void ringbuf_reset(struct ringbuf *buf); */ void ringbuf_wipe(struct ringbuf *buf); +#ifdef __cplusplus +} +#endif + #endif /* _FRR_RINGBUF_H_ */ diff --git a/lib/routemap.h b/lib/routemap.h index 6fd88ba5de..e43e74a633 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -26,6 +26,10 @@ #include "qobj.h" #include "vty.h" +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(ROUTE_MAP_NAME) DECLARE_MTYPE(ROUTE_MAP_RULE) DECLARE_MTYPE(ROUTE_MAP_COMPILED) @@ -388,4 +392,8 @@ extern void route_map_counter_increment(struct route_map *map); /* Decrement the route-map used counter */ extern void route_map_counter_decrement(struct route_map *map); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_ROUTEMAP_H */ diff --git a/lib/sbuf.h b/lib/sbuf.h index c38e96912f..b1518a3aa8 100644 --- a/lib/sbuf.h +++ b/lib/sbuf.h @@ -23,6 +23,10 @@ #ifndef SBUF_H #define SBUF_H +#ifdef __cplusplus +extern "C" { +#endif + /* * sbuf provides a simple string buffer. One application where this comes * in handy is the parsing of binary data: If there is an error in the parsing @@ -76,4 +80,8 @@ void sbuf_free(struct sbuf *buf); void sbuf_push(struct sbuf *buf, int indent, const char *format, ...) PRINTF_ATTRIBUTE(3, 4); +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/sha256.h b/lib/sha256.h index 2473da7bda..c93d253051 100644 --- a/lib/sha256.h +++ b/lib/sha256.h @@ -29,6 +29,10 @@ #ifndef _SHA256_H_ #define _SHA256_H_ +#ifdef __cplusplus +extern "C" { +#endif + typedef struct SHA256Context { uint32_t state[8]; uint32_t count[2]; @@ -55,4 +59,8 @@ void HMAC__SHA256_Final(unsigned char[32], HMAC_SHA256_CTX *); void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t, uint64_t, uint8_t *, size_t); +#ifdef __cplusplus +} +#endif + #endif /* !_SHA256_H_ */ diff --git a/lib/sigevent.h b/lib/sigevent.h index d4ab5741ac..a0ad88fcaa 100644 --- a/lib/sigevent.h +++ b/lib/sigevent.h @@ -25,6 +25,10 @@ #include <thread.h> +#ifdef __cplusplus +extern "C" { +#endif + #define QUAGGA_SIGNAL_TIMER_INTERVAL 2L struct quagga_signal_t { @@ -47,4 +51,8 @@ extern void signal_init(struct thread_master *m, int sigc, /* check whether there are signals to handle, process any found */ extern int quagga_sigevent_process(void); +#ifdef __cplusplus +} +#endif + #endif /* _QUAGGA_SIGNAL_H */ diff --git a/lib/skiplist.h b/lib/skiplist.h index a2e8c374b1..2ab37331c9 100644 --- a/lib/skiplist.h +++ b/lib/skiplist.h @@ -31,6 +31,10 @@ #ifndef _ZEBRA_SKIPLIST_H #define _ZEBRA_SKIPLIST_H +#ifdef __cplusplus +extern "C" { +#endif + #define SKIPLIST_0TIMER_DEBUG 1 /* @@ -122,4 +126,8 @@ extern void skiplist_debug(struct vty *vty, struct skiplist *l); extern void skiplist_test(struct vty *vty); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_SKIPLIST_H */ diff --git a/lib/smux.h b/lib/smux.h index 9adfacb3e4..3f860db0dc 100644 --- a/lib/smux.h +++ b/lib/smux.h @@ -26,6 +26,10 @@ #include "thread.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Structures here are mostly compatible with UCD SNMP 4.1.1 */ #define MATCH_FAILED (-1) #define MATCH_SUCCEEDED 0 @@ -103,4 +107,8 @@ extern void oid2in_addr(oid[], int, struct in_addr *); extern void *oid_copy(void *, const void *, size_t); extern void oid_copy_addr(oid[], struct in_addr *, int); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_SNMP_H */ diff --git a/lib/sockopt.h b/lib/sockopt.h index f54f60ffd7..8fa5987cff 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -23,6 +23,10 @@ #include "sockunion.h" +#ifdef __cplusplus +extern "C" { +#endif + extern void setsockopt_so_recvbuf(int sock, int size); extern void setsockopt_so_sendbuf(const int sock, int size); extern int getsockopt_so_sendbuf(const int sock); @@ -98,4 +102,9 @@ extern void sockopt_iphdrincl_swab_systoh(struct ip *iph); extern int sockopt_tcp_rtt(int); extern int sockopt_tcp_signature(int sock, union sockunion *su, const char *password); + +#ifdef __cplusplus +} +#endif + #endif /*_ZEBRA_SOCKOPT_H */ diff --git a/lib/sockunion.h b/lib/sockunion.h index b585aee5b4..d7d26ba85a 100644 --- a/lib/sockunion.h +++ b/lib/sockunion.h @@ -28,6 +28,10 @@ #include <netmpls/mpls.h> #endif +#ifdef __cplusplus +extern "C" { +#endif + union sockunion { struct sockaddr sa; struct sockaddr_in sin; @@ -99,4 +103,8 @@ extern union sockunion *sockunion_dup(const union sockunion *); extern void sockunion_free(union sockunion *); extern void sockunion_init(union sockunion *); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_SOCKUNION_H */ diff --git a/lib/spf_backoff.h b/lib/spf_backoff.h index 6de5804ace..11b2701e3e 100644 --- a/lib/spf_backoff.h +++ b/lib/spf_backoff.h @@ -26,6 +26,10 @@ #ifndef _ZEBRA_SPF_BACKOFF_H #define _ZEBRA_SPF_BACKOFF_H +#ifdef __cplusplus +extern "C" { +#endif + struct spf_backoff; struct thread_master; struct vty; @@ -58,4 +62,8 @@ long spf_backoff_long_delay(struct spf_backoff *backoff); long spf_backoff_holddown(struct spf_backoff *backoff); long spf_backoff_timetolearn(struct spf_backoff *backoff); +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/srcdest_table.h b/lib/srcdest_table.h index 54acb51b03..8845931de7 100644 --- a/lib/srcdest_table.h +++ b/lib/srcdest_table.h @@ -46,6 +46,10 @@ #include "prefix.h" #include "table.h" +#ifdef __cplusplus +extern "C" { +#endif + #define SRCDEST2STR_BUFFER (2*PREFIX2STR_BUFFER + sizeof(" from ")) /* extended route node for IPv6 srcdest routing */ @@ -84,7 +88,8 @@ static inline int rnode_is_srcnode(struct route_node *rn) static inline struct route_table *srcdest_rnode_table(struct route_node *rn) { if (rnode_is_srcnode(rn)) { - struct route_node *dst_rn = route_table_get_info(rn->table); + struct route_node *dst_rn = + (struct route_node *)route_table_get_info(rn->table); return dst_rn->table; } else { return rn->table; @@ -95,4 +100,8 @@ static inline void *srcdest_rnode_table_info(struct route_node *rn) return route_table_get_info(srcdest_rnode_table(rn)); } +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_SRC_DEST_TABLE_H */ diff --git a/lib/stream.h b/lib/stream.h index 32b6fb5af1..5341bfa40b 100644 --- a/lib/stream.h +++ b/lib/stream.h @@ -28,6 +28,10 @@ #include "mpls.h" #include "prefix.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * A stream is an arbitrary buffer, whose contents generally are assumed to * be in network order. @@ -115,9 +119,9 @@ struct stream_fifo { pthread_mutex_t mtx; /* number of streams in this fifo */ - _Atomic size_t count; + atomic_size_t count; #if defined DEV_BUILD - _Atomic size_t max_count; + atomic_size_t max_count; #endif struct stream *head; @@ -404,4 +408,8 @@ static inline uint8_t *ptr_get_be32(uint8_t *ptr, uint32_t *out) goto stream_failure; \ } while (0) +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_STREAM_H */ diff --git a/lib/systemd.h b/lib/systemd.h index a13ea7bfdd..6e43df527d 100644 --- a/lib/systemd.h +++ b/lib/systemd.h @@ -19,6 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Wrapper functions to systemd calls. * @@ -37,3 +41,7 @@ void systemd_send_stopping(void); * process? */ void systemd_send_started(struct thread_master *master, int the_process); + +#ifdef __cplusplus +} +#endif diff --git a/lib/table.h b/lib/table.h index 541d74d77b..ce578e795c 100644 --- a/lib/table.h +++ b/lib/table.h @@ -25,6 +25,11 @@ #include "memory.h" #include "hash.h" #include "prefix.h" + +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(ROUTE_TABLE) DECLARE_MTYPE(ROUTE_NODE) @@ -318,4 +323,8 @@ static inline int route_table_iter_started(route_table_iter_t *iter) return iter->state != RT_ITER_STATE_INIT; } +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_TABLE_H */ diff --git a/lib/termtable.h b/lib/termtable.h index ca5cc1df9f..491010a856 100644 --- a/lib/termtable.h +++ b/lib/termtable.h @@ -22,6 +22,10 @@ #include <zebra.h> +#ifdef __cplusplus +extern "C" { +#endif + enum ttable_align { LEFT, RIGHT, @@ -294,4 +298,8 @@ void ttable_rowseps(struct ttable *tt, unsigned int row, */ char *ttable_dump(struct ttable *tt, const char *newline); +#ifdef __cplusplus +} +#endif + #endif /* _TERMTABLE_H */ diff --git a/lib/thread.c b/lib/thread.c index ae8e375a27..8c1b3ff06d 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -93,7 +93,8 @@ static void cpu_record_hash_free(void *a) static void vty_out_cpu_thread_history(struct vty *vty, struct cpu_thread_history *a) { - vty_out(vty, "%5d %10lu.%03lu %9u %8lu %9lu %8lu %9lu", a->total_active, + vty_out(vty, "%5"PRIdFAST32" %10lu.%03lu %9"PRIuFAST32 + " %8lu %9lu %8lu %9lu", a->total_active, a->cpu.total / 1000, a->cpu.total % 1000, a->total_calls, a->cpu.total / a->total_calls, a->cpu.max, a->real.total / a->total_calls, a->real.max); diff --git a/lib/thread.h b/lib/thread.h index f404d92755..ec774a6543 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -27,6 +27,10 @@ #include "monotime.h" #include "frratomic.h" +#ifdef __cplusplus +extern "C" { +#endif + struct rusage_t { struct rusage cpu; struct timeval real; @@ -119,13 +123,13 @@ struct thread { struct cpu_thread_history { int (*func)(struct thread *); - _Atomic unsigned int total_calls; - _Atomic unsigned int total_active; + atomic_uint_fast32_t total_calls; + atomic_uint_fast32_t total_active; struct time_stats { - _Atomic unsigned long total, max; + atomic_size_t total, max; } real; struct time_stats cpu; - _Atomic uint32_t types; + atomic_uint_fast32_t types; const char *funcname; }; @@ -233,4 +237,8 @@ extern unsigned long thread_consumed_time(RUSAGE_T *after, RUSAGE_T *before, /* only for use in logging functions! */ extern pthread_key_t thread_current; +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_THREAD_H */ diff --git a/lib/vector.h b/lib/vector.h index 97e15da040..d5857eb599 100644 --- a/lib/vector.h +++ b/lib/vector.h @@ -24,6 +24,10 @@ #include "memory.h" +#ifdef __cplusplus +extern "C" { +#endif + /* struct for vector */ struct _vector { unsigned int active; /* number of active slots */ @@ -63,4 +67,9 @@ extern void *vector_lookup(vector, unsigned int); extern void *vector_lookup_ensure(vector, unsigned int); extern void vector_to_array(vector v, void ***dest, int *argc); extern vector array_to_vector(void **src, int argc); + +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_VECTOR_H */ diff --git a/lib/vlan.h b/lib/vlan.h index 6d15e62dfc..eea2633d4e 100644 --- a/lib/vlan.h +++ b/lib/vlan.h @@ -22,8 +22,16 @@ #ifndef __VLAN_H__ #define __VLAN_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* VLAN Identifier */ typedef uint16_t vlanid_t; #define VLANID_MAX 4095 +#ifdef __cplusplus +} +#endif + #endif /* __VLAN_H__ */ @@ -471,7 +471,7 @@ static const struct cmd_variable_handler vrf_var_handlers[] = { /* Initialize VRF module. */ void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *), - int (*disable)(struct vrf *), int (*delete)(struct vrf *), + int (*disable)(struct vrf *), int (*destroy)(struct vrf *), int ((*update)(struct vrf *))) { struct vrf *default_vrf; @@ -485,7 +485,7 @@ void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *), vrf_master.vrf_new_hook = create; vrf_master.vrf_enable_hook = enable; vrf_master.vrf_disable_hook = disable; - vrf_master.vrf_delete_hook = delete; + vrf_master.vrf_delete_hook = destroy; vrf_master.vrf_update_name_hook = update; /* The default VRF always exists. */ @@ -28,6 +28,10 @@ #include "vty.h" #include "ns.h" +#ifdef __cplusplus +extern "C" { +#endif + /* The default VRF ID */ #define VRF_UNKNOWN UINT32_MAX @@ -200,7 +204,7 @@ extern int vrf_bitmap_check(vrf_bitmap_t, vrf_id_t); * the system ( 2 and 3 ) above. */ extern void vrf_init(int (*create)(struct vrf *vrf), int (*enable)(struct vrf *vrf), - int (*disable)(struct vrf *vrf), int (*delete)(struct vrf *vrf), + int (*disable)(struct vrf *vrf), int (*destroy)(struct vrf *vrf), int (*update)(struct vrf *vrf)); /* @@ -292,4 +296,8 @@ extern int vrf_enable(struct vrf *vrf); extern void vrf_delete(struct vrf *vrf); extern vrf_id_t vrf_generate_id(void); +#ifdef __cplusplus +} +#endif + #endif /*_ZEBRA_VRF_H*/ diff --git a/lib/vrf_int.h b/lib/vrf_int.h index d7fe735817..8dc078e4f3 100644 --- a/lib/vrf_int.h +++ b/lib/vrf_int.h @@ -25,6 +25,10 @@ #include "vrf.h" +#ifdef __cplusplus +extern "C" { +#endif + /* * These functions should only be called by: * zebra/if_netlink.c -> The interface from OS into Zebra @@ -52,4 +56,8 @@ extern int vrf_enable(struct vrf *); */ extern void vrf_delete(struct vrf *); +#ifdef __cplusplus +} +#endif + #endif @@ -31,6 +31,10 @@ #include "compiler.h" #include "northbound.h" +#ifdef __cplusplus +extern "C" { +#endif + #define VTY_BUFSIZ 4096 #define VTY_MAXHIST 20 #define VTY_MAXDEPTH 8 @@ -333,4 +337,8 @@ extern void vty_stdio_close(void); an async-signal-safe function. */ extern void vty_log_fixed(char *buf, size_t len); +#ifdef __cplusplus +} +#endif + #endif /* _ZEBRA_VTY_H */ diff --git a/lib/vxlan.h b/lib/vxlan.h index bcf8354539..2a8077f8cf 100644 --- a/lib/vxlan.h +++ b/lib/vxlan.h @@ -22,6 +22,10 @@ #ifndef __VXLAN_H__ #define __VXLAN_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* VxLAN Network Identifier - 24-bit (RFC 7348) */ typedef uint32_t vni_t; #define VNI_MAX 16777215 /* (2^24 - 1) */ @@ -35,4 +39,9 @@ enum vxlan_flood_control { VXLAN_FLOOD_HEAD_END_REPL = 0, VXLAN_FLOOD_DISABLED, }; + +#ifdef __cplusplus +} +#endif + #endif /* __VXLAN_H__ */ diff --git a/lib/wheel.h b/lib/wheel.h index c8e83fafcb..e66751c1d0 100644 --- a/lib/wheel.h +++ b/lib/wheel.h @@ -20,6 +20,10 @@ #ifndef __WHEEL_H__ #define __WHEEL_H__ +#ifdef __cplusplus +extern "C" { +#endif + struct timer_wheel { char *name; struct thread_master *master; @@ -115,4 +119,8 @@ int wheel_add_item(struct timer_wheel *wheel, void *item); */ int wheel_remove_item(struct timer_wheel *wheel, void *item); +#ifdef __cplusplus +} +#endif + #endif diff --git a/lib/workqueue.h b/lib/workqueue.h index cbbacc0561..7c610f5dd6 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -25,6 +25,11 @@ #include "memory.h" #include "queue.h" + +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(WORK_QUEUE) /* Hold time for the initial schedule of a queue run, in millisec */ @@ -176,4 +181,8 @@ extern int work_queue_run(struct thread *); extern void workqueue_cmd_init(void); +#ifdef __cplusplus +} +#endif + #endif /* _QUAGGA_WORK_QUEUE_H */ diff --git a/lib/yang.h b/lib/yang.h index 3259189e98..4680db08d4 100644 --- a/lib/yang.h +++ b/lib/yang.h @@ -29,6 +29,10 @@ #include "yang_wrappers.h" +#ifdef __cplusplus +extern "C" { +#endif + DECLARE_MTYPE(YANG_MODULE) DECLARE_MTYPE(YANG_DATA) @@ -521,4 +525,8 @@ extern void yang_init(void); */ extern void yang_terminate(void); +#ifdef __cplusplus +} +#endif + #endif /* _FRR_YANG_H_ */ diff --git a/lib/yang_translator.h b/lib/yang_translator.h index 6b49d1acf3..55f396a434 100644 --- a/lib/yang_translator.h +++ b/lib/yang_translator.h @@ -20,6 +20,10 @@ #ifndef _FRR_YANG_TRANSLATOR_H_ #define _FRR_YANG_TRANSLATOR_H_ +#ifdef __cplusplus +extern "C" { +#endif + #define YANG_TRANSLATE_TO_NATIVE 0 #define YANG_TRANSLATE_FROM_NATIVE 1 #define YANG_TRANSLATE_MAX 2 @@ -141,4 +145,8 @@ extern void yang_translator_init(void); */ extern void yang_translator_terminate(void); +#ifdef __cplusplus +} +#endif + #endif /* _FRR_YANG_TRANSLATOR_H_ */ diff --git a/lib/zebra.h b/lib/zebra.h index 43ab4309c2..b96fb5a206 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -232,6 +232,15 @@ typedef unsigned char uint8_t; #include "zassert.h" +/* + * Add explicit static cast only when using a C++ compiler. + */ +#ifdef __cplusplus +#define static_cast(l, r) static_cast<decltype(l)>((r)) +#else +#define static_cast(l, r) (r) +#endif + #ifndef HAVE_STRLCAT size_t strlcat(char *__restrict dest, const char *__restrict src, size_t destsize); diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 30f0e9e774..76722aad10 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -1022,3 +1022,16 @@ void ospf6_area_init(void) install_element(OSPF6_NODE, &area_filter_list_cmd); install_element(OSPF6_NODE, &no_area_filter_list_cmd); } + +void ospf6_area_interface_delete(struct ospf6_interface *oi) +{ + struct ospf6_area *oa; + struct listnode *node, *nnode; + + if (!ospf6) + return; + for (ALL_LIST_ELEMENTS(ospf6->area_list, node, nnode, oa)) + if(listnode_lookup(oa->if_list, oi)) + listnode_delete(oa->if_list, oi); + +} diff --git a/ospf6d/ospf6_area.h b/ospf6d/ospf6_area.h index ba497a168e..5648b1dfec 100644 --- a/ospf6d/ospf6_area.h +++ b/ospf6d/ospf6_area.h @@ -132,5 +132,7 @@ extern void ospf6_area_show(struct vty *, struct ospf6_area *); extern void ospf6_area_plist_update(struct prefix_list *plist, int add); extern void ospf6_area_config_write(struct vty *vty); extern void ospf6_area_init(void); +struct ospf6_interface; +extern void ospf6_area_interface_delete(struct ospf6_interface *oi); #endif /* OSPF_AREA_H */ diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index dd08144daa..83b9001fea 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -269,6 +269,9 @@ void ospf6_interface_delete(struct ospf6_interface *oi) ospf6_bfd_info_free(&(oi->bfd_info)); + /* disable from area list if possible */ + ospf6_area_interface_delete(oi); + XFREE(MTYPE_OSPF6_IF, oi); } diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 046badc824..61094c7cdb 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -43,6 +43,7 @@ #include "ospf6d.h" #include "ospf6_top.h" #include "ospf6_message.h" +#include "ospf6_network.h" #include "ospf6_asbr.h" #include "ospf6_lsa.h" #include "ospf6_interface.h" @@ -84,8 +85,10 @@ static void __attribute__((noreturn)) ospf6_exit(int status) frr_early_fini(); - if (ospf6) + if (ospf6) { ospf6_delete(ospf6); + ospf6 = NULL; + } bfd_gbl_exit(); @@ -97,6 +100,7 @@ static void __attribute__((noreturn)) ospf6_exit(int status) ospf6_asbr_terminate(); ospf6_lsa_terminate(); + ospf6_serv_close(); /* reverse access_list_init */ access_list_reset(); diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c index 8df5f1cc47..625ad884f2 100644 --- a/ospf6d/ospf6_network.c +++ b/ospf6d/ospf6_network.c @@ -73,6 +73,15 @@ static void ospf6_set_checksum(void) #endif /* DISABLE_IPV6_CHECKSUM */ } +void ospf6_serv_close(void) +{ + if (ospf6_sock > 0) { + close(ospf6_sock); + ospf6_sock = -1; + return; + } +} + /* Make ospf6d's server socket. */ int ospf6_serv_sock(void) { @@ -163,6 +172,7 @@ int ospf6_sendmsg(struct in6_addr *src, struct in6_addr *dst, assert(dst); assert(*ifindex); + memset(&cmsgbuf, 0, sizeof(cmsgbuf)); scmsgp = (struct cmsghdr *)&cmsgbuf; pktinfo = (struct in6_pktinfo *)(CMSG_DATA(scmsgp)); memset(&dst_sin6, 0, sizeof(struct sockaddr_in6)); diff --git a/ospf6d/ospf6_network.h b/ospf6d/ospf6_network.h index 7c7c155fbf..7fe6e33ff2 100644 --- a/ospf6d/ospf6_network.h +++ b/ospf6d/ospf6_network.h @@ -26,6 +26,7 @@ extern struct in6_addr allspfrouters6; extern struct in6_addr alldrouters6; extern int ospf6_serv_sock(void); +extern void ospf6_serv_close(void); extern int ospf6_sso(ifindex_t ifindex, struct in6_addr *group, int option); extern int ospf6_sendmsg(struct in6_addr *, struct in6_addr *, ifindex_t *, diff --git a/ripd/rip_cli.c b/ripd/rip_cli.c index 5bb81ef157..6fbcdc059b 100644 --- a/ripd/rip_cli.c +++ b/ripd/rip_cli.c @@ -62,7 +62,7 @@ DEFPY (no_router_rip, "Enable a routing process\n" "Routing Information Protocol (RIP)\n") { - nb_cli_enqueue_change(vty, "/frr-ripd:ripd/instance", NB_OP_DELETE, + nb_cli_enqueue_change(vty, "/frr-ripd:ripd/instance", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); @@ -213,9 +213,9 @@ DEFPY (rip_distance_source, nb_cli_enqueue_change(vty, "./distance", NB_OP_MODIFY, distance_str); nb_cli_enqueue_change(vty, "./access-list", - acl ? NB_OP_MODIFY : NB_OP_DELETE, acl); + acl ? NB_OP_MODIFY : NB_OP_DESTROY, acl); } else - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, "./distance/source[prefix='%s']", prefix_str); @@ -244,7 +244,7 @@ DEFPY (rip_neighbor, "Neighbor address\n") { nb_cli_enqueue_change(vty, "./explicit-neighbor", - no ? NB_OP_DELETE : NB_OP_CREATE, neighbor_str); + no ? NB_OP_DESTROY : NB_OP_CREATE, neighbor_str); return nb_cli_apply_changes(vty, NULL); } @@ -266,7 +266,7 @@ DEFPY (rip_network_prefix, "IP prefix <network>/<length>, e.g., 35.0.0.0/8\n") { nb_cli_enqueue_change(vty, "./network", - no ? NB_OP_DELETE : NB_OP_CREATE, network_str); + no ? NB_OP_DESTROY : NB_OP_CREATE, network_str); return nb_cli_apply_changes(vty, NULL); } @@ -288,7 +288,7 @@ DEFPY (rip_network_if, "Interface name\n") { nb_cli_enqueue_change(vty, "./interface", - no ? NB_OP_DELETE : NB_OP_CREATE, network); + no ? NB_OP_DESTROY : NB_OP_CREATE, network); return nb_cli_apply_changes(vty, NULL); } @@ -319,7 +319,7 @@ DEFPY (rip_offset_list, nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY, metric_str); } else - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); return nb_cli_apply_changes( vty, "./offset-list[interface='%s'][direction='%s']", @@ -379,9 +379,9 @@ DEFPY (rip_passive_interface, "Interface name\n") { nb_cli_enqueue_change(vty, "./passive-interface", - no ? NB_OP_DELETE : NB_OP_CREATE, ifname); + no ? NB_OP_DESTROY : NB_OP_CREATE, ifname); nb_cli_enqueue_change(vty, "./non-passive-interface", - no ? NB_OP_CREATE : NB_OP_DELETE, ifname); + no ? NB_OP_CREATE : NB_OP_DESTROY, ifname); return nb_cli_apply_changes(vty, NULL); } @@ -417,13 +417,13 @@ DEFPY (rip_redistribute, if (!no) { nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); nb_cli_enqueue_change(vty, "./route-map", - route_map ? NB_OP_MODIFY : NB_OP_DELETE, + route_map ? NB_OP_MODIFY : NB_OP_DESTROY, route_map); nb_cli_enqueue_change(vty, "./metric", - metric_str ? NB_OP_MODIFY : NB_OP_DELETE, + metric_str ? NB_OP_MODIFY : NB_OP_DESTROY, metric_str); } else - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, "./redistribute[protocol='%s']", protocol); @@ -454,7 +454,7 @@ DEFPY (rip_route, "IP prefix <network>/<length>\n") { nb_cli_enqueue_change(vty, "./static-route", - no ? NB_OP_DELETE : NB_OP_CREATE, route_str); + no ? NB_OP_DESTROY : NB_OP_CREATE, route_str); return nb_cli_apply_changes(vty, NULL); } @@ -942,7 +942,7 @@ DEFPY (no_ip_rip_authentication_key_chain, "Authentication key-chain\n" "name of key-chain\n") { - nb_cli_enqueue_change(vty, "./authentication-key-chain", NB_OP_DELETE, + nb_cli_enqueue_change(vty, "./authentication-key-chain", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, "./frr-ripd:rip"); diff --git a/ripd/rip_northbound.c b/ripd/rip_northbound.c index 4e445bd46d..1e5f86eff8 100644 --- a/ripd/rip_northbound.c +++ b/ripd/rip_northbound.c @@ -1305,7 +1305,7 @@ const struct frr_yang_module_info frr_ripd_info = { { .xpath = "/frr-ripd:ripd/instance", .cbs.create = ripd_instance_create, - .cbs.delete = ripd_instance_delete, + .cbs.destroy = ripd_instance_delete, .cbs.cli_show = cli_show_router_rip, }, { @@ -1331,7 +1331,7 @@ const struct frr_yang_module_info frr_ripd_info = { { .xpath = "/frr-ripd:ripd/instance/distance/source", .cbs.create = ripd_instance_distance_source_create, - .cbs.delete = ripd_instance_distance_source_delete, + .cbs.destroy = ripd_instance_distance_source_delete, .cbs.cli_show = cli_show_rip_distance_source, }, { @@ -1341,30 +1341,30 @@ const struct frr_yang_module_info frr_ripd_info = { { .xpath = "/frr-ripd:ripd/instance/distance/source/access-list", .cbs.modify = ripd_instance_distance_source_access_list_modify, - .cbs.delete = ripd_instance_distance_source_access_list_delete, + .cbs.destroy = ripd_instance_distance_source_access_list_delete, }, { .xpath = "/frr-ripd:ripd/instance/explicit-neighbor", .cbs.create = ripd_instance_explicit_neighbor_create, - .cbs.delete = ripd_instance_explicit_neighbor_delete, + .cbs.destroy = ripd_instance_explicit_neighbor_delete, .cbs.cli_show = cli_show_rip_neighbor, }, { .xpath = "/frr-ripd:ripd/instance/network", .cbs.create = ripd_instance_network_create, - .cbs.delete = ripd_instance_network_delete, + .cbs.destroy = ripd_instance_network_delete, .cbs.cli_show = cli_show_rip_network_prefix, }, { .xpath = "/frr-ripd:ripd/instance/interface", .cbs.create = ripd_instance_interface_create, - .cbs.delete = ripd_instance_interface_delete, + .cbs.destroy = ripd_instance_interface_delete, .cbs.cli_show = cli_show_rip_network_interface, }, { .xpath = "/frr-ripd:ripd/instance/offset-list", .cbs.create = ripd_instance_offset_list_create, - .cbs.delete = ripd_instance_offset_list_delete, + .cbs.destroy = ripd_instance_offset_list_delete, .cbs.cli_show = cli_show_rip_offset_list, }, { @@ -1383,36 +1383,36 @@ const struct frr_yang_module_info frr_ripd_info = { { .xpath = "/frr-ripd:ripd/instance/passive-interface", .cbs.create = ripd_instance_passive_interface_create, - .cbs.delete = ripd_instance_passive_interface_delete, + .cbs.destroy = ripd_instance_passive_interface_delete, .cbs.cli_show = cli_show_rip_passive_interface, }, { .xpath = "/frr-ripd:ripd/instance/non-passive-interface", .cbs.create = ripd_instance_non_passive_interface_create, - .cbs.delete = ripd_instance_non_passive_interface_delete, + .cbs.destroy = ripd_instance_non_passive_interface_delete, .cbs.cli_show = cli_show_rip_non_passive_interface, }, { .xpath = "/frr-ripd:ripd/instance/redistribute", .cbs.create = ripd_instance_redistribute_create, - .cbs.delete = ripd_instance_redistribute_delete, + .cbs.destroy = ripd_instance_redistribute_delete, .cbs.apply_finish = ripd_instance_redistribute_apply_finish, .cbs.cli_show = cli_show_rip_redistribute, }, { .xpath = "/frr-ripd:ripd/instance/redistribute/route-map", .cbs.modify = ripd_instance_redistribute_route_map_modify, - .cbs.delete = ripd_instance_redistribute_route_map_delete, + .cbs.destroy = ripd_instance_redistribute_route_map_delete, }, { .xpath = "/frr-ripd:ripd/instance/redistribute/metric", .cbs.modify = ripd_instance_redistribute_metric_modify, - .cbs.delete = ripd_instance_redistribute_metric_delete, + .cbs.destroy = ripd_instance_redistribute_metric_delete, }, { .xpath = "/frr-ripd:ripd/instance/static-route", .cbs.create = ripd_instance_static_route_create, - .cbs.delete = ripd_instance_static_route_delete, + .cbs.destroy = ripd_instance_static_route_delete, .cbs.cli_show = cli_show_rip_route, }, { @@ -1475,18 +1475,18 @@ const struct frr_yang_module_info frr_ripd_info = { { .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-scheme/md5-auth-length", .cbs.modify = lib_interface_rip_authentication_scheme_md5_auth_length_modify, - .cbs.delete = lib_interface_rip_authentication_scheme_md5_auth_length_delete, + .cbs.destroy = lib_interface_rip_authentication_scheme_md5_auth_length_delete, }, { .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-password", .cbs.modify = lib_interface_rip_authentication_password_modify, - .cbs.delete = lib_interface_rip_authentication_password_delete, + .cbs.destroy = lib_interface_rip_authentication_password_delete, .cbs.cli_show = cli_show_ip_rip_authentication_string, }, { .xpath = "/frr-interface:lib/interface/frr-ripd:rip/authentication-key-chain", .cbs.modify = lib_interface_rip_authentication_key_chain_modify, - .cbs.delete = lib_interface_rip_authentication_key_chain_delete, + .cbs.destroy = lib_interface_rip_authentication_key_chain_delete, .cbs.cli_show = cli_show_ip_rip_authentication_key_chain, }, { diff --git a/ripngd/ripng_cli.c b/ripngd/ripng_cli.c index a187e80fd7..23a4803170 100644 --- a/ripngd/ripng_cli.c +++ b/ripngd/ripng_cli.c @@ -62,7 +62,7 @@ DEFPY (no_router_ripng, "Enable a routing process\n" "Make RIPng instance command\n") { - nb_cli_enqueue_change(vty, "/frr-ripngd:ripngd/instance", NB_OP_DELETE, + nb_cli_enqueue_change(vty, "/frr-ripngd:ripngd/instance", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, NULL); @@ -170,7 +170,7 @@ DEFPY (ripng_network_prefix, "IPv6 network\n") { nb_cli_enqueue_change(vty, "./network", - no ? NB_OP_DELETE : NB_OP_CREATE, network_str); + no ? NB_OP_DESTROY : NB_OP_CREATE, network_str); return nb_cli_apply_changes(vty, NULL); } @@ -192,7 +192,7 @@ DEFPY (ripng_network_if, "Interface name\n") { nb_cli_enqueue_change(vty, "./interface", - no ? NB_OP_DELETE : NB_OP_CREATE, network); + no ? NB_OP_DESTROY : NB_OP_CREATE, network); return nb_cli_apply_changes(vty, NULL); } @@ -223,7 +223,7 @@ DEFPY (ripng_offset_list, nb_cli_enqueue_change(vty, "./metric", NB_OP_MODIFY, metric_str); } else - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); return nb_cli_apply_changes( vty, "./offset-list[interface='%s'][direction='%s']", @@ -257,7 +257,7 @@ DEFPY (ripng_passive_interface, "Interface name\n") { nb_cli_enqueue_change(vty, "./passive-interface", - no ? NB_OP_DELETE : NB_OP_CREATE, ifname); + no ? NB_OP_DESTROY : NB_OP_CREATE, ifname); return nb_cli_apply_changes(vty, NULL); } @@ -286,13 +286,13 @@ DEFPY (ripng_redistribute, if (!no) { nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL); nb_cli_enqueue_change(vty, "./route-map", - route_map ? NB_OP_MODIFY : NB_OP_DELETE, + route_map ? NB_OP_MODIFY : NB_OP_DESTROY, route_map); nb_cli_enqueue_change(vty, "./metric", - metric_str ? NB_OP_MODIFY : NB_OP_DELETE, + metric_str ? NB_OP_MODIFY : NB_OP_DESTROY, metric_str); } else - nb_cli_enqueue_change(vty, ".", NB_OP_DELETE, NULL); + nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL); return nb_cli_apply_changes(vty, "./redistribute[protocol='%s']", protocol); @@ -323,7 +323,7 @@ DEFPY (ripng_route, "Set static RIPng route announcement\n") { nb_cli_enqueue_change(vty, "./static-route", - no ? NB_OP_DELETE : NB_OP_CREATE, route_str); + no ? NB_OP_DESTROY : NB_OP_CREATE, route_str); return nb_cli_apply_changes(vty, NULL); } @@ -345,7 +345,7 @@ DEFPY (ripng_aggregate_address, "Aggregate network\n") { nb_cli_enqueue_change(vty, "./aggregate-address", - no ? NB_OP_DELETE : NB_OP_CREATE, + no ? NB_OP_DESTROY : NB_OP_CREATE, aggregate_address_str); return nb_cli_apply_changes(vty, NULL); diff --git a/ripngd/ripng_northbound.c b/ripngd/ripng_northbound.c index 7993714e8d..b6998b4ddb 100644 --- a/ripngd/ripng_northbound.c +++ b/ripngd/ripng_northbound.c @@ -845,7 +845,7 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance", .cbs.create = ripngd_instance_create, - .cbs.delete = ripngd_instance_delete, + .cbs.destroy = ripngd_instance_delete, .cbs.cli_show = cli_show_router_ripng, }, { @@ -866,19 +866,19 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance/network", .cbs.create = ripngd_instance_network_create, - .cbs.delete = ripngd_instance_network_delete, + .cbs.destroy = ripngd_instance_network_delete, .cbs.cli_show = cli_show_ripng_network_prefix, }, { .xpath = "/frr-ripngd:ripngd/instance/interface", .cbs.create = ripngd_instance_interface_create, - .cbs.delete = ripngd_instance_interface_delete, + .cbs.destroy = ripngd_instance_interface_delete, .cbs.cli_show = cli_show_ripng_network_interface, }, { .xpath = "/frr-ripngd:ripngd/instance/offset-list", .cbs.create = ripngd_instance_offset_list_create, - .cbs.delete = ripngd_instance_offset_list_delete, + .cbs.destroy = ripngd_instance_offset_list_delete, .cbs.cli_show = cli_show_ripng_offset_list, }, { @@ -892,36 +892,36 @@ const struct frr_yang_module_info frr_ripngd_info = { { .xpath = "/frr-ripngd:ripngd/instance/passive-interface", .cbs.create = ripngd_instance_passive_interface_create, - .cbs.delete = ripngd_instance_passive_interface_delete, + .cbs.destroy = ripngd_instance_passive_interface_delete, .cbs.cli_show = cli_show_ripng_passive_interface, }, { .xpath = "/frr-ripngd:ripngd/instance/redistribute", .cbs.create = ripngd_instance_redistribute_create, - .cbs.delete = ripngd_instance_redistribute_delete, + .cbs.destroy = ripngd_instance_redistribute_delete, .cbs.apply_finish = ripngd_instance_redistribute_apply_finish, .cbs.cli_show = cli_show_ripng_redistribute, }, { .xpath = "/frr-ripngd:ripngd/instance/redistribute/route-map", .cbs.modify = ripngd_instance_redistribute_route_map_modify, - .cbs.delete = ripngd_instance_redistribute_route_map_delete, + .cbs.destroy = ripngd_instance_redistribute_route_map_delete, }, { .xpath = "/frr-ripngd:ripngd/instance/redistribute/metric", .cbs.modify = ripngd_instance_redistribute_metric_modify, - .cbs.delete = ripngd_instance_redistribute_metric_delete, + .cbs.destroy = ripngd_instance_redistribute_metric_delete, }, { .xpath = "/frr-ripngd:ripngd/instance/static-route", .cbs.create = ripngd_instance_static_route_create, - .cbs.delete = ripngd_instance_static_route_delete, + .cbs.destroy = ripngd_instance_static_route_delete, .cbs.cli_show = cli_show_ripng_route, }, { .xpath = "/frr-ripngd:ripngd/instance/aggregate-address", .cbs.create = ripngd_instance_aggregate_address_create, - .cbs.delete = ripngd_instance_aggregate_address_delete, + .cbs.destroy = ripngd_instance_aggregate_address_delete, .cbs.cli_show = cli_show_ripng_aggregate_address, }, { diff --git a/sharpd/Makefile b/sharpd/Makefile new file mode 100644 index 0000000000..6a904d1a6d --- /dev/null +++ b/sharpd/Makefile @@ -0,0 +1,10 @@ +all: ALWAYS + @$(MAKE) -s -C .. sharpd/sharpd +%: ALWAYS + @$(MAKE) -s -C .. sharpd/$@ + +Makefile: + #nothing +ALWAYS: +.PHONY: ALWAYS makefiles +.SUFFIXES: diff --git a/sharpd/sharp_vty.c b/sharpd/sharp_vty.c index 0c02bd304d..9018cfb359 100644 --- a/sharpd/sharp_vty.c +++ b/sharpd/sharp_vty.c @@ -39,14 +39,22 @@ #endif DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd, - "sharp watch nexthop X:X::X:X$nhop [connected$connected]", + "sharp watch <nexthop$n|import$import> X:X::X:X$nhop [connected$connected]", "Sharp routing Protocol\n" "Watch for changes\n" "Watch for nexthop changes\n" + "Watch for import check changes\n" "The v6 nexthop to signal for watching\n" "Should the route be connected\n") { struct prefix p; + bool type_import; + + + if (n) + type_import = false; + else + type_import = true; memset(&p, 0, sizeof(p)); @@ -55,29 +63,36 @@ DEFPY(watch_nexthop_v6, watch_nexthop_v6_cmd, p.family = AF_INET6; sharp_nh_tracker_get(&p); - sharp_zebra_nexthop_watch(&p, true, !!connected); + sharp_zebra_nexthop_watch(&p, type_import, true, !!connected); return CMD_SUCCESS; } DEFPY(watch_nexthop_v4, watch_nexthop_v4_cmd, - "sharp watch nexthop A.B.C.D$nhop [connected$connected]", + "sharp watch <nexthop$n|import$import> A.B.C.D$nhop [connected$connected]", "Sharp routing Protocol\n" "Watch for changes\n" "Watch for nexthop changes\n" + "Watch for import check changes\n" "The v4 nexthop to signal for watching\n" "Should the route be connected\n") { struct prefix p; + bool type_import; memset(&p, 0, sizeof(p)); + if (n) + type_import = false; + else + type_import = true; + p.prefixlen = 32; p.u.prefix4 = nhop; p.family = AF_INET; sharp_nh_tracker_get(&p); - sharp_zebra_nexthop_watch(&p, true, !!connected); + sharp_zebra_nexthop_watch(&p, type_import, true, !!connected); return CMD_SUCCESS; } diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 30e616a057..4682dbc73a 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -320,12 +320,22 @@ void route_delete(struct prefix *p, uint8_t instance) return; } -void sharp_zebra_nexthop_watch(struct prefix *p, bool watch, bool connected) +void sharp_zebra_nexthop_watch(struct prefix *p, bool import, + bool watch, bool connected) { - int command = ZEBRA_NEXTHOP_REGISTER; + int command; - if (!watch) - command = ZEBRA_NEXTHOP_UNREGISTER; + if (!import) { + command = ZEBRA_NEXTHOP_REGISTER; + + if (!watch) + command = ZEBRA_NEXTHOP_UNREGISTER; + } else { + command = ZEBRA_IMPORT_ROUTE_REGISTER; + + if (!watch) + command = ZEBRA_IMPORT_ROUTE_UNREGISTER; + } if (zclient_send_rnh(zclient, command, p, connected, VRF_DEFAULT) < 0) zlog_warn("%s: Failure to send nexthop to zebra", @@ -405,4 +415,5 @@ void sharp_zebra_init(void) zclient->interface_address_delete = interface_address_delete; zclient->route_notify_owner = route_notify_owner; zclient->nexthop_update = sharp_nexthop_update; + zclient->import_check_update = sharp_nexthop_update; } diff --git a/sharpd/sharp_zebra.h b/sharpd/sharp_zebra.h index 7e6ac7670b..b219022f02 100644 --- a/sharpd/sharp_zebra.h +++ b/sharpd/sharp_zebra.h @@ -28,8 +28,8 @@ extern void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label); extern void route_add(struct prefix *p, uint8_t instance, struct nexthop_group *nhg); extern void route_delete(struct prefix *p, uint8_t instance); -extern void sharp_zebra_nexthop_watch(struct prefix *p, bool watch, - bool connected); +extern void sharp_zebra_nexthop_watch(struct prefix *p, bool import, + bool watch, bool connected); extern void sharp_install_routes_helper(struct prefix *p, uint8_t instance, struct nexthop_group *nhg, diff --git a/tests/.gitignore b/tests/.gitignore index 5453c0d80a..de648015f1 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -19,6 +19,7 @@ /lib/cli/test_commands /lib/cli/test_commands_defun.c /lib/northbound/test_oper_data +/lib/cxxcompat /lib/test_buffer /lib/test_checksum /lib/test_graph diff --git a/tests/lib/cxxcompat.c b/tests/lib/cxxcompat.c new file mode 100644 index 0000000000..530468642e --- /dev/null +++ b/tests/lib/cxxcompat.c @@ -0,0 +1,113 @@ +/* + * C++ compatibility compile-time smoketest + * Copyright (C) 2019 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 + */ + +#include "lib/zebra.h" + +#include "lib/agg_table.h" +#include "lib/bfd.h" +#include "lib/bitfield.h" +#include "lib/buffer.h" +#include "lib/checksum.h" +#include "lib/command.h" +#include "lib/command_graph.h" +#include "lib/command_match.h" +#include "lib/compiler.h" +#include "lib/csv.h" +#include "lib/debug.h" +#include "lib/distribute.h" +#include "lib/event_counter.h" +#include "lib/ferr.h" +#include "lib/fifo.h" +#include "lib/filter.h" +#include "lib/frr_pthread.h" +#include "lib/frratomic.h" +#include "lib/frrstr.h" +#include "lib/getopt.h" +#include "lib/graph.h" +#include "lib/hash.h" +#include "lib/hook.h" +#include "lib/id_alloc.h" +#include "lib/if.h" +#include "lib/if_rmap.h" +#include "lib/imsg.h" +#include "lib/ipaddr.h" +#include "lib/jhash.h" +#include "lib/json.h" +#include "lib/keychain.h" +#include "lib/lib_errors.h" +#include "lib/libfrr.h" +#include "lib/libospf.h" +#include "lib/linklist.h" +#include "lib/log.h" +#include "lib/logicalrouter.h" +#include "lib/md5.h" +#include "lib/memory.h" +#include "lib/memory_vty.h" +#include "lib/mlag.h" +#include "lib/module.h" +#include "lib/monotime.h" +#include "lib/mpls.h" +#include "lib/network.h" +#include "lib/nexthop.h" +#include "lib/nexthop_group.h" +#include "lib/northbound.h" +#include "lib/northbound_cli.h" +#include "lib/northbound_db.h" +#include "lib/ns.h" +#include "lib/openbsd-tree.h" +#include "lib/pbr.h" +#include "lib/plist.h" +#include "lib/pqueue.h" +#include "lib/prefix.h" +#include "lib/privs.h" +#include "lib/ptm_lib.h" +#include "lib/pw.h" +#include "lib/qobj.h" +#include "lib/queue.h" +#include "lib/ringbuf.h" +#include "lib/routemap.h" +#include "lib/sbuf.h" +#include "lib/sha256.h" +#include "lib/sigevent.h" +#include "lib/skiplist.h" +#include "lib/sockopt.h" +#include "lib/sockunion.h" +#include "lib/spf_backoff.h" +#include "lib/srcdest_table.h" +#include "lib/stream.h" +#include "lib/table.h" +#include "lib/termtable.h" +#include "lib/thread.h" +#include "lib/vector.h" +#include "lib/vlan.h" +#include "lib/vrf.h" +#include "lib/vty.h" +#include "lib/vxlan.h" +#include "lib/wheel.h" +/* #include "lib/workqueue.h" -- macro problem with STAILQ_LAST */ +#include "lib/yang.h" +#include "lib/yang_translator.h" +#include "lib/yang_wrappers.h" +#include "lib/zassert.h" +#include "lib/zclient.h" + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/tests/subdir.am b/tests/subdir.am index 42730cb83a..365fe00cc6 100644 --- a/tests/subdir.am +++ b/tests/subdir.am @@ -46,6 +46,7 @@ tests/ospf6d/tests_ospf6d_test_lsdb-test_lsdb.$(OBJEXT): tests/ospf6d/test_lsdb_ tests/ospf6d/test_lsdb-test_lsdb.$(OBJEXT): tests/ospf6d/test_lsdb_clippy.c check_PROGRAMS = \ + tests/lib/cxxcompat \ tests/lib/test_buffer \ tests/lib/test_checksum \ tests/lib/test_heavy_thread \ @@ -170,6 +171,10 @@ tests_isisd_test_isis_vertex_queue_CPPFLAGS = $(TESTS_CPPFLAGS) tests_isisd_test_isis_vertex_queue_LDADD = $(ISISD_TEST_LDADD) tests_isisd_test_isis_vertex_queue_SOURCES = tests/isisd/test_isis_vertex_queue.c +tests_lib_cxxcompat_CFLAGS = $(TESTS_CFLAGS) $(CXX_COMPAT_CFLAGS) $(WERROR) +tests_lib_cxxcompat_CPPFLAGS = $(TESTS_CPPFLAGS) +tests_lib_cxxcompat_SOURCES = tests/lib/cxxcompat.c +tests_lib_cxxcompat_LDADD = $(ALL_TESTS_LDADD) tests_lib_cli_test_cli_CFLAGS = $(TESTS_CFLAGS) tests_lib_cli_test_cli_CPPFLAGS = $(TESTS_CPPFLAGS) tests_lib_cli_test_cli_LDADD = $(ALL_TESTS_LDADD) diff --git a/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref b/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref new file mode 100644 index 0000000000..e75d896721 --- /dev/null +++ b/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref @@ -0,0 +1,12 @@ +C>* 192.168.0.0/24 is directly connected, r1-eth0, XX:XX:XX +C>* 192.168.1.0/26 is directly connected, r1-eth1, XX:XX:XX +C>* 192.168.2.0/26 is directly connected, r1-eth2, XX:XX:XX +C>* 192.168.3.0/26 is directly connected, r1-eth3, XX:XX:XX +C>* 192.168.4.0/26 is directly connected, r1-eth4, XX:XX:XX +C>* 192.168.5.0/26 is directly connected, r1-eth5, XX:XX:XX +C>* 192.168.6.0/26 is directly connected, r1-eth6, XX:XX:XX +C>* 192.168.7.0/26 is directly connected, r1-eth7, XX:XX:XX +C>* 192.168.8.0/26 is directly connected, r1-eth8, XX:XX:XX +C>* 192.168.9.0/26 is directly connected, r1-eth9, XX:XX:XX +O 192.168.0.0/24 [110/10] is directly connected, r1-eth0, XX:XX:XX +O 192.168.3.0/26 [110/10] is directly connected, r1-eth3, XX:XX:XX diff --git a/tests/topotests/all-protocol-startup/r1/ipv6_routes.ref b/tests/topotests/all-protocol-startup/r1/ipv6_routes.ref new file mode 100644 index 0000000000..88cee964d6 --- /dev/null +++ b/tests/topotests/all-protocol-startup/r1/ipv6_routes.ref @@ -0,0 +1,22 @@ +C>* fc00:0:0:1::/64 is directly connected, r1-eth1, XX:XX:XX +C>* fc00:0:0:2::/64 is directly connected, r1-eth2, XX:XX:XX +C>* fc00:0:0:3::/64 is directly connected, r1-eth3, XX:XX:XX +C>* fc00:0:0:4::/64 is directly connected, r1-eth4, XX:XX:XX +C>* fc00:0:0:5::/64 is directly connected, r1-eth5, XX:XX:XX +C>* fc00:0:0:6::/64 is directly connected, r1-eth6, XX:XX:XX +C>* fc00:0:0:7::/64 is directly connected, r1-eth7, XX:XX:XX +C>* fc00:0:0:8::/64 is directly connected, r1-eth8, XX:XX:XX +C>* fc00:0:0:9::/64 is directly connected, r1-eth9, XX:XX:XX +C>* fc00::/64 is directly connected, r1-eth0, XX:XX:XX +C>* fe80::/64 is directly connected, lo, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth0, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth1, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth2, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth3, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth4, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth5, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth6, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth7, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth8, XX:XX:XX +C * fe80::/64 is directly connected, r1-eth9, XX:XX:XX +O fc00:0:0:4::/64 [110/10] is directly connected, r1-eth4, XX:XX:XX diff --git a/tests/topotests/all-protocol-startup/test_all_protocol_startup.py b/tests/topotests/all-protocol-startup/test_all_protocol_startup.py index fb2100e03d..239de55bd6 100755 --- a/tests/topotests/all-protocol-startup/test_all_protocol_startup.py +++ b/tests/topotests/all-protocol-startup/test_all_protocol_startup.py @@ -296,10 +296,53 @@ def test_converge_protocols(): sleep(60) # Make sure that all daemons are running + failures = 0 for i in range(1, 2): fatal_error = net['r%s' % i].checkRouterRunning() assert fatal_error == "", fatal_error + print("Show that v4 routes are right\n"); + v4_routesFile = '%s/r%s/ipv4_routes.ref' % (thisDir, i) + expected = open(v4_routesFile).read().rstrip() + expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1) + + actual = net['r%s' %i].cmd('vtysh -c "show ip route" | /usr/bin/tail -n +7 | sort 2> /dev/null').rstrip() + # Drop time in last update + actual = re.sub(r" [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", " XX:XX:XX", actual) + actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1) + diff = topotest.get_textdiff(actual, expected, + title1="Actual IP Routing Table", + title2="Expected IP RoutingTable") + if diff: + sys.stderr.write('r%s failed IP Routing table check:\n%s\n' % (i, diff)) + failures += 1 + else: + print("r%s ok" %i) + + assert failures == 0, "IP Routing table failed for r%s\n%s" % (i, diff) + + failures = 0 + + print("Show that v6 routes are right\n") + v6_routesFile = '%s/r%s/ipv6_routes.ref' % (thisDir, i) + expected = open(v6_routesFile).read().rstrip() + expected = ('\n'.join(expected.splitlines()) + '\n').splitlines(1) + + actual = net['r%s' %i].cmd('vtysh -c "show ipv6 route" | /usr/bin/tail -n +7 | sort 2> /dev/null').rstrip() + # Drop time in last update + actual = re.sub(r" [0-2][0-9]:[0-5][0-9]:[0-5][0-9]", " XX:XX:XX", actual) + actual = ('\n'.join(actual.splitlines()) + '\n').splitlines(1) + diff = topotest.get_textdiff(actual, expected, + title1="Actual IPv6 Routing Table", + title2="Expected IPv6 RoutingTable") + if diff: + sys.stderr.write('r%s failed IPv6 Routing table check:\n%s\n' % (i, diff)) + failures += 1 + else: + print("r%s ok" %i) + + assert failures == 0, "IPv6 Routing table failed for r%s\n%s" % (i, diff) + # For debugging after starting FRR/Quagga daemons, uncomment the next line ## CLI(net) diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py index 31e23faede..ce542413ba 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/customize.py @@ -141,7 +141,10 @@ class ThisTestTopo(Topo): switch[1].add_link(tgen.gears['r2'], nodeif='r2-eth2') switch[1].add_link(tgen.gears['r3'], nodeif='r3-eth1') +l3mdev_accept = 0 + def ltemplatePreRouterStartHook(): + global l3mdev_accept cc = ltemplateRtrCmd() krel = platform.release() tgen = get_topogen() @@ -172,7 +175,7 @@ def ltemplatePreRouterStartHook(): 'ip ru add oif {0}-cust1 table 10', 'ip ru add iif {0}-cust1 table 10', 'ip link set dev {0}-cust1 up', - 'sysctl -w net.ipv4.udp_l3mdev_accept={}'.format(l3mdev_accept)] + 'sysctl -w net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept)] for rtr in rtrs: router = tgen.gears[rtr] for cmd in cmds: @@ -202,7 +205,7 @@ def ltemplatePreRouterStartHook(): 'ip ru add oif {0}-cust2 table 20', 'ip ru add iif {0}-cust2 table 20', 'ip link set dev {0}-cust2 up', - 'sysctl -w net.ipv4.udp_l3mdev_accept={}'.format(l3mdev_accept)] + 'sysctl -w net.ipv4.tcp_l3mdev_accept={}'.format(l3mdev_accept)] for rtr in rtrs: for cmd in cmds: cc.doCmd(tgen, rtr, cmd.format(rtr)) diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_vrf.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_vrf.py index 778d504040..f5d73a8c49 100644 --- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_vrf.py +++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_linux_vrf.py @@ -1,11 +1,12 @@ from lutil import luCommand - -rtrs = ['r1', 'r3', 'r4', 'ce1', 'ce2', 'ce3', 'ce4'] -for rtr in rtrs: +from customize import l3mdev_accept +l3mdev_rtrs = ['r1', 'r3', 'r4', 'ce4'] +for rtr in l3mdev_rtrs: luCommand(rtr,'sysctl net.ipv4.tcp_l3mdev_accept',' = \d*','none','') found = luLast() - luCommand(rtr,'ss -aep',':bgp','pass','IPv4:bgp, l3mdev%s' % found.group(0)) - luCommand(rtr,'ss -aep',':.:bgp','pass','IPv6:bgp') + luCommand(rtr,'ss -naep',':179','pass','IPv4:bgp, l3mdev{}'.format(found.group(0))) + luCommand(rtr,'ss -naep',':.*:179','pass','IPv6:bgp') + luCommand(rtr,'sysctl net.ipv4.tcp_l3mdev_accept',' = {}'.format(l3mdev_accept),'pass','l3mdev matches expected (real/expected{}/{})'.format(found.group(0),l3mdev_accept)) rtrs = ['r1', 'r3', 'r4'] for rtr in rtrs: diff --git a/tools/gen_northbound_callbacks.c b/tools/gen_northbound_callbacks.c index eded87c12e..f6c757f5d7 100644 --- a/tools/gen_northbound_callbacks.c +++ b/tools/gen_northbound_callbacks.c @@ -54,7 +54,7 @@ static struct nb_callback_info { "enum nb_event event, const struct lyd_node *dnode, union nb_resource *resource", }, { - .operation = NB_OP_DELETE, + .operation = NB_OP_DESTROY, .return_type = "int ", .return_value = "NB_OK", .arguments = diff --git a/zebra/rtadv.c b/zebra/rtadv.c index fadf8317cc..5088e2e8e1 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1780,7 +1780,7 @@ DEFUN(ipv6_nd_rdnss, { VTY_DECLVAR_CONTEXT(interface, ifp); struct zebra_if *zif = ifp->info; - struct rtadv_rdnss rdnss = {0}; + struct rtadv_rdnss rdnss = {}; if (inet_pton(AF_INET6, argv[3]->arg, &rdnss.addr) != 1) { vty_out(vty, "Malformed IPv6 address\n"); @@ -1813,7 +1813,7 @@ DEFUN(no_ipv6_nd_rdnss, { VTY_DECLVAR_CONTEXT(interface, ifp); struct zebra_if *zif = ifp->info; - struct rtadv_rdnss rdnss = {0}; + struct rtadv_rdnss rdnss = {}; if (inet_pton(AF_INET6, argv[4]->arg, &rdnss.addr) != 1) { vty_out(vty, "Malformed IPv6 address\n"); @@ -1839,7 +1839,7 @@ DEFUN(ipv6_nd_dnssl, { VTY_DECLVAR_CONTEXT(interface, ifp); struct zebra_if *zif = ifp->info; - struct rtadv_dnssl dnssl = {0}; + struct rtadv_dnssl dnssl = {}; size_t len; int ret; @@ -1889,7 +1889,7 @@ DEFUN(no_ipv6_nd_dnssl, { VTY_DECLVAR_CONTEXT(interface, ifp); struct zebra_if *zif = ifp->info; - struct rtadv_dnssl dnssl = {0}; + struct rtadv_dnssl dnssl = {}; size_t len; len = strlcpy(dnssl.name, argv[4]->arg, sizeof(dnssl.name)); diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index 0aac7d7b12..78c07f9aaf 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -1800,9 +1800,10 @@ void zebra_mpls_lsp_dplane_result(struct zebra_dplane_ctx *ctx) break; case DPLANE_OP_LSP_DELETE: - flog_warn(EC_ZEBRA_LSP_DELETE_FAILURE, - "LSP Deletion Failure: in-label %u", - dplane_ctx_get_in_label(ctx)); + if (status != ZEBRA_DPLANE_REQUEST_SUCCESS) + flog_warn(EC_ZEBRA_LSP_DELETE_FAILURE, + "LSP Deletion Failure: in-label %u", + dplane_ctx_get_in_label(ctx)); break; default: diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index dcc5a7acb0..8afcc2b685 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1089,7 +1089,7 @@ void rib_install_kernel(struct route_node *rn, struct route_entry *re, hook_call(rib_update, rn, "installing in kernel"); /* Send add or update */ - if (old && (old != re)) + if (old) ret = dplane_route_update(rn, re, old); else ret = dplane_route_add(rn, re); |
