Skip to content

Commit

Permalink
fix for lemming
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 committed Jan 10, 2025
1 parent 49df8a3 commit 2332625
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dataplane/dplanerc/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ func (ni *Reconciler) setupPorts(ctx context.Context) error {
Type: saipb.HostifType_HOSTIF_TYPE_NETDEV.Enum(),
ObjId: &portResp.Oid,
Name: []byte(hostifName),
OperStatus: proto.Bool(true),
OperStatus: proto.Bool(false),
})
if err != nil {
return fmt.Errorf("failed to create host interface %q: %w", hostifName, err)
Expand Down
20 changes: 15 additions & 5 deletions dataplane/saiserver/hostif.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"

"github.com/openconfig/lemming/dataplane/dplaneopts"
"github.com/openconfig/lemming/dataplane/forwarding/fwdconfig"
Expand Down Expand Up @@ -169,14 +168,12 @@ func (hostif *hostif) CreateHostif(ctx context.Context, req *saipb.CreateHostifR
if err := hostif.remotePortReq(ctlReq); err != nil {
return nil, err
}
slog.Info("hostif created", "oid", id)
if err := hostif.remotePortReq(operReq); err != nil {
return nil, err
}

attr := &saipb.HostifAttribute{
OperStatus: proto.Bool(true),
}
hostif.mgr.StoreAttributes(id, attr)
slog.Info("hostif status set", "oid", id, "op", operStatus)
hostif.remoteHostifs[id] = ctlReq

return &saipb.CreateHostifResponse{Oid: id}, nil
Expand Down Expand Up @@ -226,6 +223,19 @@ func (hostif *hostif) RemoveHostif(ctx context.Context, req *saipb.RemoveHostifR

// SetHostifAttribute sets the attributes in the request.
func (hostif *hostif) SetHostifAttribute(ctx context.Context, req *saipb.SetHostifAttributeRequest) (*saipb.SetHostifAttributeResponse, error) {
if req.OperStatus != nil {
op := pktiopb.PortOperation_PORT_OPERATION_SET_DOWN

if req.GetOperStatus() {
op = pktiopb.PortOperation_PORT_OPERATION_SET_UP
}
if err := hostif.remotePortReq(&pktiopb.HostPortControlMessage{
PortId: req.GetOid(),
Op: op,
}); err != nil {
return nil, err
}
}
return nil, nil
}

Expand Down
8 changes: 4 additions & 4 deletions dataplane/standalone/pkthandler/pktiohandler/pktiohandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (m *PacketIOMgr) ManagePorts(c pktiopb.PacketIO_HostPortControlClient) erro
return err
}
log.Infof("received port control message: %+v", resp)
switch {
case (resp.Op == pktiopb.PortOperation_PORT_OPERATION_UNSPECIFIED && resp.Create) || resp.Op == pktiopb.PortOperation_PORT_OPERATION_CREATE:
switch resp.Op {
case pktiopb.PortOperation_PORT_OPERATION_CREATE:
st := &status.Status{
Code: int32(codes.OK),
}
Expand All @@ -181,7 +181,7 @@ func (m *PacketIOMgr) ManagePorts(c pktiopb.PacketIO_HostPortControlClient) erro
if err := m.writePorts(); err != nil {
log.Warningf("failed to write file: %v", err)
}
case resp.Op == pktiopb.PortOperation_PORT_OPERATION_UNSPECIFIED || resp.Op == pktiopb.PortOperation_PORT_OPERATION_DELETE:
case pktiopb.PortOperation_PORT_OPERATION_DELETE:
p, ok := m.hostifs[resp.GetPortId()]
if !ok {
sendErr := c.Send(&pktiopb.HostPortControlRequest{Msg: &pktiopb.HostPortControlRequest_Status{
Expand Down Expand Up @@ -219,7 +219,7 @@ func (m *PacketIOMgr) ManagePorts(c pktiopb.PacketIO_HostPortControlClient) erro
if err := m.writePorts(); err != nil {
log.Warningf("failed to write file: %v", err)
}
case resp.Op == pktiopb.PortOperation_PORT_OPERATION_SET_UP || resp.Op == pktiopb.PortOperation_PORT_OPERATION_SET_DOWN:
case pktiopb.PortOperation_PORT_OPERATION_SET_UP, pktiopb.PortOperation_PORT_OPERATION_SET_DOWN:
p, ok := m.hostifs[resp.GetPortId()]
if !ok {
sendErr := c.Send(&pktiopb.HostPortControlRequest{Msg: &pktiopb.HostPortControlRequest_Status{
Expand Down

0 comments on commit 2332625

Please sign in to comment.