Skip to content

Commit

Permalink
Fix SwInterfaceDump filtering for interface name in case of remote vl…
Browse files Browse the repository at this point in the history
…an mechanism (networkservicemesh#494)

Signed-off-by: Laszlo Kiraly <[email protected]>
  • Loading branch information
ljkiraly committed Jan 24, 2022
1 parent 8726a58 commit 9d2479f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pkg/networkservice/mechanisms/vlan/common.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 Nordix Foundation.
// Copyright (c) 2021-2022 Nordix Foundation.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -33,6 +33,10 @@ import (
"github.com/networkservicemesh/sdk-vpp/pkg/tools/ifindex"
)

const (
afPacketNamePrefix = "host-"
)

func addSubIf(ctx context.Context, conn *networkservice.Connection, vppConn api.Connection, deviceNames map[string]string) error {
if mechanism := vlanmech.ToMechanism(conn.GetMechanism()); mechanism != nil {
_, ok := ifindex.Load(ctx, true)
Expand All @@ -43,7 +47,7 @@ func addSubIf(ctx context.Context, conn *networkservice.Connection, vppConn api.
via := conn.GetLabels()[viaLabel]
hostIFName, ok := deviceNames[via]
if !ok {
return errors.Errorf("no interface name for service domain %s", via)
return errors.Errorf("no interface name for label %s", via)
}

client, err := interfaces.NewServiceClient(vppConn).SwInterfaceDump(ctx, &interfaces.SwInterfaceDump{
Expand All @@ -66,6 +70,13 @@ func addSubIf(ctx context.Context, conn *networkservice.Connection, vppConn api.
if err != nil {
return errors.Wrapf(err, "error attempting to get interface details to set vlan subinterface on %q", hostIFName)
}

if (hostIFName != details.InterfaceName) && (afPacketNamePrefix+hostIFName != details.InterfaceName) {
log.FromContext(ctx).
WithField("InterfaceName", details.InterfaceName).
WithField("vppapi", "SwInterfaceDetails").Debug("skipped")
continue
}
now = time.Now()
swIfIndex := details.SwIfIndex
vlanID := mechanism.GetVlanID()
Expand All @@ -85,7 +96,9 @@ func addSubIf(ctx context.Context, conn *networkservice.Connection, vppConn api.
WithField("vppapi", "CreateVlanSubIf").Debug("completed")

ifindex.Store(ctx, true, rsp.SwIfIndex)
return nil
}
return errors.Errorf("no interface name found %s", hostIFName)
}
return nil
}
Expand Down

0 comments on commit 9d2479f

Please sign in to comment.