Skip to content

Commit

Permalink
Merge pull request #6169 from chiragshah6/yang_nb1
Browse files Browse the repository at this point in the history
yang, lib: increase xpath len and add weight in nexthop operational model
  • Loading branch information
Spantik authored Apr 7, 2020
2 parents 660e39e + 247c89b commit 1b18786
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/yang.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
#endif

/* Maximum XPath length. */
#define XPATH_MAXLEN 256
#define XPATH_MAXLEN 512

/* Maximum list key length. */
#define LIST_MAXKEYS 8
Expand Down
47 changes: 31 additions & 16 deletions yang/frr-nexthop.yang
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module frr-nexthop {
}

import frr-vrf {
prefix "frr-vrf";
prefix frr-vrf;
}

organization
Expand All @@ -33,13 +33,12 @@ module frr-nexthop {
}

typedef optional-ip-address {
type union {
type inet:ip-address;
type string {
pattern
'';
}
}
type union {
type inet:ip-address;
type string {
pattern '';
}
}
}

/*
Expand Down Expand Up @@ -148,10 +147,11 @@ module frr-nexthop {
when "../nh-type = 'ip4-ifindex' or
../nh-type = 'ip6-ifindex'";
type boolean;
default false;
default "false";
description
"Nexthop is directly connected.";
}

uses rt-types:mpls-label-stack {
description
"Nexthop's MPLS label stack.";
Expand All @@ -163,29 +163,39 @@ module frr-nexthop {
*/
grouping frr-nexthop-operational {
leaf duplicate {
config false;
type empty;
config false;
description
"Duplicate nexthop";
}

leaf recursive {
config false;
type empty;
config false;
description
"Nexthop resolved through another gateway.";
}

leaf active {
config false;
type empty;
config false;
description
"Nexthop is active.";
}

leaf fib {
config false;
type empty;
config false;
description
"Nexthop is installed in fib.";
}

leaf weight {
type uint8;
config false;
description
"Weight to be used by the nexthop for purposes of ECMP";
}
}

/*
Expand All @@ -199,7 +209,6 @@ module frr-nexthop {
key "nh-type gateway interface";
description
"A list of nexthop objects.";

uses frr-nexthop-attributes;
}
}
Expand Down Expand Up @@ -228,12 +237,18 @@ module frr-nexthop {
container frr-nexthop-group {
description
"A nexthop-group, represented as a list of nexthop objects.";

uses frr-nexthop-grouping;
}

typedef nexthop-group-ref {
type leafref {
require-instance false;
path "/frr-nexthop:frr-nexthop-group/frr-nexthop:nexthop-group/frr-nexthop:name";
}
}

/*
* Agument weight attributes to nexthop group.
* Augment weight attributes to nexthop group.
*/
augment "/frr-nexthop-group/nexthop-group/frr-nexthops/nexthop" {
leaf weight {
Expand Down
6 changes: 6 additions & 0 deletions zebra/zebra_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,12 @@ const struct frr_yang_module_info frr_zebra_info = {
.get_elem = lib_vrf_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_fib_get_elem,
}
},
{
.xpath = "/frr-vrf:lib/vrf/frr-zebra:ribs/rib/route/route-entry/nexthop-group/frr-nexthops/nexthop/weight",
.cbs = {
.get_elem = lib_vrf_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_weight_get_elem,
}
},
{
.xpath = NULL,
},
Expand Down
3 changes: 3 additions & 0 deletions zebra/zebra_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,8 @@ lib_vrf_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_active_get
struct yang_data *
lib_vrf_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_fib_get_elem(
const char *xpath, const void *list_entry);
struct yang_data *
lib_vrf_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_weight_get_elem(
const char *xpath, const void *list_entry);

#endif
12 changes: 12 additions & 0 deletions zebra/zebra_nb_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,15 @@ lib_vrf_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_fib_get_el
/* TODO: implement me. */
return NULL;
}

/*
* XPath:
* /frr-vrf:lib/vrf/frr-zebra:ribs/rib/route/route-entry/nexthop-group/frr-nexthops/nexthop/weight
*/
struct yang_data *
lib_vrf_ribs_rib_route_route_entry_nexthop_group_frr_nexthops_nexthop_weight_get_elem(
const char *xpath, const void *list_entry)
{
/* TODO: implement me. */
return NULL;
}

0 comments on commit 1b18786

Please sign in to comment.