Skip to content

Commit

Permalink
added methods and options for ipv6 (openconfig#2457)
Browse files Browse the repository at this point in the history
Co-authored-by: arvbaska1 <123760606+arvbaska1@users.noreply.github.com>
  • Loading branch information
2 people authored and frasieroh committed Jan 24, 2024
1 parent 951dcb9 commit 1e4afd2
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions internal/gribi/gribi.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ func NHEntry(nhIndex uint64, address, instance string, expectedResult fluent.Pro
nh = nh.WithIPinIP(opt.Src, opt.Dest).
WithNextHopNetworkInstance(opt.VrfName)
}
case "Encap":
nh = nh.WithEncapsulateHeader(fluent.IPinIP)
for _, opt := range opts {
nh = nh.WithIPinIP(opt.Src, opt.Dest).
WithNextHopNetworkInstance(opt.VrfName)
}
case "VRFOnly":
for _, opt := range opts {
nh = nh.WithNextHopNetworkInstance(opt.VrfName)
Expand Down Expand Up @@ -295,6 +301,29 @@ func (c *Client) AddIPv4(t testing.TB, prefix string, nhgIndex uint64, instance,
)
}

// AddIPv6 adds an IPv6Entry mapping a prefix to a given next hop group index within a given network instance.
func (c *Client) AddIPv6(t testing.TB, prefix string, nhgIndex uint64, instance, nhgInstance string, expectedResult fluent.ProgrammingResult) {
t.Helper()
ipv6Entry := fluent.IPv6Entry().WithPrefix(prefix).
WithNetworkInstance(instance).
WithNextHopGroup(nhgIndex)
if nhgInstance != "" && nhgInstance != instance {
ipv6Entry.WithNextHopGroupNetworkInstance(nhgInstance)
}
c.fluentC.Modify().AddEntry(t, ipv6Entry)
if err := c.AwaitTimeout(context.Background(), t, timeout); err != nil {
t.Fatalf("Error waiting to add IPv6: %v", err)
}
chk.HasResult(t, c.fluentC.Results(t),
fluent.OperationResult().
WithIPv6Operation(prefix).
WithOperationType(constants.Add).
WithProgrammingResult(expectedResult).
AsResult(),
chk.IgnoreOperationID(),
)
}

// DeleteIPv4 deletes an IPv4Entry within a network instance, given the route's prefix
func (c *Client) DeleteIPv4(t testing.TB, prefix string, instance string, expectedResult fluent.ProgrammingResult) {
t.Helper()
Expand All @@ -313,6 +342,24 @@ func (c *Client) DeleteIPv4(t testing.TB, prefix string, instance string, expect
)
}

// DeleteIPv6 deletes an IPv6Entry within a network instance, given the route's prefix
func (c *Client) DeleteIPv6(t testing.TB, prefix string, instance string, expectedResult fluent.ProgrammingResult) {
t.Helper()
ipv6Entry := fluent.IPv6Entry().WithPrefix(prefix).WithNetworkInstance(instance)
c.fluentC.Modify().DeleteEntry(t, ipv6Entry)
if err := c.AwaitTimeout(context.Background(), t, timeout); err != nil {
t.Fatalf("Error waiting to delete IPv6: %v", err)
}
chk.HasResult(t, c.fluentC.Results(t),
fluent.OperationResult().
WithIPv6Operation(prefix).
WithOperationType(constants.Delete).
WithProgrammingResult(expectedResult).
AsResult(),
chk.IgnoreOperationID(),
)
}

// FlushAll flushes all the gribi entries
func (c *Client) FlushAll(t testing.TB) {
if err := FlushAll(c.fluentC); err != nil {
Expand Down

0 comments on commit 1e4afd2

Please sign in to comment.