summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_evpn_vty.c3
-rw-r--r--bgpd/bgp_mplsvpn.c3
-rw-r--r--doc/developer/subdir.am2
-rw-r--r--lib/vrf.c9
-rw-r--r--ospfd/ospf_packet.c1
-rw-r--r--pbrd/pbr_zebra.c5
-rwxr-xr-x[-rw-r--r--]tests/topotests/bgp-vrf-route-leak-basic/test_bgp.py0
-rw-r--r--tests/topotests/bgp_rfapi_basic_sanity/scripts/cleanup_all.py3
-rwxr-xr-xtests/topotests/conftest.py14
-rw-r--r--zebra/if_netlink.c23
-rw-r--r--zebra/interface.c21
-rw-r--r--zebra/interface.h3
-rw-r--r--zebra/zapi_msg.c3
-rw-r--r--zebra/zebra_dplane.c23
-rw-r--r--zebra/zebra_rib.c33
-rw-r--r--zebra/zserv.c7
-rw-r--r--zebra/zserv.h16
17 files changed, 107 insertions, 62 deletions
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c
index 4dccc89f52..63b3145b53 100644
--- a/bgpd/bgp_evpn_vty.c
+++ b/bgpd/bgp_evpn_vty.c
@@ -3259,9 +3259,6 @@ DEFPY(bgp_evpn_advertise_svi_ip_vni,
if (!bgp)
return CMD_WARNING;
- if (!vpn)
- return CMD_WARNING;
-
if (no)
evpn_set_advertise_svi_macip(bgp, vpn, 0);
else
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index d7cb84c323..6eddd0e1e3 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -319,9 +319,6 @@ void vpn_leak_zebra_vrf_label_withdraw(struct bgp *bgp, afi_t afi)
bgp->name_pretty, bgp->vrf_id);
}
- if (label == BGP_PREVENT_VRF_2_VRF_LEAK)
- label = MPLS_LABEL_NONE;
-
zclient_send_vrf_label(zclient, bgp->vrf_id, afi, label, ZEBRA_LSP_BGP);
bgp->vpn_policy[afi].tovpn_zebra_vrf_label_last_sent = label;
}
diff --git a/doc/developer/subdir.am b/doc/developer/subdir.am
index 479aa04d59..996f12d47f 100644
--- a/doc/developer/subdir.am
+++ b/doc/developer/subdir.am
@@ -40,7 +40,7 @@ dev_RSTFILES = \
doc/developer/ospf-sr.rst \
doc/developer/ospf.rst \
doc/developer/packaging-debian.rst \
- doc/developer/packaging-redhat.rst
+ doc/developer/packaging-redhat.rst \
doc/developer/packaging.rst \
doc/developer/testing.rst \
doc/developer/topotests-snippets.rst \
diff --git a/lib/vrf.c b/lib/vrf.c
index de50e6a517..6d9ac2e1e4 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -860,7 +860,6 @@ void vrf_cmd_init(int (*writefunc)(struct vty *vty),
void vrf_set_default_name(const char *default_name, bool force)
{
struct vrf *def_vrf;
- struct vrf *vrf_with_default_name = NULL;
static bool def_vrf_forced;
def_vrf = vrf_lookup_by_id(VRF_DEFAULT);
@@ -871,13 +870,7 @@ void vrf_set_default_name(const char *default_name, bool force)
def_vrf->vrf_id);
return;
}
- if (vrf_with_default_name && vrf_with_default_name != def_vrf) {
- /* vrf name already used by an other VRF */
- zlog_debug("VRF: %s, avoid changing name to %s, same name exists (%u)",
- vrf_with_default_name->name, default_name,
- vrf_with_default_name->vrf_id);
- return;
- }
+
snprintf(vrf_default_name, VRF_NAMSIZ, "%s", default_name);
if (def_vrf) {
if (force)
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index 43c5e338b0..6bc8c25153 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -2107,7 +2107,6 @@ static void ospf_ls_upd(struct ospf *ospf, struct ip *iph,
dump_lsa_key(lsa));
DISCARD_LSA(lsa, 4);
- continue;
}
/* Actual flooding procedure. */
diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c
index 4f8f50556b..1396d83d65 100644
--- a/pbrd/pbr_zebra.c
+++ b/pbrd/pbr_zebra.c
@@ -111,8 +111,9 @@ static int interface_address_add(int command, struct zclient *zclient,
c = zebra_interface_address_read(command, zclient->ibuf, vrf_id);
DEBUGD(&pbr_dbg_zebra,
- "%s: %s added %s", __PRETTY_FUNCTION__, c->ifp->name,
- prefix2str(c->address, buf, sizeof(buf)));
+ "%s: %s added %s", __PRETTY_FUNCTION__,
+ c ? c->ifp->name : "Unknown",
+ c ? prefix2str(c->address, buf, sizeof(buf)) : "Unknown");
return 0;
}
diff --git a/tests/topotests/bgp-vrf-route-leak-basic/test_bgp.py b/tests/topotests/bgp-vrf-route-leak-basic/test_bgp.py
index b0d60403db..b0d60403db 100644..100755
--- a/tests/topotests/bgp-vrf-route-leak-basic/test_bgp.py
+++ b/tests/topotests/bgp-vrf-route-leak-basic/test_bgp.py
diff --git a/tests/topotests/bgp_rfapi_basic_sanity/scripts/cleanup_all.py b/tests/topotests/bgp_rfapi_basic_sanity/scripts/cleanup_all.py
index 096e97fa94..e9c1916f75 100644
--- a/tests/topotests/bgp_rfapi_basic_sanity/scripts/cleanup_all.py
+++ b/tests/topotests/bgp_rfapi_basic_sanity/scripts/cleanup_all.py
@@ -10,7 +10,8 @@ luCommand('r3','vtysh -c "debug rfapi-dev close vn 10.0.0.2 un 2.2.2.2"','status
luCommand('r4','vtysh -c "debug rfapi-dev unregister vn 10.0.0.3 un 3.3.3.3 prefix 33.33.33.0/24"','', 'none', 'Prefix removed')
luCommand('r4','vtysh -c "debug rfapi-dev unregister vn 10.0.0.3 un 3.3.3.3 prefix 11.11.11.0/24"','', 'none', 'MP prefix removed')
luCommand('r4','vtysh -c "show vnc registrations"','Locally: *Active: 0 ','wait','Local registration removed')
-luCommand('r4','vtysh -c "debug rfapi-dev close vn 10.0.0.3 un 3.3.3.3"','status 0', 'pass', 'Closed RFAPI')
+#luCommand('r4','vtysh -c "debug rfapi-dev close vn 10.0.0.3 un 3.3.3.3"','status 0', 'pass', 'Closed RFAPI')
+luCommand('r4','vtysh -c "clear vnc nve *"','.', 'pass', 'Cleared NVEs')
luCommand('r1','vtysh -c "show vnc registrations"','Locally: *Active: 0 .* Remotely: *Active: 0','wait','All registrations cleared')
luCommand('r3','vtysh -c "show vnc registrations"','Locally: *Active: 0 .* Remotely: *Active: 0','wait','All registrations cleared')
diff --git a/tests/topotests/conftest.py b/tests/topotests/conftest.py
index 327e4625f2..49e48ba927 100755
--- a/tests/topotests/conftest.py
+++ b/tests/topotests/conftest.py
@@ -7,6 +7,8 @@ from lib.topotest import json_cmp_result
from lib.topolog import logger
import pytest
+topology_only = False
+
def pytest_addoption(parser):
"""
Add topology-only option to the topology tester. This option makes pytest
@@ -20,9 +22,9 @@ def pytest_runtest_call():
This function must be run after setup_module(), it does standarized post
setup routines. It is only being used for the 'topology-only' option.
"""
- # pylint: disable=E1101
- # Trust me, 'config' exists.
- if pytest.config.getoption('--topology-only'):
+ global topology_only
+
+ if topology_only:
tgen = get_topogen()
if tgen is not None:
# Allow user to play with the setup.
@@ -44,9 +46,15 @@ def pytest_assertrepr_compare(op, left, right):
def pytest_configure(config):
"Assert that the environment is correctly configured."
+
+ global topology_only
+
if not diagnose_env():
pytest.exit('enviroment has errors, please read the logs')
+ if config.getoption('--topology-only'):
+ topology_only = True
+
def pytest_runtest_makereport(item, call):
"Log all assert messages to default logger with error level"
# Nothing happened
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index ba518ea576..ce0834f190 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -690,9 +690,6 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ifp->speed = get_iflink_speed(ifp);
ifp->ptm_status = ZEBRA_PTM_STATUS_UNKNOWN;
- if (desc)
- ifp->desc = XSTRDUP(MTYPE_TMP, desc);
-
/* Set zebra interface type */
zebra_if_set_ziftype(ifp, zif_type, zif_slave_type);
if (IS_ZEBRA_IF_VRF(ifp))
@@ -707,6 +704,11 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup)
zif = (struct zebra_if *)ifp->info;
zif->link_ifindex = link_ifindex;
+ if (desc) {
+ XFREE(MTYPE_TMP, zif->desc);
+ zif->desc = XSTRDUP(MTYPE_TMP, desc);
+ }
+
/* Hardware type and address. */
ifp->ll_type = netlink_to_zebra_link_type(ifi->ifi_type);
netlink_interface_update_hw_addr(tb, ifp);
@@ -1106,7 +1108,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
ifindex_t bond_ifindex = IFINDEX_INTERNAL;
ifindex_t link_ifindex = IFINDEX_INTERNAL;
uint8_t old_hw_addr[INTERFACE_HWADDR_MAX];
-
+ struct zebra_if *zif;
zns = zebra_ns_lookup(ns_id);
ifi = NLMSG_DATA(h);
@@ -1186,12 +1188,6 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
/* See if interface is present. */
ifp = if_lookup_by_name_per_ns(zns, name);
- if (ifp) {
- XFREE(MTYPE_TMP, ifp->desc);
- if (desc)
- ifp->desc = XSTRDUP(MTYPE_TMP, desc);
- }
-
if (h->nlmsg_type == RTM_NEWLINK) {
if (tb[IFLA_MASTER]) {
if (slave_kind && (strcmp(slave_kind, "vrf") == 0)
@@ -1390,6 +1386,13 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
if_delete_update(ifp);
}
+ zif = ifp->info;
+ if (zif) {
+ XFREE(MTYPE_TMP, zif->desc);
+ if (desc)
+ zif->desc = XSTRDUP(MTYPE_TMP, desc);
+ }
+
return 0;
}
diff --git a/zebra/interface.c b/zebra/interface.c
index 10f1f92100..b0ddcaf8bc 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -181,6 +181,7 @@ static int if_zebra_delete_hook(struct interface *ifp)
list_delete(&rtadv->AdvDNSSLList);
#endif /* HAVE_RTADV */
+ XFREE(MTYPE_TMP, zebra_if->desc);
THREAD_OFF(zebra_if->speed_update);
XFREE(MTYPE_ZINFO, zebra_if);
@@ -1303,6 +1304,9 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp)
if (ifp->desc)
vty_out(vty, " Description: %s\n", ifp->desc);
+ if (zebra_if->desc)
+ vty_out(vty, " OS Description: %s\n", zebra_if->desc);
+
if (ifp->ifindex == IFINDEX_INTERNAL) {
vty_out(vty, " pseudo interface\n");
return;
@@ -1696,6 +1700,10 @@ static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
vty_out(vty, "Interface Status Protocol Description\n");
FOR_ALL_INTERFACES (vrf, ifp) {
int len;
+ struct zebra_if *zif;
+ bool intf_desc;
+
+ intf_desc = false;
len = vty_out(vty, "%s", ifp->name);
vty_out(vty, "%*s", (16 - len), " ");
@@ -1715,8 +1723,19 @@ static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
vty_out(vty, "down down ");
}
- if (ifp->desc)
+ if (ifp->desc) {
+ intf_desc = true;
vty_out(vty, "%s", ifp->desc);
+ }
+ zif = ifp->info;
+ if (zif && zif->desc) {
+ vty_out(vty, "%s%s",
+ intf_desc
+ ? "\n "
+ : "",
+ zif->desc);
+ }
+
vty_out(vty, "\n");
}
}
diff --git a/zebra/interface.h b/zebra/interface.h
index ce404e8253..bbb5445cc6 100644
--- a/zebra/interface.h
+++ b/zebra/interface.h
@@ -342,6 +342,9 @@ struct zebra_if {
bool v6_2_v4_ll_neigh_entry;
char neigh_mac[6];
struct in6_addr v6_2_v4_ll_addr6;
+
+ /* The description of the interface */
+ char *desc;
};
DECLARE_HOOK(zebra_if_extra_info, (struct vty * vty, struct interface *ifp),
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index f31fb53a34..7f6af82018 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -2507,6 +2507,9 @@ void zserv_handle_commands(struct zserv *client, struct stream *msg)
zapi_parse_header(msg, &hdr);
+ if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
+ zserv_log_message(NULL, msg, &hdr);
+
#if defined(HANDLE_ZAPI_FUZZING)
zserv_write_incoming(msg, hdr.command);
#endif
diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c
index d1b28227c3..ae52762c5a 100644
--- a/zebra/zebra_dplane.c
+++ b/zebra/zebra_dplane.c
@@ -1344,10 +1344,6 @@ dplane_route_update_internal(struct route_node *rn,
/* Obtain context block */
ctx = dplane_ctx_alloc();
- if (ctx == NULL) {
- ret = ENOMEM;
- goto done;
- }
/* Init context with info from zebra data structs */
ret = dplane_ctx_route_init(ctx, op, rn, re);
@@ -1382,7 +1378,6 @@ dplane_route_update_internal(struct route_node *rn,
ret = dplane_route_enqueue(ctx);
}
-done:
/* Update counter */
atomic_fetch_add_explicit(&zdplane_info.dg_routes_in, 1,
memory_order_relaxed);
@@ -1562,10 +1557,6 @@ static enum zebra_dplane_result lsp_update_internal(zebra_lsp_t *lsp,
/* Obtain context block */
ctx = dplane_ctx_alloc();
- if (ctx == NULL) {
- ret = ENOMEM;
- goto done;
- }
ret = dplane_ctx_lsp_init(ctx, op, lsp);
if (ret != AOK)
@@ -1601,10 +1592,6 @@ static enum zebra_dplane_result pw_update_internal(struct zebra_pw *pw,
struct zebra_dplane_ctx *ctx = NULL;
ctx = dplane_ctx_alloc();
- if (ctx == NULL) {
- ret = ENOMEM;
- goto done;
- }
ret = dplane_ctx_pw_init(ctx, op, pw);
if (ret != AOK)
@@ -1691,10 +1678,6 @@ static enum zebra_dplane_result intf_addr_update_internal(
}
ctx = dplane_ctx_alloc();
- if (ctx == NULL) {
- ret = ENOMEM;
- goto done;
- }
ctx->zd_op = op;
ctx->zd_status = ZEBRA_DPLANE_REQUEST_SUCCESS;
@@ -1706,7 +1689,7 @@ static enum zebra_dplane_result intf_addr_update_internal(
/* Init the interface-addr-specific area */
memset(&ctx->u.intf, 0, sizeof(ctx->u.intf));
- strncpy(ctx->u.intf.ifname, ifp->name, sizeof(ctx->u.intf.ifname));
+ strlcpy(ctx->u.intf.ifname, ifp->name, sizeof(ctx->u.intf.ifname));
ctx->u.intf.ifindex = ifp->ifindex;
ctx->u.intf.prefix = *(ifc->address);
@@ -1734,7 +1717,7 @@ static enum zebra_dplane_result intf_addr_update_internal(
len = strlen(ifc->label);
if (len < sizeof(ctx->u.intf.label_buf)) {
- strncpy(ctx->u.intf.label_buf, ifc->label,
+ strlcpy(ctx->u.intf.label_buf, ifc->label,
sizeof(ctx->u.intf.label_buf));
ctx->u.intf.label = ctx->u.intf.label_buf;
} else {
@@ -1744,8 +1727,6 @@ static enum zebra_dplane_result intf_addr_update_internal(
ret = dplane_route_enqueue(ctx);
-done:
-
/* Increment counter */
atomic_fetch_add_explicit(&zdplane_info.dg_intf_addrs_in, 1,
memory_order_relaxed);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 626583a848..10be5d8fa5 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -71,7 +71,7 @@ extern int allow_delete;
/* Each route type's string and default distance value. */
static const struct {
int key;
- int distance;
+ uint8_t distance;
uint8_t meta_q_map;
} route_info[ZEBRA_ROUTE_MAX] = {
[ZEBRA_ROUTE_SYSTEM] = {ZEBRA_ROUTE_SYSTEM, 0, 4},
@@ -98,6 +98,10 @@ static const struct {
[ZEBRA_ROUTE_BGP_DIRECT_EXT] = {ZEBRA_ROUTE_BGP_DIRECT_EXT, 20, 3},
[ZEBRA_ROUTE_BABEL] = {ZEBRA_ROUTE_BABEL, 100, 2},
[ZEBRA_ROUTE_SHARP] = {ZEBRA_ROUTE_SHARP, 150, 4},
+ [ZEBRA_ROUTE_PBR] = {ZEBRA_ROUTE_PBR, 200, 4},
+ [ZEBRA_ROUTE_BFD] = {ZEBRA_ROUTE_BFD, 255, 4},
+ [ZEBRA_ROUTE_OPENFABRIC] = {ZEBRA_ROUTE_OPENFABRIC, 115, 2},
+ /* Any new route type added to zebra, should be mirrored here */
/* no entry/default: 150 */
};
@@ -470,8 +474,7 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
"\t%s: Interface %s is not unnumbered",
- __PRETTY_FUNCTION__,
- ifp ? ifp->name : "Unknown");
+ __PRETTY_FUNCTION__, ifp->name);
return 0;
}
}
@@ -3386,9 +3389,33 @@ static int rib_dplane_results(struct dplane_ctx_q *ctxlist)
return 0;
}
+/*
+ * Ensure there are no empty slots in the route_info array.
+ * Every route type in zebra should be present there.
+ */
+static void check_route_info(void)
+{
+ int len = array_size(route_info);
+
+ /*
+ * ZEBRA_ROUTE_SYSTEM is special cased since
+ * its key is 0 anyway.
+ *
+ * ZEBRA_ROUTE_ALL is also ignored.
+ */
+ for (int i = 0; i < len; i++) {
+ if (i == ZEBRA_ROUTE_SYSTEM || i == ZEBRA_ROUTE_ALL)
+ continue;
+ assert(route_info[i].key);
+ assert(route_info[i].meta_q_map < MQ_SIZE);
+ }
+}
+
/* Routing information base initialize. */
void rib_init(void)
{
+ check_route_info();
+
rib_queue_init();
/* Init dataplane, and register for results */
diff --git a/zebra/zserv.c b/zebra/zserv.c
index df5f236c04..e7b0a2302d 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -149,8 +149,8 @@ static void zserv_event(struct zserv *client, enum zserv_event event);
* hdr (optional)
* The message header
*/
-static void zserv_log_message(const char *errmsg, struct stream *msg,
- struct zmsghdr *hdr)
+void zserv_log_message(const char *errmsg, struct stream *msg,
+ struct zmsghdr *hdr)
{
zlog_debug("Rx'd ZAPI message");
if (errmsg)
@@ -411,9 +411,6 @@ static int zserv_read(struct thread *thread)
hdr.vrf_id, hdr.length,
sock);
- if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
- zserv_log_message(NULL, client->ibuf_work, &hdr);
-
stream_set_getp(client->ibuf_work, 0);
struct stream *msg = stream_dup(client->ibuf_work);
diff --git a/zebra/zserv.h b/zebra/zserv.h
index 90fd195712..380f23916e 100644
--- a/zebra/zserv.h
+++ b/zebra/zserv.h
@@ -240,6 +240,22 @@ extern struct zserv *zserv_find_client(uint8_t proto, unsigned short instance);
*/
extern void zserv_close_client(struct zserv *client);
+
+/*
+ * Log a ZAPI message hexdump.
+ *
+ * errmsg
+ * Error message to include with packet hexdump
+ *
+ * msg
+ * Message to log
+ *
+ * hdr
+ * Message header
+ */
+void zserv_log_message(const char *errmsg, struct stream *msg,
+ struct zmsghdr *hdr);
+
#if defined(HANDLE_ZAPI_FUZZING)
extern void zserv_read_file(char *input);
#endif