summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_attr.c3
-rw-r--r--lib/stream.c14
-rw-r--r--lib/stream.h3
3 files changed, 16 insertions, 4 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index c64d153f1b..e21c84355e 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -2956,7 +2956,8 @@ void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
addpath_encode, addpath_tx_id);
} else if (safi == SAFI_LABELED_UNICAST) {
/* Prefix write with label. */
- stream_put_labeled_prefix(s, p, label);
+ stream_put_labeled_prefix(s, p, label, addpath_encode,
+ addpath_tx_id);
} else if (safi == SAFI_FLOWSPEC) {
if (PSIZE (p->prefixlen)+2 < FLOWSPEC_NLRI_SIZELIMIT)
stream_putc(s, PSIZE (p->prefixlen)+2);
diff --git a/lib/stream.c b/lib/stream.c
index 6c187bd359..c67bc3c993 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -904,20 +904,30 @@ int stream_put_prefix(struct stream *s, struct prefix *p)
/* Put NLRI with label */
int stream_put_labeled_prefix(struct stream *s, struct prefix *p,
- mpls_label_t *label)
+ mpls_label_t *label, int addpath_encode,
+ uint32_t addpath_tx_id)
{
size_t psize;
+ size_t psize_with_addpath;
uint8_t *label_pnt = (uint8_t *)label;
STREAM_VERIFY_SANE(s);
psize = PSIZE(p->prefixlen);
+ psize_with_addpath = psize + (addpath_encode ? 4 : 0);
- if (STREAM_WRITEABLE(s) < (psize + 3)) {
+ if (STREAM_WRITEABLE(s) < (psize_with_addpath + 3)) {
STREAM_BOUND_WARN(s, "put");
return 0;
}
+ if (addpath_encode) {
+ s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 24);
+ s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 16);
+ s->data[s->endp++] = (uint8_t)(addpath_tx_id >> 8);
+ s->data[s->endp++] = (uint8_t)addpath_tx_id;
+ }
+
stream_putc(s, (p->prefixlen + 24));
stream_putc(s, label_pnt[0]);
stream_putc(s, label_pnt[1]);
diff --git a/lib/stream.h b/lib/stream.h
index 5341bfa40b..a903ec0ea5 100644
--- a/lib/stream.h
+++ b/lib/stream.h
@@ -199,7 +199,8 @@ extern int stream_put_prefix_addpath(struct stream *, struct prefix *,
uint32_t addpath_tx_id);
extern int stream_put_prefix(struct stream *, struct prefix *);
extern int stream_put_labeled_prefix(struct stream *, struct prefix *,
- mpls_label_t *);
+ mpls_label_t *, int addpath_encode,
+ uint32_t addpath_tx_id);
extern void stream_get(void *, struct stream *, size_t);
extern bool stream_get2(void *data, struct stream *s, size_t size);
extern void stream_get_from(void *, struct stream *, size_t, size_t);