Skip to content

Commit

Permalink
Connecting a remote interface without creating a VLAN on top
Browse files Browse the repository at this point in the history
Fix issue: cmd-nse-remote-vlan/18
Related PR: sdk-vpp/546

Skip setting ACLs.

Signed-off-by: Laszlo Kiraly <laszlo.kiraly@est.tech>
  • Loading branch information
ljkiraly committed Apr 12, 2022
1 parent 91c39bb commit 2992b5c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
26 changes: 8 additions & 18 deletions internal/vppinit/links.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 @@ -48,9 +48,9 @@ func InitLinks(ctx context.Context, vppConn api.Connection, deviceNames map[stri
}

if !isTunnelLink(link, tunnelIP) {
err = createInterface(ctx, vppConn, link)
err = setupLinkVpp(ctx, vppConn, link)
if err != nil {
return errors.Errorf("error creating AF_PACKET for %s", device)
return errors.Wrapf(err, "error setting up device %s", device)
}
}
setPromiscHw(ctx, link)
Expand All @@ -71,33 +71,23 @@ func isTunnelLink(link netlink.Link, tunnelIP net.IP) bool {
return false
}

func createInterface(ctx context.Context, vppConn api.Connection, link netlink.Link) error {
now := time.Now()
func setupLinkVpp(ctx context.Context, vppConn api.Connection, link netlink.Link) error {
swIfIndex, err := createAfPacket(ctx, vppConn, link)
if err != nil {
return err
}
log.FromContext(ctx).
WithField("duration", time.Since(now)).
WithField("SwIfIndex", swIfIndex).
WithField("vppapi", "CreateAfPacket").Debug("completed")

now = time.Now()
if aclErr := denyAllACLToInterface(ctx, vppConn, swIfIndex); aclErr != nil {
return aclErr
if mtuErr := setMtu(ctx, vppConn, link, swIfIndex); err != nil {
return mtuErr
}
log.FromContext(ctx).
WithField("duration", time.Since(now)).
WithField("SwIfIndex", swIfIndex).
WithField("vppapi", "DenyAllACLToInterface").Debug("completed")

now = time.Now()
now := time.Now()
_, err = interfaces.NewServiceClient(vppConn).SwInterfaceSetFlags(ctx, &interfaces.SwInterfaceSetFlags{
SwIfIndex: swIfIndex,
Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP,
})
if err != nil {
return err
return errors.Wrap(err, "unable to set interface amdin UP")
}
log.FromContext(ctx).
WithField("swIfIndex", swIfIndex).
Expand Down
7 changes: 4 additions & 3 deletions internal/vppinit/vppinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func LinkToAfPacket(ctx context.Context, vppConn api.Connection, tunnelIP net.IP
return nil, err
}

if mtuErr := setMtu(ctx, vppConn, link, swIfIndex); err != nil {
return nil, mtuErr
}

if aclErr := denyAllACLToInterface(ctx, vppConn, swIfIndex); aclErr != nil {
return nil, aclErr
}
Expand Down Expand Up @@ -209,9 +213,6 @@ func createAfPacket(ctx context.Context, vppConn api.Connection, link netlink.Li
WithField("duration", time.Since(now)).
WithField("vppapi", "AfPacketCreate").Debug("completed")

if err := setMtu(ctx, vppConn, link, afPacketCreateRsp.SwIfIndex); err != nil {
return 0, err
}
return afPacketCreateRsp.SwIfIndex, nil
}

Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ func main() {
}

deviceMap := setupDeviceMap(ctx, cfg)
_ = vppinit.InitLinks(ctx, vppConn, deviceMap, cfg.TunnelIP)
err = vppinit.InitLinks(ctx, vppConn, deviceMap, cfg.TunnelIP)
if err != nil {
log.FromContext(ctx).Warnf("Link init failed %+v", err)
}

// ********************************************************************************
log.FromContext(ctx).Infof("executing phase 6: retrieving svid, check spire agent logs if this is the last line you see (time since start: %s)", time.Since(starttime))
Expand Down

0 comments on commit 2992b5c

Please sign in to comment.