Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dataplane/forwarding/fwdport/ports/tap.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ func stateFromAttrs(attrs *netlink.LinkAttrs) (fwdpb.PortState, fwdpb.PortState)

var state fwdpb.PortState
switch attrs.OperState {
case netlink.OperDown, netlink.OperLowerLayerDown:
case netlink.OperDown, netlink.OperLowerLayerDown, netlink.OperUnknown:
Comment thread
sonikajindal marked this conversation as resolved.
Resolved
state = fwdpb.PortState_PORT_STATE_DISABLED_DOWN
case netlink.OperUp, netlink.OperUnknown: // TAP interface may be unknown state because the dataplane doesn't bind to its fd, so treat unknown as up.
case netlink.OperUp:
state = fwdpb.PortState_PORT_STATE_ENABLED_UP
}
return adminState, state
Expand Down
25 changes: 7 additions & 18 deletions dataplane/saiserver/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ func (port *port) CreatePort(ctx context.Context, req *saipb.CreatePortRequest)
}
// For ports that don't exist, do not create dataplane ports.
if _, err := getInterface(dev); err != nil {
attrs.OperStatus = saipb.PortOperStatus_PORT_OPER_STATUS_NOT_PRESENT.Enum()
attrs.OperStatus = saipb.PortOperStatus_PORT_OPER_STATUS_DOWN.Enum()
port.mgr.StoreAttributes(id, attrs)
// TODO: This should be a real error, improve once we a correct config solution.
// For now, create dummy port with no actions so we don't get a bunch error for a nonexistant port.
// For now, create dummy port with no actions so we don't get a bunch error for a nonexistent port.
fwdPort := &fwdpb.PortCreateRequest{
ContextId: &fwdpb.ContextId{Id: port.dataplane.ID()},
Port: &fwdpb.PortDesc{
Expand Down Expand Up @@ -527,28 +527,17 @@ func (port *port) createCPUPort(ctx context.Context) (uint64, error) {
// SetPortAttributes sets the attributes in the request.
func (port *port) SetPortAttribute(ctx context.Context, req *saipb.SetPortAttributeRequest) (*saipb.SetPortAttributeResponse, error) {
if req.AdminState != nil {
// Skip ports that don't exsit.
attrReq := &saipb.GetPortAttributeRequest{Oid: req.GetOid(), AttrType: []saipb.PortAttr{saipb.PortAttr_PORT_ATTR_OPER_STATUS}}
p := &saipb.GetPortAttributeResponse{}
if err := port.mgr.PopulateAttributes(attrReq, p); err != nil {
return nil, err
}
if p.GetAttr().GetOperStatus() == saipb.PortOperStatus_PORT_OPER_STATUS_NOT_PRESENT {
return nil, nil
}

stateReq := &fwdpb.PortStateRequest{
ContextId: &fwdpb.ContextId{Id: port.dataplane.ID()},
PortId: &fwdpb.PortId{ObjectId: &fwdpb.ObjectId{Id: fmt.Sprint(req.GetOid())}},
}
stateReq.Operation = &fwdpb.PortInfo{
AdminStatus: fwdpb.PortState_PORT_STATE_DISABLED_DOWN,
}
stateReq.Operation = &fwdpb.PortInfo{}
if req.GetAdminState() {
stateReq.Operation.AdminStatus = fwdpb.PortState_PORT_STATE_ENABLED_UP
} else {
stateReq.Operation.AdminStatus = fwdpb.PortState_PORT_STATE_DISABLED_DOWN
}
_, err := port.dataplane.PortState(ctx, stateReq)
if err != nil {
if _, err := port.dataplane.PortState(ctx, stateReq); err != nil {
return nil, err
}
}
Expand Down Expand Up @@ -709,7 +698,7 @@ func (port *port) RemovePort(ctx context.Context, req *saipb.RemovePortRequest)
}

func (port *port) Reset() {
slog.Info("reseting port")
slog.Info("resetting port")
}

type lagMember struct {
Expand Down
2 changes: 1 addition & 1 deletion dataplane/saiserver/ports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestCreatePort(t *testing.T) {
Oid: 3,
},
wantAttr: &saipb.PortAttribute{
OperStatus: saipb.PortOperStatus_PORT_OPER_STATUS_NOT_PRESENT.Enum(),
OperStatus: saipb.PortOperStatus_PORT_OPER_STATUS_DOWN.Enum(),
QosNumberOfQueues: proto.Uint32(12),
HwLaneList: []uint32{1},
QosQueueList: []uint64{4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
Expand Down
Loading