diff options
author | G. Paul Ziemba <paulz@labn.net> | 2018-03-28 19:11:56 +0200 |
---|---|---|
committer | G. Paul Ziemba <paulz@labn.net> | 2018-04-04 18:24:17 +0200 |
commit | 3572fb26ca35151b291f335074ae41deb291b466 (patch) | |
tree | 2b7db0f426a0ee0b3f01c92c1f70cfc4b13e274f | |
parent | lib/prefix.[ch]: add family2str() (diff) | |
download | frr-3572fb26ca35151b291f335074ae41deb291b466.tar.xz frr-3572fb26ca35151b291f335074ae41deb291b466.zip |
bgpd: simplify bgp instance name printing
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
-rw-r--r-- | bgpd/bgpd.c | 24 | ||||
-rw-r--r-- | bgpd/bgpd.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index ad4e7dc34..70dc11a7b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -2964,6 +2964,28 @@ static struct bgp *bgp_create(as_t *as, const char *name, bgp->restart_time, &bgp->t_startup); } + /* printable name we can use in debug messages */ + if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) { + bgp->name_pretty = XSTRDUP(MTYPE_BGP, "VRF default"); + } else { + const char *n; + int len; + + if (bgp->name) + n = bgp->name; + else + n = "?"; + + len = 4 + 1 + strlen(n) + 1; /* "view foo\0" */ + + bgp->name_pretty = XCALLOC(MTYPE_BGP, len); + snprintf(bgp->name_pretty, len, "%s %s", + (bgp->inst_type == BGP_INSTANCE_TYPE_VRF) + ? "VRF" + : "VIEW", + n); + } + atomic_store_explicit(&bgp->wpkt_quanta, BGP_WRITE_PACKET_MAX, memory_order_relaxed); atomic_store_explicit(&bgp->rpkt_quanta, BGP_READ_PACKET_MAX, @@ -3358,6 +3380,8 @@ void bgp_free(struct bgp *bgp) if (bgp->name) XFREE(MTYPE_BGP, bgp->name); + if (bgp->name_pretty) + XFREE(MTYPE_BGP, bgp->name_pretty); XFREE(MTYPE_BGP, bgp); } diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 40f887b86..0c5f72662 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -188,6 +188,7 @@ struct bgp { /* Name of this BGP instance. */ char *name; + char *name_pretty; /* printable "VRF|VIEW name|default" */ /* Type of instance and VRF id. */ enum bgp_instance_type inst_type; |