mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-30 18:05:56 +00:00
lib,sharpd: add ability for sharpd to install vni labels
Add the ability for sharpd to install vni labels for testing. This patch is just for testing/dev work purposes with evpn. It adds some code to vty for nexthop-groups so we can explicitly add a label to nexthops and then let sharpd encode them to zebra. Signed-off-by: Stephen Worley <sworley@nvidia.com>
This commit is contained in:
parent
5fa6bfffb1
commit
90aaed169f
@ -41,6 +41,7 @@ struct nexthop_hold {
|
|||||||
char *intf;
|
char *intf;
|
||||||
bool onlink;
|
bool onlink;
|
||||||
char *labels;
|
char *labels;
|
||||||
|
vni_t vni;
|
||||||
uint32_t weight;
|
uint32_t weight;
|
||||||
char *backup_str;
|
char *backup_str;
|
||||||
};
|
};
|
||||||
@ -803,12 +804,13 @@ static bool nexthop_group_parse_nexthop(struct nexthop *nhop,
|
|||||||
const union sockunion *addr,
|
const union sockunion *addr,
|
||||||
const char *intf, bool onlink,
|
const char *intf, bool onlink,
|
||||||
const char *name, const char *labels,
|
const char *name, const char *labels,
|
||||||
int *lbl_ret, uint32_t weight,
|
vni_t vni, int *lbl_ret,
|
||||||
const char *backup_str)
|
uint32_t weight, const char *backup_str)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
int num;
|
int num;
|
||||||
|
uint8_t labelnum = 0;
|
||||||
|
|
||||||
memset(nhop, 0, sizeof(*nhop));
|
memset(nhop, 0, sizeof(*nhop));
|
||||||
|
|
||||||
@ -849,10 +851,9 @@ static bool nexthop_group_parse_nexthop(struct nexthop *nhop,
|
|||||||
nhop->type = NEXTHOP_TYPE_IFINDEX;
|
nhop->type = NEXTHOP_TYPE_IFINDEX;
|
||||||
|
|
||||||
if (labels) {
|
if (labels) {
|
||||||
uint8_t num = 0;
|
|
||||||
mpls_label_t larray[MPLS_MAX_LABELS];
|
mpls_label_t larray[MPLS_MAX_LABELS];
|
||||||
|
|
||||||
ret = mpls_str2label(labels, &num, larray);
|
ret = mpls_str2label(labels, &labelnum, larray);
|
||||||
|
|
||||||
/* Return label parse result */
|
/* Return label parse result */
|
||||||
if (lbl_ret)
|
if (lbl_ret)
|
||||||
@ -860,9 +861,14 @@ static bool nexthop_group_parse_nexthop(struct nexthop *nhop,
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return false;
|
return false;
|
||||||
else if (num > 0)
|
else if (labelnum > 0)
|
||||||
nexthop_add_labels(nhop, ZEBRA_LSP_NONE,
|
nexthop_add_labels(nhop, ZEBRA_LSP_NONE, labelnum,
|
||||||
num, larray);
|
larray);
|
||||||
|
} else if (vni) {
|
||||||
|
mpls_label_t label = MPLS_INVALID_LABEL;
|
||||||
|
|
||||||
|
vni2label(vni, &label);
|
||||||
|
nexthop_add_labels(nhop, ZEBRA_LSP_EVPN, 1, &label);
|
||||||
}
|
}
|
||||||
|
|
||||||
nhop->weight = weight;
|
nhop->weight = weight;
|
||||||
@ -889,7 +895,7 @@ static bool nexthop_group_parse_nhh(struct nexthop *nhop,
|
|||||||
{
|
{
|
||||||
return (nexthop_group_parse_nexthop(
|
return (nexthop_group_parse_nexthop(
|
||||||
nhop, nhh->addr, nhh->intf, nhh->onlink, nhh->nhvrf_name,
|
nhop, nhh->addr, nhh->intf, nhh->onlink, nhh->nhvrf_name,
|
||||||
nhh->labels, NULL, nhh->weight, nhh->backup_str));
|
nhh->labels, nhh->vni, NULL, nhh->weight, nhh->backup_str));
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
|
DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
|
||||||
@ -901,6 +907,7 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
|
|||||||
[{ \
|
[{ \
|
||||||
nexthop-vrf NAME$vrf_name \
|
nexthop-vrf NAME$vrf_name \
|
||||||
|label WORD \
|
|label WORD \
|
||||||
|
|vni (1-16777215) \
|
||||||
|weight (1-255) \
|
|weight (1-255) \
|
||||||
|backup-idx WORD \
|
|backup-idx WORD \
|
||||||
}]",
|
}]",
|
||||||
@ -915,6 +922,8 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
|
|||||||
"The nexthop-vrf Name\n"
|
"The nexthop-vrf Name\n"
|
||||||
"Specify label(s) for this nexthop\n"
|
"Specify label(s) for this nexthop\n"
|
||||||
"One or more labels in the range (16-1048575) separated by '/'\n"
|
"One or more labels in the range (16-1048575) separated by '/'\n"
|
||||||
|
"Specify VNI(s) for this nexthop\n"
|
||||||
|
"VNI in the range (1-16777215)\n"
|
||||||
"Weight to be used by the nexthop for purposes of ECMP\n"
|
"Weight to be used by the nexthop for purposes of ECMP\n"
|
||||||
"Weight value to be used\n"
|
"Weight value to be used\n"
|
||||||
"Specify backup nexthop indexes in another group\n"
|
"Specify backup nexthop indexes in another group\n"
|
||||||
@ -939,8 +948,8 @@ DEFPY(ecmp_nexthops, ecmp_nexthops_cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
legal = nexthop_group_parse_nexthop(&nhop, addr, intf, !!onlink,
|
legal = nexthop_group_parse_nexthop(&nhop, addr, intf, !!onlink,
|
||||||
vrf_name, label, &lbl_ret, weight,
|
vrf_name, label, vni, &lbl_ret,
|
||||||
backup_idx);
|
weight, backup_idx);
|
||||||
|
|
||||||
if (nhop.type == NEXTHOP_TYPE_IPV6
|
if (nhop.type == NEXTHOP_TYPE_IPV6
|
||||||
&& IN6_IS_ADDR_LINKLOCAL(&nhop.gate.ipv6)) {
|
&& IN6_IS_ADDR_LINKLOCAL(&nhop.gate.ipv6)) {
|
||||||
@ -1166,6 +1175,9 @@ static void nexthop_group_write_nexthop_internal(struct vty *vty,
|
|||||||
if (nh->labels)
|
if (nh->labels)
|
||||||
vty_out(vty, " label %s", nh->labels);
|
vty_out(vty, " label %s", nh->labels);
|
||||||
|
|
||||||
|
if (nh->vni)
|
||||||
|
vty_out(vty, " vni %u", nh->vni);
|
||||||
|
|
||||||
if (nh->weight)
|
if (nh->weight)
|
||||||
vty_out(vty, " weight %u", nh->weight);
|
vty_out(vty, " weight %u", nh->weight);
|
||||||
|
|
||||||
|
@ -271,6 +271,11 @@ static bool route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance,
|
|||||||
api.nhgid = nhgid;
|
api.nhgid = nhgid;
|
||||||
} else {
|
} else {
|
||||||
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
|
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
|
||||||
|
/* Check if we set a VNI label */
|
||||||
|
if (nh->nh_label
|
||||||
|
&& (nh->nh_label_type == ZEBRA_LSP_EVPN))
|
||||||
|
SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE);
|
||||||
|
|
||||||
api_nh = &api.nexthops[i];
|
api_nh = &api.nexthops[i];
|
||||||
|
|
||||||
zapi_nexthop_from_nexthop(api_nh, nh);
|
zapi_nexthop_from_nexthop(api_nh, nh);
|
||||||
|
Loading…
Reference in New Issue
Block a user