forked from Mirror/frr
*: Add ability to encode / decode resilence down zapi
At this point add abilty for the encode/decode of the resilience down ZAPI to zebra. Just hookup sharpd at this point in time. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
f3c6dd49f4
commit
ca2b346783
|
@ -1166,6 +1166,10 @@ static int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
|
||||||
stream_putw(s, api_nhg->proto);
|
stream_putw(s, api_nhg->proto);
|
||||||
stream_putl(s, api_nhg->id);
|
stream_putl(s, api_nhg->id);
|
||||||
|
|
||||||
|
stream_putw(s, api_nhg->resilience.buckets);
|
||||||
|
stream_putl(s, api_nhg->resilience.idle_timer);
|
||||||
|
stream_putl(s, api_nhg->resilience.unbalanced_timer);
|
||||||
|
|
||||||
if (cmd == ZEBRA_NHG_ADD) {
|
if (cmd == ZEBRA_NHG_ADD) {
|
||||||
/* Nexthops */
|
/* Nexthops */
|
||||||
zapi_nexthop_group_sort(api_nhg->nexthops,
|
zapi_nexthop_group_sort(api_nhg->nexthops,
|
||||||
|
|
|
@ -35,6 +35,8 @@ struct zclient;
|
||||||
|
|
||||||
/* For union g_addr */
|
/* For union g_addr */
|
||||||
#include "nexthop.h"
|
#include "nexthop.h"
|
||||||
|
/* For resilience */
|
||||||
|
#include "nexthop_group.h"
|
||||||
|
|
||||||
/* For union pw_protocol_fields */
|
/* For union pw_protocol_fields */
|
||||||
#include "pw.h"
|
#include "pw.h"
|
||||||
|
@ -463,6 +465,8 @@ struct zapi_nhg {
|
||||||
uint16_t proto;
|
uint16_t proto;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
|
struct nhg_resilience resilience;
|
||||||
|
|
||||||
uint16_t nexthop_num;
|
uint16_t nexthop_num;
|
||||||
struct zapi_nexthop nexthops[MULTIPATH_NUM];
|
struct zapi_nexthop nexthops[MULTIPATH_NUM];
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,20 @@ static void sharp_nhgroup_add_cb(const char *name)
|
||||||
|
|
||||||
static void sharp_nhgroup_modify_cb(const struct nexthop_group_cmd *nhgc)
|
static void sharp_nhgroup_modify_cb(const struct nexthop_group_cmd *nhgc)
|
||||||
{
|
{
|
||||||
|
struct sharp_nhg lookup;
|
||||||
|
struct sharp_nhg *snhg;
|
||||||
|
struct nexthop_group_cmd *bnhgc = NULL;
|
||||||
|
|
||||||
|
strlcpy(lookup.name, nhgc->name, sizeof(lookup.name));
|
||||||
|
snhg = sharp_nhg_rb_find(&nhg_head, &lookup);
|
||||||
|
|
||||||
|
if (!nhgc->nhg.nexthop)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (nhgc->backup_list_name[0])
|
||||||
|
bnhgc = nhgc_find(nhgc->backup_list_name);
|
||||||
|
|
||||||
|
nhg_add(snhg->id, &nhgc->nhg, (bnhgc ? &bnhgc->nhg : NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sharp_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc,
|
static void sharp_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhgc,
|
||||||
|
|
|
@ -550,6 +550,9 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
||||||
bool is_valid = true;
|
bool is_valid = true;
|
||||||
|
|
||||||
api_nhg.id = id;
|
api_nhg.id = id;
|
||||||
|
|
||||||
|
api_nhg.resilience = nhg->nhgr;
|
||||||
|
|
||||||
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
|
for (ALL_NEXTHOPS_PTR(nhg, nh)) {
|
||||||
if (api_nhg.nexthop_num >= MULTIPATH_NUM) {
|
if (api_nhg.nexthop_num >= MULTIPATH_NUM) {
|
||||||
zlog_warn(
|
zlog_warn(
|
||||||
|
|
|
@ -1874,6 +1874,10 @@ static int zapi_nhg_decode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
|
||||||
if (cmd == ZEBRA_NHG_DEL)
|
if (cmd == ZEBRA_NHG_DEL)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
STREAM_GETW(s, api_nhg->resilience.buckets);
|
||||||
|
STREAM_GETL(s, api_nhg->resilience.idle_timer);
|
||||||
|
STREAM_GETL(s, api_nhg->resilience.unbalanced_timer);
|
||||||
|
|
||||||
/* Nexthops */
|
/* Nexthops */
|
||||||
STREAM_GETW(s, api_nhg->nexthop_num);
|
STREAM_GETW(s, api_nhg->nexthop_num);
|
||||||
|
|
||||||
|
@ -1998,6 +2002,8 @@ static void zread_nhg_add(ZAPI_HANDLER_ARGS)
|
||||||
nhe->nhg.nexthop = nhg->nexthop;
|
nhe->nhg.nexthop = nhg->nexthop;
|
||||||
nhg->nexthop = NULL;
|
nhg->nexthop = NULL;
|
||||||
|
|
||||||
|
nhe->nhg.nhgr = api_nhg.resilience;
|
||||||
|
|
||||||
if (bnhg) {
|
if (bnhg) {
|
||||||
nhe->backup_info = bnhg;
|
nhe->backup_info = bnhg;
|
||||||
bnhg = NULL;
|
bnhg = NULL;
|
||||||
|
|
|
@ -3367,6 +3367,7 @@ struct nhg_hash_entry *zebra_nhg_proto_add(uint32_t id, int type,
|
||||||
|
|
||||||
zebra_nhe_init(&lookup, afi, nhg->nexthop);
|
zebra_nhe_init(&lookup, afi, nhg->nexthop);
|
||||||
lookup.nhg.nexthop = nhg->nexthop;
|
lookup.nhg.nexthop = nhg->nexthop;
|
||||||
|
lookup.nhg.nhgr = nhg->nhgr;
|
||||||
lookup.id = id;
|
lookup.id = id;
|
||||||
lookup.type = type;
|
lookup.type = type;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue