mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-05 20:51:17 +00:00
lib, zebra: Allow for encode/decode of nexthop weight in pass down
Add code to encode/decode the nexthop weight when we pass it down into zebra. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
df7fb5800b
commit
bd054c1aa2
@ -118,6 +118,12 @@ static int _nexthop_cmp_no_labels(const struct nexthop *next1,
|
||||
if (next1->type > next2->type)
|
||||
return 1;
|
||||
|
||||
if (next1->weight < next2->weight)
|
||||
return -1;
|
||||
|
||||
if (next1->weight > next2->weight)
|
||||
return 1;
|
||||
|
||||
switch (next1->type) {
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
|
@ -802,6 +802,12 @@ static int zapi_nexthop_cmp_no_labels(const struct zapi_nexthop *next1,
|
||||
if (next1->type > next2->type)
|
||||
return 1;
|
||||
|
||||
if (next1->weight < next2->weight)
|
||||
return -1;
|
||||
|
||||
if (next1->weight > next2->weight)
|
||||
return 1;
|
||||
|
||||
switch (next1->type) {
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
case NEXTHOP_TYPE_IPV6:
|
||||
@ -882,6 +888,9 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
|
||||
}
|
||||
}
|
||||
|
||||
if (api_nh->weight)
|
||||
SET_FLAG(nh_flags, ZAPI_NEXTHOP_FLAG_WEIGHT);
|
||||
|
||||
/* Note that we're only encoding a single octet */
|
||||
stream_putc(s, nh_flags);
|
||||
|
||||
@ -920,6 +929,9 @@ int zapi_nexthop_encode(struct stream *s, const struct zapi_nexthop *api_nh,
|
||||
api_nh->label_num * sizeof(mpls_label_t));
|
||||
}
|
||||
|
||||
if (api_nh->weight)
|
||||
stream_putl(s, api_nh->weight);
|
||||
|
||||
/* Router MAC for EVPN routes. */
|
||||
if (CHECK_FLAG(api_flags, ZEBRA_FLAG_EVPN_ROUTE))
|
||||
stream_put(s, &(api_nh->rmac),
|
||||
@ -1082,6 +1094,9 @@ static int zapi_nexthop_decode(struct stream *s, struct zapi_nexthop *api_nh,
|
||||
api_nh->label_num * sizeof(mpls_label_t));
|
||||
}
|
||||
|
||||
if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_WEIGHT))
|
||||
STREAM_GETL(s, api_nh->weight);
|
||||
|
||||
/* Router MAC for EVPN routes. */
|
||||
if (CHECK_FLAG(api_flags, ZEBRA_FLAG_EVPN_ROUTE))
|
||||
STREAM_GET(&(api_nh->rmac), s,
|
||||
|
@ -323,6 +323,8 @@ struct zapi_nexthop {
|
||||
mpls_label_t labels[MPLS_MAX_LABELS];
|
||||
|
||||
struct ethaddr rmac;
|
||||
|
||||
uint32_t weight;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -330,6 +332,7 @@ struct zapi_nexthop {
|
||||
*/
|
||||
#define ZAPI_NEXTHOP_FLAG_ONLINK 0x01
|
||||
#define ZAPI_NEXTHOP_FLAG_LABEL 0x02
|
||||
#define ZAPI_NEXTHOP_FLAG_WEIGHT 0x04
|
||||
|
||||
/*
|
||||
* Some of these data structures do not map easily to
|
||||
|
@ -279,6 +279,7 @@ static void route_add_helper(struct zapi_route *api, struct nexthop_group nhg,
|
||||
api_nh = &api->nexthops[i];
|
||||
api_nh->vrf_id = nhop->vrf_id;
|
||||
api_nh->type = nhop->type;
|
||||
api_nh->weight = nhop->weight;
|
||||
switch (nhop->type) {
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
api_nh->gate.ipv4 = nhop->gate.ipv4;
|
||||
|
@ -243,6 +243,8 @@ void route_add(struct prefix *p, vrf_id_t vrf_id,
|
||||
api_nh = &api.nexthops[i];
|
||||
api_nh->vrf_id = nh->vrf_id;
|
||||
api_nh->type = nh->type;
|
||||
api_nh->weight = nh->weight;
|
||||
|
||||
switch (nh->type) {
|
||||
case NEXTHOP_TYPE_IPV4:
|
||||
api_nh->gate = nh->gate;
|
||||
|
@ -567,6 +567,7 @@ int zsend_redistribute_route(int cmd, struct zserv *client,
|
||||
api_nh = &api.nexthops[count];
|
||||
api_nh->vrf_id = nexthop->vrf_id;
|
||||
api_nh->type = nexthop->type;
|
||||
api_nh->weight = nexthop->weight;
|
||||
switch (nexthop->type) {
|
||||
case NEXTHOP_TYPE_BLACKHOLE:
|
||||
api_nh->bh_type = nexthop->bh_type;
|
||||
@ -1544,6 +1545,9 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
|
||||
if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_ONLINK))
|
||||
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK);
|
||||
|
||||
if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_WEIGHT))
|
||||
nexthop->weight = api_nh->weight;
|
||||
|
||||
/* MPLS labels for BGP-LU or Segment Routing */
|
||||
if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_LABEL)
|
||||
&& api_nh->type != NEXTHOP_TYPE_IFINDEX
|
||||
|
@ -380,6 +380,9 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
|
||||
sizeof buf, 1));
|
||||
}
|
||||
|
||||
if (nexthop->weight)
|
||||
vty_out(vty, ", weight %u", nexthop->weight);
|
||||
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
vty_out(vty, "\n");
|
||||
@ -1240,6 +1243,9 @@ static void show_nexthop_group_out(struct vty *vty, struct nhg_hash_entry *nhe)
|
||||
sizeof(buf), 1));
|
||||
}
|
||||
|
||||
if (nexthop->weight)
|
||||
vty_out(vty, ", weight %u", nexthop->weight);
|
||||
|
||||
vty_out(vty, "\n");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user