Skip to content

Commit

Permalink
qfix: Dont exclude subnets from routes (#1368)
Browse files Browse the repository at this point in the history
* dont exclude subnets from routes

Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>

* fix linter

Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>

Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
  • Loading branch information
denis-tingaikin authored Oct 12, 2022
1 parent 6c3f844 commit d4d43ae
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/networkservice/common/excludedprefixes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ func (epc *excludedPrefixesClient) Close(ctx context.Context, conn *networkservi
func getRoutePrefixes(routes []*networkservice.Route) []string {
var rv []string
for _, route := range routes {
var o, b = route.GetPrefixIPNet().Mask.Size()
if o != b {
continue
}
rv = append(rv, route.GetPrefix())
}

Expand Down
47 changes: 47 additions & 0 deletions pkg/networkservice/common/excludedprefixes/client_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2022 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -488,6 +490,51 @@ func TestExcludedPrefixesClient_Request_EndpointConflictCloseError(t *testing.T)
require.Contains(t, err.Error(), "connection closed")
}

func Test_ExcludePrefixClient_ShouldntExcludeRouteSubnets(t *testing.T) {
client := chain.NewNetworkServiceClient(
excludedprefixes.NewClient(),
)

var req = &networkservice.NetworkServiceRequest{
Connection: &networkservice.Connection{
Context: &networkservice.ConnectionContext{
IpContext: &networkservice.IPContext{
SrcRoutes: []*networkservice.Route{
{
Prefix: "172.16.1.0/32",
},
{
Prefix: "172.16.1.0/24",
},
{
Prefix: "fe80::/128",
},
{
Prefix: "fe80::/32",
},
},
},
},
},
}

_, err := client.Request(context.Background(), req)
require.NoError(t, err)

// Refresh
client = chain.NewNetworkServiceClient(
client,
checkrequest.NewClient(t, func(t *testing.T, request *networkservice.NetworkServiceRequest) {
require.Equal(t, []string{"172.16.1.0/32", "fe80::/128"}, request.Connection.Context.IpContext.ExcludedPrefixes)
}),
)

// refresh
_, err = client.Request(context.Background(), req)

require.NoError(t, err)
}

func TestClient(t *testing.T) {
reqPrefixes := []string{"100.1.1.0/13", "10.32.0.0/12", "10.96.0.0/12"}

Expand Down

0 comments on commit d4d43ae

Please sign in to comment.