summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_label.c
diff options
context:
space:
mode:
authorVivek Venkatraman <vivek@cumulusnetworks.com>2017-03-09 18:55:54 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-04-06 16:32:07 +0200
commit28d58fd7b166836029656c29ad8ed9a9e8a744ac (patch)
tree549a60873cfe73d04c055447fc599e667cb1d71c /bgpd/bgp_label.c
parentbgpd: This patch implements the exchange of the BGP-Prefix-SID label index attr (diff)
downloadfrr-28d58fd7b166836029656c29ad8ed9a9e8a744ac.tar.xz
frr-28d58fd7b166836029656c29ad8ed9a9e8a744ac.zip
bgpd, lib, zebra: Implement handling of BGP-Prefix-SID label Index
Implement BGP Prefix-SID IETF draft to be able to signal a labeled-unicast prefix with a label index (segment ID). This makes it easier to deploy global MPLS labels with BGP, even without other aspects of Segment Routing implemented. This patch implements the handling of the BGP-Prefix-SID Label Index attribute. When received from a peer and the index is acceptable, the local label is picked up from the SRGB and is programmed as the incoming label as well as advertised to peers. If the index is not acceptable, no local label is assigned. The outgoing label will always be the one advertised by the downstream neighbor. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_label.c')
-rw-r--r--bgpd/bgp_label.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index e2c4a5404..0c331c5d5 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -125,11 +125,14 @@ bgp_adv_label (struct bgp_node *rn, struct bgp_info *ri, struct peer *to,
}
void
-bgp_reg_dereg_for_label (struct bgp_node *rn, int reg)
+bgp_reg_dereg_for_label (struct bgp_node *rn, struct bgp_info *ri,
+ int reg)
{
struct stream *s;
struct prefix *p;
int command;
+ u_int16_t flags = 0;
+ size_t flags_pos = 0;
/* Check socket. */
if (!zclient || zclient->sock < 0)
@@ -140,17 +143,29 @@ bgp_reg_dereg_for_label (struct bgp_node *rn, int reg)
stream_reset (s);
command = (reg) ? ZEBRA_FEC_REGISTER : ZEBRA_FEC_UNREGISTER;
zclient_create_header (s, command, VRF_DEFAULT);
+ flags_pos = stream_get_endp (s); /* save position of 'flags' */
+ stream_putw(s, flags); /* initial flags */
stream_putw(s, PREFIX_FAMILY(p));
stream_put_prefix(s, p);
- stream_putw_at (s, 0, stream_get_endp (s));
-
if (reg)
- SET_FLAG (rn->flags, BGP_NODE_REGISTERED_FOR_LABEL);
+ {
+ assert (ri);
+ if (ri->attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LABEL_INDEX))
+ {
+ assert (ri->attr->extra);
+ flags |= ZEBRA_FEC_REGISTER_LABEL_INDEX;
+ stream_putl (s, ri->attr->extra->label_index);
+ }
+ SET_FLAG (rn->flags, BGP_NODE_REGISTERED_FOR_LABEL);
+ }
else
UNSET_FLAG (rn->flags, BGP_NODE_REGISTERED_FOR_LABEL);
- zclient_send_message(zclient);
- return;
+ /* Set length and flags */
+ stream_putw_at (s, 0, stream_get_endp (s));
+ stream_putw_at (s, flags_pos, flags);
+
+ zclient_send_message(zclient);
}
static int