static struct zebra_nhlfe *
nhlfe_add(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
enum nexthop_types_t gtype, const union g_addr *gate,
- ifindex_t ifindex, uint8_t num_labels, const mpls_label_t *labels,
- bool is_backup);
+ ifindex_t ifindex, vrf_id_t vrf_id, uint8_t num_labels,
+ const mpls_label_t *labels, bool is_backup);
static int nhlfe_del(struct zebra_nhlfe *nhlfe);
static void nhlfe_free(struct zebra_nhlfe *nhlfe);
static void nhlfe_out_label_update(struct zebra_nhlfe *nhlfe,
changed++;
} else {
/* Add LSP entry to this nexthop */
- nhlfe = nhlfe_add(lsp, lsp_type, nexthop->type,
- &nexthop->gate, nexthop->ifindex,
- nexthop->nh_label->num_labels,
- nexthop->nh_label->label,
- false /*backup*/);
+ nhlfe = nhlfe_add(
+ lsp, lsp_type, nexthop->type, &nexthop->gate,
+ nexthop->ifindex, nexthop->vrf_id,
+ nexthop->nh_label->num_labels,
+ nexthop->nh_label->label, false /*backup*/);
if (!nhlfe)
return -1;
/*
* Locate NHLFE that matches with passed info.
+ * TODO: handle vrf_id if vrf backend is netns based
*/
static struct zebra_nhlfe *nhlfe_find(struct nhlfe_list_head *list,
enum lsp_types_t lsp_type,
static struct zebra_nhlfe *
nhlfe_alloc(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
enum nexthop_types_t gtype, const union g_addr *gate,
- ifindex_t ifindex, uint8_t num_labels, const mpls_label_t *labels)
+ ifindex_t ifindex, vrf_id_t vrf_id, uint8_t num_labels,
+ const mpls_label_t *labels)
{
struct zebra_nhlfe *nhlfe;
struct nexthop *nexthop;
nexthop_add_labels(nexthop, lsp_type, num_labels, labels);
- nexthop->vrf_id = VRF_DEFAULT;
+ nexthop->vrf_id = vrf_id;
nexthop->type = gtype;
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
* Add primary or backup NHLFE. Base entry must have been created and
* duplicate check done.
*/
-static struct zebra_nhlfe *nhlfe_add(struct zebra_lsp *lsp,
- enum lsp_types_t lsp_type,
- enum nexthop_types_t gtype,
- const union g_addr *gate,
- ifindex_t ifindex, uint8_t num_labels,
- const mpls_label_t *labels, bool is_backup)
+static struct zebra_nhlfe *
+nhlfe_add(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
+ enum nexthop_types_t gtype, const union g_addr *gate,
+ ifindex_t ifindex, vrf_id_t vrf_id, uint8_t num_labels,
+ const mpls_label_t *labels, bool is_backup)
{
struct zebra_nhlfe *nhlfe;
return NULL;
/* Allocate new object */
- nhlfe = nhlfe_alloc(lsp, lsp_type, gtype, gate, ifindex, num_labels,
- labels);
+ nhlfe = nhlfe_alloc(lsp, lsp_type, gtype, gate, ifindex, vrf_id,
+ num_labels, labels);
if (!nhlfe)
return NULL;
const mpls_label_t *out_labels)
{
/* Just a public pass-through to the internal implementation */
- return nhlfe_add(lsp, lsp_type, gtype, gate, ifindex, num_labels,
- out_labels, false /*backup*/);
+ return nhlfe_add(lsp, lsp_type, gtype, gate, ifindex, VRF_DEFAULT,
+ num_labels, out_labels, false /*backup*/);
}
/*
uint8_t num_labels, const mpls_label_t *out_labels)
{
/* Just a public pass-through to the internal implementation */
- return nhlfe_add(lsp, lsp_type, gtype, gate, ifindex, num_labels,
- out_labels, true);
+ return nhlfe_add(lsp, lsp_type, gtype, gate, ifindex, VRF_DEFAULT,
+ num_labels, out_labels, true);
}
/*
{
struct zebra_nhlfe *nhlfe;
- nhlfe = nhlfe_add(lsp, lsp_type, nh->type, &nh->gate, nh->ifindex,
- nh->nh_label ? nh->nh_label->num_labels : 0,
- nh->nh_label ? nh->nh_label->label : NULL,
- false /*backup*/);
+ nhlfe = nhlfe_add(
+ lsp, lsp_type, nh->type, &nh->gate, nh->ifindex, nh->vrf_id,
+ nh->nh_label ? nh->nh_label->num_labels : 0,
+ nh->nh_label ? nh->nh_label->label : NULL, false /*backup*/);
return nhlfe;
}
struct zebra_nhlfe *nhlfe;
nhlfe = nhlfe_add(lsp, lsp_type, nh->type, &nh->gate, nh->ifindex,
+ nh->vrf_id,
nh->nh_label ? nh->nh_label->num_labels : 0,
nh->nh_label ? nh->nh_label->label : NULL, true);
lsp_add_nhlfe(struct zebra_lsp *lsp, enum lsp_types_t type,
uint8_t num_out_labels, const mpls_label_t *out_labels,
enum nexthop_types_t gtype, const union g_addr *gate,
- ifindex_t ifindex, bool is_backup)
+ ifindex_t ifindex, vrf_id_t vrf_id, bool is_backup)
{
struct zebra_nhlfe *nhlfe;
char buf[MPLS_LABEL_STRLEN];
}
} else {
/* Add LSP entry to this nexthop */
- nhlfe = nhlfe_add(lsp, type, gtype, gate, ifindex,
+ nhlfe = nhlfe_add(lsp, type, gtype, gate, ifindex, vrf_id,
num_out_labels, out_labels, is_backup);
if (!nhlfe)
return NULL;
/*
* Install an LSP and forwarding entry; used primarily
* from vrf zapi message processing.
+ * TODO: handle vrf_id parameter when mpls API extends to interface or SRTE
+ * changes
*/
int mpls_lsp_install(struct zebra_vrf *zvrf, enum lsp_types_t type,
mpls_label_t in_label, uint8_t num_out_labels,
lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
nhlfe = lsp_add_nhlfe(lsp, type, num_out_labels, out_labels, gtype,
- gate, ifindex, false /*backup*/);
+ gate, ifindex, VRF_DEFAULT, false /*backup*/);
if (nhlfe == NULL)
return -1;
{
struct zebra_nhlfe *nhlfe;
- nhlfe = lsp_add_nhlfe(lsp, type, znh->label_num, znh->labels,
- znh->type, &znh->gate, znh->ifindex,
+ nhlfe = lsp_add_nhlfe(lsp, type, znh->label_num, znh->labels, znh->type,
+ &znh->gate, znh->ifindex, znh->vrf_id,
false /*backup*/);
if (nhlfe == NULL)
return -1;
{
struct zebra_nhlfe *nhlfe;
- nhlfe = lsp_add_nhlfe(lsp, type, znh->label_num,
- znh->labels, znh->type, &znh->gate,
- znh->ifindex, true /*backup*/);
+ nhlfe = lsp_add_nhlfe(lsp, type, znh->label_num, znh->labels, znh->type,
+ &znh->gate, znh->ifindex, znh->vrf_id,
+ true /*backup*/);
if (nhlfe == NULL) {
if (IS_ZEBRA_DEBUG_MPLS)
zlog_debug("%s: unable to add backup nhlfe, label: %u",
} else {
/* Add static LSP entry to this nexthop */
- nhlfe = nhlfe_add(lsp, ZEBRA_LSP_STATIC, gtype, gate,
- ifindex, 1, &out_label, false /*backup*/);
+ nhlfe = nhlfe_add(lsp, ZEBRA_LSP_STATIC, gtype, gate, ifindex,
+ VRF_DEFAULT, 1, &out_label, false /*backup*/);
if (!nhlfe)
return -1;