mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 18:10:23 +00:00
zebra: handle nexthop vrf_id in ZEBRA_MPLS_LABELS messages
This commit addresses the case where a service wants to install an LSP entry to a next-hop located in a VRF instance. The incoming MPLS packet is on the namespace and has to be directed to a nexthop located behind an interface that sits in a specific VRF instance. The below iproute command can illustrate: > ip link add vrf1 type vrf table 10 > ip link set dev vrf1 up > ip link set dev eth0 master vrf1 > ip a a 192.0.2.1/24 dev eth0 > ip -f mpls route add 105 via inet 192.0.2.45 dev eth0 If a service uses the ZEBRA_MPLS_LABELS messages, then the LSP message is ignored: from zebra perspective, the MPLS entries are visible via the 'show mpls table' command, but no LSP entry is installed in the kernel. The issue is in the nhlfe_nexthop_active_ipv[4/6] function: the outgoing interface mentioned in the nexthop is searched in the main VRF, whereas the interface is in a separate VRF. The interface is not found, and the nhlfe to install is considered not active. To address this issue, reuse the incoming vrf_id parameter transmitted in the nexthop structure from the ZEBRA_MPLS_LABELS message. When creating an NHLFE entry, the vrf_id is used instead of the DEFAULT_VRF. And the nhlfe entry can be considered as active. One alternate solution to reuse the vrf_id parameter in the mpls network context would be to modify the search function in nhlfe_nexthop_active..() function: looking for an existing ifindex in the zns. However, this solution may not fit later when netns backend would be used. Note that some changes have not been done yet and are considered sufficient for now: - The 'nhlfe_find' API: the assumption is done that only the linux vrf backend is used for now. - The 'mpls_lsp_install()' API: It is currently used by the CLI command which does not handle the interface parameter, and the SRTE service, whih always sends LSPs towards a nexthop located in the VRF_DEFAULT. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
parent
bd21ba79aa
commit
7bae48960e
@ -97,8 +97,8 @@ static struct zebra_nhlfe *nhlfe_find(struct nhlfe_list_head *list,
|
|||||||
static struct zebra_nhlfe *
|
static struct zebra_nhlfe *
|
||||||
nhlfe_add(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
|
nhlfe_add(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
|
||||||
enum nexthop_types_t gtype, const union g_addr *gate,
|
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,
|
||||||
bool is_backup);
|
const mpls_label_t *labels, bool is_backup);
|
||||||
static int nhlfe_del(struct zebra_nhlfe *nhlfe);
|
static int nhlfe_del(struct zebra_nhlfe *nhlfe);
|
||||||
static void nhlfe_free(struct zebra_nhlfe *nhlfe);
|
static void nhlfe_free(struct zebra_nhlfe *nhlfe);
|
||||||
static void nhlfe_out_label_update(struct zebra_nhlfe *nhlfe,
|
static void nhlfe_out_label_update(struct zebra_nhlfe *nhlfe,
|
||||||
@ -212,11 +212,11 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label,
|
|||||||
changed++;
|
changed++;
|
||||||
} else {
|
} else {
|
||||||
/* Add LSP entry to this nexthop */
|
/* Add LSP entry to this nexthop */
|
||||||
nhlfe = nhlfe_add(lsp, lsp_type, nexthop->type,
|
nhlfe = nhlfe_add(
|
||||||
&nexthop->gate, nexthop->ifindex,
|
lsp, lsp_type, nexthop->type, &nexthop->gate,
|
||||||
nexthop->nh_label->num_labels,
|
nexthop->ifindex, nexthop->vrf_id,
|
||||||
nexthop->nh_label->label,
|
nexthop->nh_label->num_labels,
|
||||||
false /*backup*/);
|
nexthop->nh_label->label, false /*backup*/);
|
||||||
if (!nhlfe)
|
if (!nhlfe)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -1236,6 +1236,7 @@ static int nhlfe_nhop_match(struct zebra_nhlfe *nhlfe,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Locate NHLFE that matches with passed info.
|
* 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,
|
static struct zebra_nhlfe *nhlfe_find(struct nhlfe_list_head *list,
|
||||||
enum lsp_types_t lsp_type,
|
enum lsp_types_t lsp_type,
|
||||||
@ -1261,7 +1262,8 @@ static struct zebra_nhlfe *nhlfe_find(struct nhlfe_list_head *list,
|
|||||||
static struct zebra_nhlfe *
|
static struct zebra_nhlfe *
|
||||||
nhlfe_alloc(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
|
nhlfe_alloc(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
|
||||||
enum nexthop_types_t gtype, const union g_addr *gate,
|
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 zebra_nhlfe *nhlfe;
|
||||||
struct nexthop *nexthop;
|
struct nexthop *nexthop;
|
||||||
@ -1278,7 +1280,7 @@ nhlfe_alloc(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
|
|||||||
|
|
||||||
nexthop_add_labels(nexthop, lsp_type, num_labels, labels);
|
nexthop_add_labels(nexthop, lsp_type, num_labels, labels);
|
||||||
|
|
||||||
nexthop->vrf_id = VRF_DEFAULT;
|
nexthop->vrf_id = vrf_id;
|
||||||
nexthop->type = gtype;
|
nexthop->type = gtype;
|
||||||
switch (nexthop->type) {
|
switch (nexthop->type) {
|
||||||
case NEXTHOP_TYPE_IPV4:
|
case NEXTHOP_TYPE_IPV4:
|
||||||
@ -1313,12 +1315,11 @@ nhlfe_alloc(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
|
|||||||
* Add primary or backup NHLFE. Base entry must have been created and
|
* Add primary or backup NHLFE. Base entry must have been created and
|
||||||
* duplicate check done.
|
* duplicate check done.
|
||||||
*/
|
*/
|
||||||
static struct zebra_nhlfe *nhlfe_add(struct zebra_lsp *lsp,
|
static struct zebra_nhlfe *
|
||||||
enum lsp_types_t lsp_type,
|
nhlfe_add(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
|
||||||
enum nexthop_types_t gtype,
|
enum nexthop_types_t gtype, const union g_addr *gate,
|
||||||
const union g_addr *gate,
|
ifindex_t ifindex, vrf_id_t vrf_id, uint8_t num_labels,
|
||||||
ifindex_t ifindex, uint8_t num_labels,
|
const mpls_label_t *labels, bool is_backup)
|
||||||
const mpls_label_t *labels, bool is_backup)
|
|
||||||
{
|
{
|
||||||
struct zebra_nhlfe *nhlfe;
|
struct zebra_nhlfe *nhlfe;
|
||||||
|
|
||||||
@ -1326,8 +1327,8 @@ static struct zebra_nhlfe *nhlfe_add(struct zebra_lsp *lsp,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Allocate new object */
|
/* Allocate new object */
|
||||||
nhlfe = nhlfe_alloc(lsp, lsp_type, gtype, gate, ifindex, num_labels,
|
nhlfe = nhlfe_alloc(lsp, lsp_type, gtype, gate, ifindex, vrf_id,
|
||||||
labels);
|
num_labels, labels);
|
||||||
|
|
||||||
if (!nhlfe)
|
if (!nhlfe)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2236,8 +2237,8 @@ zebra_mpls_lsp_add_nhlfe(struct zebra_lsp *lsp, enum lsp_types_t lsp_type,
|
|||||||
const mpls_label_t *out_labels)
|
const mpls_label_t *out_labels)
|
||||||
{
|
{
|
||||||
/* Just a public pass-through to the internal implementation */
|
/* Just a public pass-through to the internal implementation */
|
||||||
return nhlfe_add(lsp, lsp_type, gtype, gate, ifindex, num_labels,
|
return nhlfe_add(lsp, lsp_type, gtype, gate, ifindex, VRF_DEFAULT,
|
||||||
out_labels, false /*backup*/);
|
num_labels, out_labels, false /*backup*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2251,8 +2252,8 @@ struct zebra_nhlfe *zebra_mpls_lsp_add_backup_nhlfe(
|
|||||||
uint8_t num_labels, const mpls_label_t *out_labels)
|
uint8_t num_labels, const mpls_label_t *out_labels)
|
||||||
{
|
{
|
||||||
/* Just a public pass-through to the internal implementation */
|
/* Just a public pass-through to the internal implementation */
|
||||||
return nhlfe_add(lsp, lsp_type, gtype, gate, ifindex, num_labels,
|
return nhlfe_add(lsp, lsp_type, gtype, gate, ifindex, VRF_DEFAULT,
|
||||||
out_labels, true);
|
num_labels, out_labels, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2264,10 +2265,10 @@ struct zebra_nhlfe *zebra_mpls_lsp_add_nh(struct zebra_lsp *lsp,
|
|||||||
{
|
{
|
||||||
struct zebra_nhlfe *nhlfe;
|
struct zebra_nhlfe *nhlfe;
|
||||||
|
|
||||||
nhlfe = nhlfe_add(lsp, lsp_type, nh->type, &nh->gate, nh->ifindex,
|
nhlfe = nhlfe_add(
|
||||||
nh->nh_label ? nh->nh_label->num_labels : 0,
|
lsp, lsp_type, nh->type, &nh->gate, nh->ifindex, nh->vrf_id,
|
||||||
nh->nh_label ? nh->nh_label->label : NULL,
|
nh->nh_label ? nh->nh_label->num_labels : 0,
|
||||||
false /*backup*/);
|
nh->nh_label ? nh->nh_label->label : NULL, false /*backup*/);
|
||||||
|
|
||||||
return nhlfe;
|
return nhlfe;
|
||||||
}
|
}
|
||||||
@ -2283,6 +2284,7 @@ struct zebra_nhlfe *zebra_mpls_lsp_add_backup_nh(struct zebra_lsp *lsp,
|
|||||||
struct zebra_nhlfe *nhlfe;
|
struct zebra_nhlfe *nhlfe;
|
||||||
|
|
||||||
nhlfe = nhlfe_add(lsp, lsp_type, nh->type, &nh->gate, nh->ifindex,
|
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->num_labels : 0,
|
||||||
nh->nh_label ? nh->nh_label->label : NULL, true);
|
nh->nh_label ? nh->nh_label->label : NULL, true);
|
||||||
|
|
||||||
@ -3102,7 +3104,7 @@ static struct zebra_nhlfe *
|
|||||||
lsp_add_nhlfe(struct zebra_lsp *lsp, enum lsp_types_t type,
|
lsp_add_nhlfe(struct zebra_lsp *lsp, enum lsp_types_t type,
|
||||||
uint8_t num_out_labels, const mpls_label_t *out_labels,
|
uint8_t num_out_labels, const mpls_label_t *out_labels,
|
||||||
enum nexthop_types_t gtype, const union g_addr *gate,
|
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;
|
struct zebra_nhlfe *nhlfe;
|
||||||
char buf[MPLS_LABEL_STRLEN];
|
char buf[MPLS_LABEL_STRLEN];
|
||||||
@ -3164,7 +3166,7 @@ lsp_add_nhlfe(struct zebra_lsp *lsp, enum lsp_types_t type,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Add LSP entry to this nexthop */
|
/* 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);
|
num_out_labels, out_labels, is_backup);
|
||||||
if (!nhlfe)
|
if (!nhlfe)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3196,6 +3198,8 @@ lsp_add_nhlfe(struct zebra_lsp *lsp, enum lsp_types_t type,
|
|||||||
/*
|
/*
|
||||||
* Install an LSP and forwarding entry; used primarily
|
* Install an LSP and forwarding entry; used primarily
|
||||||
* from vrf zapi message processing.
|
* 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,
|
int mpls_lsp_install(struct zebra_vrf *zvrf, enum lsp_types_t type,
|
||||||
mpls_label_t in_label, uint8_t num_out_labels,
|
mpls_label_t in_label, uint8_t num_out_labels,
|
||||||
@ -3217,7 +3221,7 @@ int mpls_lsp_install(struct zebra_vrf *zvrf, enum lsp_types_t type,
|
|||||||
lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
|
lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
|
||||||
|
|
||||||
nhlfe = lsp_add_nhlfe(lsp, type, num_out_labels, out_labels, gtype,
|
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)
|
if (nhlfe == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -3236,8 +3240,8 @@ static int lsp_znh_install(struct zebra_lsp *lsp, enum lsp_types_t type,
|
|||||||
{
|
{
|
||||||
struct zebra_nhlfe *nhlfe;
|
struct zebra_nhlfe *nhlfe;
|
||||||
|
|
||||||
nhlfe = lsp_add_nhlfe(lsp, type, znh->label_num, znh->labels,
|
nhlfe = lsp_add_nhlfe(lsp, type, znh->label_num, znh->labels, znh->type,
|
||||||
znh->type, &znh->gate, znh->ifindex,
|
&znh->gate, znh->ifindex, znh->vrf_id,
|
||||||
false /*backup*/);
|
false /*backup*/);
|
||||||
if (nhlfe == NULL)
|
if (nhlfe == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -3274,9 +3278,9 @@ static int lsp_backup_znh_install(struct zebra_lsp *lsp, enum lsp_types_t type,
|
|||||||
{
|
{
|
||||||
struct zebra_nhlfe *nhlfe;
|
struct zebra_nhlfe *nhlfe;
|
||||||
|
|
||||||
nhlfe = lsp_add_nhlfe(lsp, type, znh->label_num,
|
nhlfe = lsp_add_nhlfe(lsp, type, znh->label_num, znh->labels, znh->type,
|
||||||
znh->labels, znh->type, &znh->gate,
|
&znh->gate, znh->ifindex, znh->vrf_id,
|
||||||
znh->ifindex, true /*backup*/);
|
true /*backup*/);
|
||||||
if (nhlfe == NULL) {
|
if (nhlfe == NULL) {
|
||||||
if (IS_ZEBRA_DEBUG_MPLS)
|
if (IS_ZEBRA_DEBUG_MPLS)
|
||||||
zlog_debug("%s: unable to add backup nhlfe, label: %u",
|
zlog_debug("%s: unable to add backup nhlfe, label: %u",
|
||||||
@ -3607,8 +3611,8 @@ int zebra_mpls_static_lsp_add(struct zebra_vrf *zvrf, mpls_label_t in_label,
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Add static LSP entry to this nexthop */
|
/* Add static LSP entry to this nexthop */
|
||||||
nhlfe = nhlfe_add(lsp, ZEBRA_LSP_STATIC, gtype, gate,
|
nhlfe = nhlfe_add(lsp, ZEBRA_LSP_STATIC, gtype, gate, ifindex,
|
||||||
ifindex, 1, &out_label, false /*backup*/);
|
VRF_DEFAULT, 1, &out_label, false /*backup*/);
|
||||||
if (!nhlfe)
|
if (!nhlfe)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user