]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: safer vrf/table name (RFC9069) info tlv
authormxyns <mx.yns@outlook.fr>
Thu, 28 Jul 2022 16:23:14 +0000 (18:23 +0200)
committerMaxence Younsi <mx.yns@outlook.fr>
Sat, 4 Nov 2023 11:17:48 +0000 (12:17 +0100)
vrf_id_to_name is used for display values only and returns "Unknown" when the vrf is not found
doing a manual lookup and not providing any tlv when the vrf is not found should be better

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
bgpd/bgp_bmp.c

index e75f08eaff0ff41ed8a682881d46563aabe9a651..78528b080ac6369bced399376a58239742b62c33 100644 (file)
@@ -344,6 +344,19 @@ static void bmp_put_info_tlv(struct stream *s, uint16_t type,
        stream_put(s, string, len);
 }
 
+static void bmp_put_vrftablename_info_tlv(struct stream *s, struct bmp *bmp)
+{
+
+#define BMP_INFO_TYPE_VRFTABLENAME 3
+       char *vrftablename = "global";
+       if (bmp->targets->bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT) {
+               struct vrf *vrf = vrf_lookup_by_id(bmp->targets->bgp->vrf_id);
+               vrftablename = vrf ? vrf->name : NULL;
+       }
+       if (vrftablename != NULL)
+               bmp_put_info_tlv(s, BMP_INFO_TYPE_VRFTABLENAME, vrftablename);
+}
+
 static int bmp_send_initiation(struct bmp *bmp)
 {
        int len;