Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 committed Jan 11, 2024
1 parent 8abe2aa commit 01b89ac
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
15 changes: 10 additions & 5 deletions dataplane/dplaneopts/dplaneopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ import fwdpb "github.com/openconfig/lemming/proto/forwarding"

// Options configures the dataplane
type Options struct {
Addr string
Reconcilation bool
// Addr is the address of the gRPC server.
Addr string
// Reconcilation enabes gNMI reconcilation.
Reconcilation bool
// HostifNetDevType is the fwdpb type for the saipb hostif netdev types.
HostifNetDevType fwdpb.PortType
PortType fwdpb.PortType
// PortType is the fwdpb type for the port type.
PortType fwdpb.PortType
}

// Option exposes additional configuration for the dataplane.
type Option func(*Options)

// WithAddress sets the address of the dataplane gRPC server
// WithAddrPort sets the address of the dataplane gRPC server
// Default: 127.0.0.1:0
func WithAddress(addr string) Option {
func WithAddrPort(addr string) Option {
return func(o *Options) {
o.Addr = addr
}
Expand Down
2 changes: 2 additions & 0 deletions dataplane/forwarding/infra/fwdcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ type PacketCallback func(*fwdpb.PacketSinkResponse) error
// An NotificationCallback generates events to a notification service.
type NotificationCallback func(*fwdpb.EventDesc)

// Port is an interface for reading and writing to a port.
type Port interface {
gopacket.PacketDataSource
WritePacketData(data []byte) error
}

// FakePortManager is an interface for creating custom ports for fwdpb FakePort.
type FakePortManager interface {
CreatePort(string) (Port, error)
}
Expand Down
8 changes: 8 additions & 0 deletions dataplane/internal/kernel/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (k *Interfaces) NeighSubscribe(ch chan<- netlink.NeighUpdate, done <-chan s
return netlink.NeighSubscribe(ch, done)
}

// LinkList lists all Linux network interfaces.
func (k *Interfaces) LinkList() ([]netlink.Link, error) {
links, err := netlink.LinkList()
if err != nil {
Expand All @@ -148,30 +149,37 @@ func (k *Interfaces) LinkList() ([]netlink.Link, error) {
return links, err
}

// LinkAdd adds a new network interface.
func (k *Interfaces) LinkAdd(link netlink.Link) error {
return netlink.LinkAdd(link)
}

// LinkByIndex finds a link by its index.
func (k *Interfaces) LinkByIndex(idx int) (netlink.Link, error) {
return netlink.LinkByIndex(idx)
}

// LinkSetDown sets the admin state to down.
func (k *Interfaces) LinkSetDown(link netlink.Link) error {
return netlink.LinkSetDown(link)
}

// LinkSetDown sets the admin state to up.
func (k *Interfaces) LinkSetUp(link netlink.Link) error {
return netlink.LinkSetUp(link)
}

// LinkSetMaster sets the member link's master to the other link.
func (k *Interfaces) LinkSetMaster(member netlink.Link, link netlink.Link) error {
return netlink.LinkSetMaster(member, link)
}

// LinkSetNoMaster removes the master from the link.
func (k *Interfaces) LinkSetNoMaster(link netlink.Link) error {
return netlink.LinkSetNoMaster(link)
}

// LinkModify modifies the link.
func (k *Interfaces) LinkModify(link netlink.Link) error {
return netlink.LinkModify(link)
}
15 changes: 15 additions & 0 deletions integration_tests/dataplane/basictraffic/basic_traffic_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// TODO: Fill this in with a real test
package basictraffic

import (
Expand Down
7 changes: 4 additions & 3 deletions internal/binding/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
fwdpb "github.com/openconfig/lemming/proto/forwarding"
)

// LocalBind is an Ondatra binding for in-process testbed. Only Lemming and Magna are supported.
type LocalBind struct {
binding.Binding
}
Expand All @@ -62,9 +63,9 @@ type localLemming struct {

const (
gnmiPort = 9339
gribiPort = 9559
gribiPort = 9340
bgpPort = 1179
dataplanePort = 9999
dataplanePort = 50000
)

// Reserve creates a new local binding.
Expand Down Expand Up @@ -93,7 +94,7 @@ func (lb *LocalBind) Reserve(ctx context.Context, tb *opb.Testbed, _, _ time.Dur
lemming.WithTransportCreds(local.NewCredentials()),
lemming.WithDataplane(true),
lemming.WithDataplaneOpts(
dplaneopts.WithAddress(net.JoinHostPort(addr, fmt.Sprint(dataplanePort))),
dplaneopts.WithAddrPort(net.JoinHostPort(addr, fmt.Sprint(dataplanePort))),
dplaneopts.WithReconcilation(false),
dplaneopts.WithPortType(fwdpb.PortType_PORT_TYPE_FAKE),
),
Expand Down

0 comments on commit 01b89ac

Please sign in to comment.