From 9b72c77d4b1cd516a420e9c012abcb9d1437b9a9 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 12 Oct 2026 16:40:09 -0700 Subject: [PATCH 1/6] Update ports.go Change the default state from PortOperStatus_PORT_OPER_STATUS_NOT_PRESENT to PortState_PORT_STATE_DISABLED_DOWN. --- dataplane/saiserver/ports.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 9ab6f834e..539510ebe 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -241,7 +241,7 @@ 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.PortState_PORT_STATE_DISABLED_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. From 105e24fa6044b660ec0c4d1f9edf9eb1079a8588 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Tue, 13 Oct 2026 15:06:17 -0700 Subject: [PATCH 2/6] Update ports.go Change the default oper status and remove the skip for ports with not present status in SetPortAttribute. --- dataplane/saiserver/ports.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 539510ebe..5440c408e 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -241,7 +241,7 @@ 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.PortState_PORT_STATE_DISABLED_DOWN.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. @@ -527,28 +527,16 @@ 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, - } 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 } } From 99e4c60b14c225f3b2cf2a40dcccf1cadb89a644 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Wed, 14 Oct 2026 10:43:06 -0700 Subject: [PATCH 3/6] Update ports_test.go Fix the unit test. --- dataplane/saiserver/ports_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataplane/saiserver/ports_test.go b/dataplane/saiserver/ports_test.go index 6b853a41b..8f1ca2fa1 100644 --- a/dataplane/saiserver/ports_test.go +++ b/dataplane/saiserver/ports_test.go @@ -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}, From 29b6331d5ffd51d6de6e6a9c087f368c89bb9688 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Wed, 14 Oct 2026 10:45:39 -0700 Subject: [PATCH 4/6] Update tap.go Change the oper status to DOWN when the port state is unknown. --- dataplane/forwarding/fwdport/ports/tap.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dataplane/forwarding/fwdport/ports/tap.go b/dataplane/forwarding/fwdport/ports/tap.go index 05aa14267..90876c59f 100644 --- a/dataplane/forwarding/fwdport/ports/tap.go +++ b/dataplane/forwarding/fwdport/ports/tap.go @@ -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: 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 From 0e933b64730a2ca756c3c313f2225d9087f1a313 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Wed, 14 Oct 2026 11:24:41 -0700 Subject: [PATCH 5/6] Update ports.go Fix typos --- dataplane/saiserver/ports.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 5440c408e..d082aaeae 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -244,7 +244,7 @@ func (port *port) CreatePort(ctx context.Context, req *saipb.CreatePortRequest) 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{ @@ -697,7 +697,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 { From c80f0e5587d002cf831c3f4eace0ca99ee12e650 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Wed, 14 Oct 2026 11:59:10 -0700 Subject: [PATCH 6/6] Update ports.go --- dataplane/saiserver/ports.go | 1 + 1 file changed, 1 insertion(+) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index d082aaeae..7e8b344b4 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -531,6 +531,7 @@ func (port *port) SetPortAttribute(ctx context.Context, req *saipb.SetPortAttrib ContextId: &fwdpb.ContextId{Id: port.dataplane.ID()}, PortId: &fwdpb.PortId{ObjectId: &fwdpb.ObjectId{Id: fmt.Sprint(req.GetOid())}}, } + stateReq.Operation = &fwdpb.PortInfo{} if req.GetAdminState() { stateReq.Operation.AdminStatus = fwdpb.PortState_PORT_STATE_ENABLED_UP } else {