From aab1814c21a473861994a868e60bdd99adec053f Mon Sep 17 00:00:00 2001 From: Don Slice Date: Wed, 15 Mar 2017 08:43:01 -0400 Subject: [PATCH] bgpd: Fix labeled-unicast generation and parsing issues Labeled-unicast updates were being sent with an ipv6 nexthop due to not setting the mp_nexthop_len or nh_afi. On the receive side, the prefix length was being incorrectly determined and has been fixed. Also the stream for bgp_label_buf was not created. All resolved. Ticket: CM-15260 Signed-off-by: Don Slice Reviewed-by: --- bgpd/bgp_attr.c | 4 ++++ bgpd/bgp_label.c | 2 +- bgpd/bgp_zebra.c | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index acc08184b9..7a28da5780 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -2792,6 +2792,10 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi, if (nh_afi == AFI_MAX) nh_afi = BGP_NEXTHOP_AFI_FROM_NHLEN(attr->extra->mp_nexthop_len); + + if (safi == SAFI_LABELED_UNICAST) + nh_afi = AFI_IP; + /* Nexthop */ switch (nh_afi) { diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index 0c331c5d59..615eca5884 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -253,7 +253,7 @@ bgp_nlri_parse_label (struct peer *peer, struct attr *attr, /* Fill in the labels */ llen = bgp_nlri_get_labels(peer, pnt, psize, label); // zlog_debug("rcvd label [%x/%x/%x], llen=%d\n", label[0], label[1], label[2], llen); - p.prefixlen -= BSIZE(llen); + p.prefixlen = prefixlen - BSIZE(llen); /* There needs to be at least one label */ if (prefixlen < 24) diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 1ded613f65..d76eb951db 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -2272,6 +2272,7 @@ bgp_zebra_init (struct thread_master *master) bgp_nexthop_buf = stream_new(BGP_NEXTHOP_BUF_SIZE); bgp_ifindices_buf = stream_new(BGP_IFINDICES_BUF_SIZE); + bgp_label_buf = stream_new(BGP_LABEL_BUF_SIZE); } void -- 2.39.5