From b08802a844210b6d0d3075d25871d091faef36b0 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Thu, 29 Oct 2026 15:48:19 -0700 Subject: [PATCH 01/15] Update ports.go Switch to use PortType_PORT_TYPE_GENETLINK when creating dummy ports. --- dataplane/saiserver/ports.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 847579e2..096825ed 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -247,12 +247,12 @@ func (port *port) CreatePort(ctx context.Context, req *saipb.CreatePortRequest) fwdPort := &fwdpb.PortCreateRequest{ ContextId: &fwdpb.ContextId{Id: port.dataplane.ID()}, Port: &fwdpb.PortDesc{ - PortType: fwdpb.PortType_PORT_TYPE_TAP, + PortType: fwdpb.PortType_PORT_TYPE_GENETLINK, PortId: &fwdpb.PortId{ ObjectId: &fwdpb.ObjectId{Id: fmt.Sprint(id)}, }, - Port: &fwdpb.PortDesc_Tap{ - Tap: &fwdpb.TAPPortDesc{ + Port: &fwdpb.PortDesc_Genetlink{ + Genetlink: &fwdpb.GenetlinkPortDesc{ DeviceName: dev, AdminState: req.GetAdminState(), }, @@ -534,6 +534,10 @@ func (port *port) SetPortAttribute(ctx context.Context, req *saipb.SetPortAttrib return nil, fmt.Errorf("port %v has no lanes", req.GetOid()) } dev := fmt.Sprintf("eth%v", portAttr.GetAttr().GetHwLaneList()[0]) + if _, err := getInterface(dev); err != nil { + // Skip setting MTU if the interface doesn't exist. These could be fake ports. + return &saipb.SetPortAttributeResponse{}, nil + } slog.InfoContext(ctx, "setting port mtu", "oid", req.GetOid(), "dev", dev, "mtu", req.GetMtu()) link, err := netlink.LinkByName(dev) if err != nil { From fc8c24d336f13720d5be9161fa87f04270101c75 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Thu, 29 Oct 2026 15:49:57 -0700 Subject: [PATCH 02/15] Update common.go Remove code to handle tap ports since dummy ports will use PortType_PORT_TYPE_GENETLINK. --- dataplane/forwarding/fwdport/ports/common.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dataplane/forwarding/fwdport/ports/common.go b/dataplane/forwarding/fwdport/ports/common.go index e8cffc45..a5dfdca9 100644 --- a/dataplane/forwarding/fwdport/ports/common.go +++ b/dataplane/forwarding/fwdport/ports/common.go @@ -167,10 +167,6 @@ func (w *linkStateWatcher) run(updCh <-chan netlink.LinkUpdate, doneCh <-chan st continue } admin, oper := stateFromAttrs(upd.Attrs()) - if portType := target.port.Type(); portType == fwdpb.PortType_PORT_TYPE_TAP { - // Dummy ports created by Lucius should not be set to enabled up. - oper = fwdpb.PortState_PORT_STATE_DISABLED_DOWN - } log.V(1).Infof("dataplane receive link update: port %q, admin %v, oper %v", devName, admin.String(), oper.String()) if err := target.ctx.Notify(&fwdpb.EventDesc{ Event: fwdpb.Event_EVENT_PORT, From c6558e3ed21385484636070876deab8aeab46da0 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Thu, 29 Oct 2026 15:50:38 -0700 Subject: [PATCH 03/15] Update genetlink.go Update genetlink so that it can be used to create dummy ports. --- .../forwarding/fwdport/ports/genetlink.go | 74 +++++++++---------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/dataplane/forwarding/fwdport/ports/genetlink.go b/dataplane/forwarding/fwdport/ports/genetlink.go index 3669beaf..3004d138 100644 --- a/dataplane/forwarding/fwdport/ports/genetlink.go +++ b/dataplane/forwarding/fwdport/ports/genetlink.go @@ -34,10 +34,10 @@ func init() { // port running on a remote CPU port. type genetlinkPort struct { fwdobject.Base - input fwdaction.Actions - output fwdaction.Actions - desc *fwdpb.PortDesc - ctx *fwdcontext.Context // Forwarding context containing the port + desc *fwdpb.PortDesc + devName string + adminState fwdpb.PortState + ctx *fwdcontext.Context // Forwarding context containing the port } // Desc returns the port description proto. @@ -46,7 +46,7 @@ func (p *genetlinkPort) Desc() *fwdpb.PortDesc { } func (p *genetlinkPort) String() string { - desc := fmt.Sprintf("Type=%v;;", fwdpb.PortType_PORT_TYPE_KERNEL, p.input, p.output) + desc := fmt.Sprintf("Type=%v;DeviceName=%v;", fwdpb.PortType_PORT_TYPE_GENETLINK, p.devName) if state, err := p.State(nil); err == nil { desc += fmt.Sprintf(";", state) } @@ -58,58 +58,34 @@ func (p *genetlinkPort) Type() fwdpb.PortType { } func (p *genetlinkPort) Cleanup() { - p.input.Cleanup() - p.output.Cleanup() - p.input = nil - p.output = nil } // Update updates the actions of the port. func (p *genetlinkPort) Update(upd *fwdpb.PortUpdateDesc) error { - var err error defer func() { - if err != nil { - p.Cleanup() - } + p.Cleanup() }() - genUpd, ok := upd.Port.(*fwdpb.PortUpdateDesc_Genetlink) - if !ok { - return fmt.Errorf("invalid type for port update") - } - - // Acquire new actions before releasing the old ones. - if p.input, err = fwdaction.NewActions(genUpd.Genetlink.GetInputs(), p.ctx); err != nil { - return fmt.Errorf("ports: input actions for port %v failed, err %v", p, err) - } - if p.output, err = fwdaction.NewActions(genUpd.Genetlink.GetOutputs(), p.ctx); err != nil { - return fmt.Errorf("ports: output actions for port %v failed, err %v", p, err) - } return nil } -// Write writes a packet out. If successful, the port returns -// fwdaction.CONSUME. func (p *genetlinkPort) Write(fwdpacket.Packet) (fwdaction.State, error) { return fwdaction.CONSUME, nil } // Actions returns the port actions of the specified type func (p *genetlinkPort) Actions(dir fwdpb.PortAction) fwdaction.Actions { - switch dir { - case fwdpb.PortAction_PORT_ACTION_INPUT: - return p.input - case fwdpb.PortAction_PORT_ACTION_OUTPUT: - return p.output - } return nil } // State returns the state of the port. -func (p *genetlinkPort) State(*fwdpb.PortInfo) (*fwdpb.PortStateReply, error) { +func (p *genetlinkPort) State(pi *fwdpb.PortInfo) (*fwdpb.PortStateReply, error) { + if pi != nil { + p.adminState = pi.AdminStatus + } return &fwdpb.PortStateReply{ Status: &fwdpb.PortInfo{ - OperStatus: fwdpb.PortState_PORT_STATE_ENABLED_UP, - AdminStatus: fwdpb.PortState_PORT_STATE_ENABLED_UP, + OperStatus: fwdpb.PortState_PORT_STATE_DISABLED_DOWN, + AdminStatus: p.adminState, }, }, nil } @@ -117,9 +93,25 @@ func (p *genetlinkPort) State(*fwdpb.PortInfo) (*fwdpb.PortStateReply, error) { type genetlinkBuilder struct{} // Build creates a new port. -func (genetlinkBuilder) Build(pd *fwdpb.PortDesc, ctx *fwdcontext.Context) (fwdport.Port, error) { - return &genetlinkPort{ - ctx: ctx, - desc: pd, - }, nil +func (genetlinkBuilder) Build(portDesc *fwdpb.PortDesc, ctx *fwdcontext.Context) (fwdport.Port, error) { + kp, ok := portDesc.Port.(*fwdpb.PortDesc_Genetlink) + if !ok { + return nil, fmt.Errorf("invalid port type in proto") + } + var adminState fwdpb.PortState + if kp.Genetlink.GetAdminState() { + adminState = fwdpb.PortState_PORT_STATE_ENABLED_UP + } else { + adminState = fwdpb.PortState_PORT_STATE_DISABLED_DOWN + } + p := genetlinkPort{ + ctx: ctx, + desc: portDesc, + adminState: adminState, + } + list := append(fwdport.CounterList, fwdaction.CounterList...) + if err := p.InitCounters("", list...); err != nil { + return nil, err + } + return &p, nil } From 60924dd720e78e1ddcaad4820cd003b75c7e6f84 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Thu, 29 Oct 2026 15:52:03 -0700 Subject: [PATCH 04/15] Update tap.go Fix minor bug in the string function --- dataplane/forwarding/fwdport/ports/tap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataplane/forwarding/fwdport/ports/tap.go b/dataplane/forwarding/fwdport/ports/tap.go index 275a4b5e..dc099f00 100644 --- a/dataplane/forwarding/fwdport/ports/tap.go +++ b/dataplane/forwarding/fwdport/ports/tap.go @@ -66,7 +66,7 @@ func (p *tapPort) Desc() *fwdpb.PortDesc { } func (p *tapPort) String() string { - desc := fmt.Sprintf("Type=%v;DeviceName=%v;;", fwdpb.PortType_PORT_TYPE_KERNEL, p.fd, p.input, p.output) + desc := fmt.Sprintf("Type=%v;DeviceName=%v;;", fwdpb.PortType_PORT_TYPE_KERNEL, p.devName, p.input, p.output) if state, err := p.State(nil); err == nil { desc += fmt.Sprintf(";", state) } From ef2127b3cf8c8395302d02ef4dd5e130c5a9f291 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Thu, 29 Oct 2026 15:53:06 -0700 Subject: [PATCH 05/15] Update forwarding_port.proto Update GenetlinkPortDesc --- proto/forwarding/forwarding_port.proto | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proto/forwarding/forwarding_port.proto b/proto/forwarding/forwarding_port.proto index 60983524..b8b57734 100644 --- a/proto/forwarding/forwarding_port.proto +++ b/proto/forwarding/forwarding_port.proto @@ -77,8 +77,8 @@ message FakePortDesc { } message GenetlinkPortDesc { - string family_name = 1; - string group_name = 2; + string device_name = 1; + bool admin_state = 2; } @@ -112,7 +112,7 @@ message PortUpdateRequest { } message PortUpdateReply { - + } // A CPUPortUpdateDesc updates the CPU port's input and output actions. @@ -127,7 +127,7 @@ message KernelPortUpdateDesc { repeated ActionDesc outputs = 2; } -// A GenetlinkPortUpdateDesc updates the Genetlink port's +// A GenetlinkPortUpdateDesc updates the Genetlink port's // input and output actions. message GenetlinkPortUpdateDesc { repeated ActionDesc inputs = 1; From 4ca69c4f70e36260ab15b59dd76f73b8e88d1b7e Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Thu, 29 Oct 2026 15:53:36 -0700 Subject: [PATCH 06/15] Update forwarding_port.pb.go Update GenetlinkPortDesc --- proto/forwarding/forwarding_port.pb.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/proto/forwarding/forwarding_port.pb.go b/proto/forwarding/forwarding_port.pb.go index 690514f0..2d6b4666 100644 --- a/proto/forwarding/forwarding_port.pb.go +++ b/proto/forwarding/forwarding_port.pb.go @@ -613,8 +613,8 @@ func (x *FakePortDesc) GetHwLane() uint32 { type GenetlinkPortDesc struct { state protoimpl.MessageState `protogen:"open.v1"` - FamilyName string `protobuf:"bytes,1,opt,name=family_name,json=familyName,proto3" json:"family_name,omitempty"` - GroupName string `protobuf:"bytes,2,opt,name=group_name,json=groupName,proto3" json:"group_name,omitempty"` + DeviceName string `protobuf:"bytes,1,opt,name=device_name,json=deviceName,proto3" json:"device_name,omitempty"` + AdminState bool `protobuf:"varint,2,opt,name=admin_state,json=adminState,proto3" json:"admin_state,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -649,18 +649,18 @@ func (*GenetlinkPortDesc) Descriptor() ([]byte, []int) { return file_proto_forwarding_forwarding_port_proto_rawDescGZIP(), []int{5} } -func (x *GenetlinkPortDesc) GetFamilyName() string { +func (x *GenetlinkPortDesc) GetDeviceName() string { if x != nil { - return x.FamilyName + return x.DeviceName } return "" } -func (x *GenetlinkPortDesc) GetGroupName() string { +func (x *GenetlinkPortDesc) GetAdminState() bool { if x != nil { - return x.GroupName + return x.AdminState } - return "" + return false } type PortCreateRequest struct { @@ -1699,12 +1699,12 @@ const file_proto_forwarding_forwarding_port_proto_rawDesc = "" + "\fFakePortDesc\x12\x17\n" + "\ain_file\x18\x01 \x01(\tR\x06inFile\x12\x19\n" + "\bout_file\x18\x02 \x01(\tR\aoutFile\x12\x17\n" + - "\ahw_lane\x18\x03 \x01(\rR\x06hwLane\"S\n" + + "\ahw_lane\x18\x03 \x01(\rR\x06hwLane\"U\n" + "\x11GenetlinkPortDesc\x12\x1f\n" + - "\vfamily_name\x18\x01 \x01(\tR\n" + - "familyName\x12\x1d\n" + - "\n" + - "group_name\x18\x02 \x01(\tR\tgroupName\"s\n" + + "\vdevice_name\x18\x01 \x01(\tR\n" + + "deviceName\x12\x1f\n" + + "\vadmin_state\x18\x02 \x01(\bR\n" + + "adminState\"s\n" + "\x11PortCreateRequest\x12(\n" + "\x04port\x18\x01 \x01(\v2\x14.forwarding.PortDescR\x04port\x124\n" + "\n" + From e73e4b2a1a05568cb250f1dbcdb8ae9b8dd44d1c Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Thu, 29 Oct 2026 16:04:36 -0700 Subject: [PATCH 07/15] Update ports.go Update comments --- dataplane/saiserver/ports.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 096825ed..03318e11 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -240,10 +240,8 @@ func (port *port) CreatePort(ctx context.Context, req *saipb.CreatePortRequest) AdminState: req.GetAdminState(), }, } - // For ports that don't exist, do not create dataplane ports. if _, err := getInterface(dev); err != nil { - // 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 nonexistent port. + // Create a dummy port so we don't get errors for a nonexistent port. fwdPort := &fwdpb.PortCreateRequest{ ContextId: &fwdpb.ContextId{Id: port.dataplane.ID()}, Port: &fwdpb.PortDesc{ From 88624d78623caf987a74ab2c462adc9dc7e08ebb Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 2 Nov 2026 09:06:00 -0800 Subject: [PATCH 08/15] Update and rename genetlink.go to dummy.go Rename to dummy port since it is a dummy port --- .../fwdport/ports/{genetlink.go => dummy.go} | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) rename dataplane/forwarding/fwdport/ports/{genetlink.go => dummy.go} (71%) diff --git a/dataplane/forwarding/fwdport/ports/genetlink.go b/dataplane/forwarding/fwdport/ports/dummy.go similarity index 71% rename from dataplane/forwarding/fwdport/ports/genetlink.go rename to dataplane/forwarding/fwdport/ports/dummy.go index 3004d138..c40d90b0 100644 --- a/dataplane/forwarding/fwdport/ports/genetlink.go +++ b/dataplane/forwarding/fwdport/ports/dummy.go @@ -26,13 +26,13 @@ import ( ) func init() { - fwdport.Register(fwdpb.PortType_PORT_TYPE_GENETLINK, genetlinkBuilder{}) + fwdport.Register(fwdpb.PortType_PORT_TYPE_DUMMY, dummyBuilder{}) } -// genetlinkPort is a ports that receives from and writes a linux network device. -// Note: This is a "virtual" port, it doesn't perform any IO, but represents a genetlink +// dummyPort is a ports that receives from and writes a linux network device. +// Note: This is a "virtual" port, it doesn't perform any IO, but represents a dummy // port running on a remote CPU port. -type genetlinkPort struct { +type dummyPort struct { fwdobject.Base desc *fwdpb.PortDesc devName string @@ -41,44 +41,44 @@ type genetlinkPort struct { } // Desc returns the port description proto. -func (p *genetlinkPort) Desc() *fwdpb.PortDesc { +func (p *dummyPort) Desc() *fwdpb.PortDesc { return p.desc } -func (p *genetlinkPort) String() string { - desc := fmt.Sprintf("Type=%v;DeviceName=%v;", fwdpb.PortType_PORT_TYPE_GENETLINK, p.devName) +func (p *dummyPort) String() string { + desc := fmt.Sprintf("Type=%v;DeviceName=%v;", fwdpb.PortType_PORT_TYPE_DUMMY, p.devName) if state, err := p.State(nil); err == nil { desc += fmt.Sprintf(";", state) } return desc } -func (p *genetlinkPort) Type() fwdpb.PortType { - return fwdpb.PortType_PORT_TYPE_GENETLINK +func (p *dummyPort) Type() fwdpb.PortType { + return fwdpb.PortType_PORT_TYPE_DUMMY } -func (p *genetlinkPort) Cleanup() { +func (p *dummyPort) Cleanup() { } // Update updates the actions of the port. -func (p *genetlinkPort) Update(upd *fwdpb.PortUpdateDesc) error { +func (p *dummyPort) Update(upd *fwdpb.PortUpdateDesc) error { defer func() { p.Cleanup() }() return nil } -func (p *genetlinkPort) Write(fwdpacket.Packet) (fwdaction.State, error) { +func (p *dummyPort) Write(fwdpacket.Packet) (fwdaction.State, error) { return fwdaction.CONSUME, nil } // Actions returns the port actions of the specified type -func (p *genetlinkPort) Actions(dir fwdpb.PortAction) fwdaction.Actions { +func (p *dummyPort) Actions(dir fwdpb.PortAction) fwdaction.Actions { return nil } // State returns the state of the port. -func (p *genetlinkPort) State(pi *fwdpb.PortInfo) (*fwdpb.PortStateReply, error) { +func (p *dummyPort) State(pi *fwdpb.PortInfo) (*fwdpb.PortStateReply, error) { if pi != nil { p.adminState = pi.AdminStatus } @@ -90,21 +90,21 @@ func (p *genetlinkPort) State(pi *fwdpb.PortInfo) (*fwdpb.PortStateReply, error) }, nil } -type genetlinkBuilder struct{} +type dummyBuilder struct{} // Build creates a new port. -func (genetlinkBuilder) Build(portDesc *fwdpb.PortDesc, ctx *fwdcontext.Context) (fwdport.Port, error) { - kp, ok := portDesc.Port.(*fwdpb.PortDesc_Genetlink) +func (dummyBuilder) Build(portDesc *fwdpb.PortDesc, ctx *fwdcontext.Context) (fwdport.Port, error) { + kp, ok := portDesc.Port.(*fwdpb.PortDesc_Dummy) if !ok { return nil, fmt.Errorf("invalid port type in proto") } var adminState fwdpb.PortState - if kp.Genetlink.GetAdminState() { + if kp.Dummy.GetAdminState() { adminState = fwdpb.PortState_PORT_STATE_ENABLED_UP } else { adminState = fwdpb.PortState_PORT_STATE_DISABLED_DOWN } - p := genetlinkPort{ + p := dummyPort{ ctx: ctx, desc: portDesc, adminState: adminState, From 651ac98a7368e9eed683e923a3c37faa0449f895 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 2 Nov 2026 09:06:29 -0800 Subject: [PATCH 09/15] Update BUILD Rename genetlink to dummy --- dataplane/forwarding/fwdport/ports/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataplane/forwarding/fwdport/ports/BUILD b/dataplane/forwarding/fwdport/ports/BUILD index 61ac66c0..a1d6a0c1 100644 --- a/dataplane/forwarding/fwdport/ports/BUILD +++ b/dataplane/forwarding/fwdport/ports/BUILD @@ -7,7 +7,7 @@ go_library( "cpu.go", "doc.go", "fake.go", - "genetlink.go", + "dummy.go", "group.go", "kernel.go", "tap.go", From 1c5e9bcef72b479bda957fa01e24d47015587118 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 2 Nov 2026 09:07:16 -0800 Subject: [PATCH 10/15] Update forwarding_port.proto Rename genet to dummy --- proto/forwarding/forwarding_port.proto | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/proto/forwarding/forwarding_port.proto b/proto/forwarding/forwarding_port.proto index b8b57734..d722d076 100644 --- a/proto/forwarding/forwarding_port.proto +++ b/proto/forwarding/forwarding_port.proto @@ -31,7 +31,7 @@ enum PortType { PORT_TYPE_KERNEL = 3; // Port that is kernel network interface. PORT_TYPE_TAP = 4; // Port that is kernel TAP interface. PORT_TYPE_FAKE = 5; // Fake port type that uses files for packet io. - PORT_TYPE_GENETLINK = 6; // Port that use genetlink. + PORT_TYPE_DUMMY = 6; // Port that is a dummy port. } // A PortDesc describes a forwarding port. It is assumed that the descriptor @@ -45,7 +45,7 @@ message PortDesc { KernelPortDesc kernel = 4; TAPPortDesc tap = 5; FakePortDesc fake = 6; - GenetlinkPortDesc genetlink = 7; + DummyPortDesc dummy = 7; } } @@ -76,7 +76,7 @@ message FakePortDesc { uint32 hw_lane = 3; } -message GenetlinkPortDesc { +message DummyPortDesc { string device_name = 1; bool admin_state = 2; } @@ -100,7 +100,7 @@ message PortUpdateDesc { AggregatePortRemoveMemberUpdateDesc aggregate_del = 4; AggregatePortAlgorithmUpdateDesc aggregate_algo = 5; KernelPortUpdateDesc kernel = 6; - GenetlinkPortUpdateDesc genetlink = 7; + DummyPortUpdateDesc dummy = 7; } } @@ -127,9 +127,9 @@ message KernelPortUpdateDesc { repeated ActionDesc outputs = 2; } -// A GenetlinkPortUpdateDesc updates the Genetlink port's +// A DummyPortUpdateDesc updates the dummy port's // input and output actions. -message GenetlinkPortUpdateDesc { +message DummyPortUpdateDesc { repeated ActionDesc inputs = 1; repeated ActionDesc outputs = 2; } From ecd4720682f7cabef94056c4d7f32b2eeae5b174 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 2 Nov 2026 09:07:54 -0800 Subject: [PATCH 11/15] Update forwarding_port.pb.go Rename genetlink to dummy --- proto/forwarding/forwarding_port.pb.go | 116 ++++++++++++------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/proto/forwarding/forwarding_port.pb.go b/proto/forwarding/forwarding_port.pb.go index 2d6b4666..cccca063 100644 --- a/proto/forwarding/forwarding_port.pb.go +++ b/proto/forwarding/forwarding_port.pb.go @@ -31,7 +31,7 @@ const ( PortType_PORT_TYPE_KERNEL PortType = 3 PortType_PORT_TYPE_TAP PortType = 4 PortType_PORT_TYPE_FAKE PortType = 5 - PortType_PORT_TYPE_GENETLINK PortType = 6 + PortType_PORT_TYPE_DUMMY PortType = 6 ) // Enum value maps for PortType. @@ -43,7 +43,7 @@ var ( 3: "PORT_TYPE_KERNEL", 4: "PORT_TYPE_TAP", 5: "PORT_TYPE_FAKE", - 6: "PORT_TYPE_GENETLINK", + 6: "PORT_TYPE_DUMMY", } PortType_value = map[string]int32{ "PORT_TYPE_UNSPECIFIED": 0, @@ -52,7 +52,7 @@ var ( "PORT_TYPE_KERNEL": 3, "PORT_TYPE_TAP": 4, "PORT_TYPE_FAKE": 5, - "PORT_TYPE_GENETLINK": 6, + "PORT_TYPE_DUMMY": 6, } ) @@ -243,7 +243,7 @@ type PortDesc struct { // *PortDesc_Kernel // *PortDesc_Tap // *PortDesc_Fake - // *PortDesc_Genetlink + // *PortDesc_Dummy Port isPortDesc_Port `protobuf_oneof:"port"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -336,10 +336,10 @@ func (x *PortDesc) GetFake() *FakePortDesc { return nil } -func (x *PortDesc) GetGenetlink() *GenetlinkPortDesc { +func (x *PortDesc) GetDummy() *DummyPortDesc { if x != nil { - if x, ok := x.Port.(*PortDesc_Genetlink); ok { - return x.Genetlink + if x, ok := x.Port.(*PortDesc_Dummy); ok { + return x.Dummy } } return nil @@ -365,8 +365,8 @@ type PortDesc_Fake struct { Fake *FakePortDesc `protobuf:"bytes,6,opt,name=fake,proto3,oneof"` } -type PortDesc_Genetlink struct { - Genetlink *GenetlinkPortDesc `protobuf:"bytes,7,opt,name=genetlink,proto3,oneof"` +type PortDesc_Dummy struct { + Dummy *DummyPortDesc `protobuf:"bytes,7,opt,name=dummy,proto3,oneof"` } func (*PortDesc_Cpu) isPortDesc_Port() {} @@ -377,7 +377,7 @@ func (*PortDesc_Tap) isPortDesc_Port() {} func (*PortDesc_Fake) isPortDesc_Port() {} -func (*PortDesc_Genetlink) isPortDesc_Port() {} +func (*PortDesc_Dummy) isPortDesc_Port() {} type CPUPortDesc struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -611,7 +611,7 @@ func (x *FakePortDesc) GetHwLane() uint32 { return 0 } -type GenetlinkPortDesc struct { +type DummyPortDesc struct { state protoimpl.MessageState `protogen:"open.v1"` DeviceName string `protobuf:"bytes,1,opt,name=device_name,json=deviceName,proto3" json:"device_name,omitempty"` AdminState bool `protobuf:"varint,2,opt,name=admin_state,json=adminState,proto3" json:"admin_state,omitempty"` @@ -619,20 +619,20 @@ type GenetlinkPortDesc struct { sizeCache protoimpl.SizeCache } -func (x *GenetlinkPortDesc) Reset() { - *x = GenetlinkPortDesc{} +func (x *DummyPortDesc) Reset() { + *x = DummyPortDesc{} mi := &file_proto_forwarding_forwarding_port_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GenetlinkPortDesc) String() string { +func (x *DummyPortDesc) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GenetlinkPortDesc) ProtoMessage() {} +func (*DummyPortDesc) ProtoMessage() {} -func (x *GenetlinkPortDesc) ProtoReflect() protoreflect.Message { +func (x *DummyPortDesc) ProtoReflect() protoreflect.Message { mi := &file_proto_forwarding_forwarding_port_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -644,19 +644,19 @@ func (x *GenetlinkPortDesc) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GenetlinkPortDesc.ProtoReflect.Descriptor instead. -func (*GenetlinkPortDesc) Descriptor() ([]byte, []int) { +// Deprecated: Use DummyPortDesc.ProtoReflect.Descriptor instead. +func (*DummyPortDesc) Descriptor() ([]byte, []int) { return file_proto_forwarding_forwarding_port_proto_rawDescGZIP(), []int{5} } -func (x *GenetlinkPortDesc) GetDeviceName() string { +func (x *DummyPortDesc) GetDeviceName() string { if x != nil { return x.DeviceName } return "" } -func (x *GenetlinkPortDesc) GetAdminState() bool { +func (x *DummyPortDesc) GetAdminState() bool { if x != nil { return x.AdminState } @@ -769,7 +769,7 @@ type PortUpdateDesc struct { // *PortUpdateDesc_AggregateDel // *PortUpdateDesc_AggregateAlgo // *PortUpdateDesc_Kernel - // *PortUpdateDesc_Genetlink + // *PortUpdateDesc_Dummy Port isPortUpdateDesc_Port `protobuf_oneof:"port"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -866,10 +866,10 @@ func (x *PortUpdateDesc) GetKernel() *KernelPortUpdateDesc { return nil } -func (x *PortUpdateDesc) GetGenetlink() *GenetlinkPortUpdateDesc { +func (x *PortUpdateDesc) GetDummy() *DummyPortUpdateDesc { if x != nil { - if x, ok := x.Port.(*PortUpdateDesc_Genetlink); ok { - return x.Genetlink + if x, ok := x.Port.(*PortUpdateDesc_Dummy); ok { + return x.Dummy } } return nil @@ -903,8 +903,8 @@ type PortUpdateDesc_Kernel struct { Kernel *KernelPortUpdateDesc `protobuf:"bytes,6,opt,name=kernel,proto3,oneof"` } -type PortUpdateDesc_Genetlink struct { - Genetlink *GenetlinkPortUpdateDesc `protobuf:"bytes,7,opt,name=genetlink,proto3,oneof"` +type PortUpdateDesc_Dummy struct { + Dummy *DummyPortUpdateDesc `protobuf:"bytes,7,opt,name=dummy,proto3,oneof"` } func (*PortUpdateDesc_Cpu) isPortUpdateDesc_Port() {} @@ -919,7 +919,7 @@ func (*PortUpdateDesc_AggregateAlgo) isPortUpdateDesc_Port() {} func (*PortUpdateDesc_Kernel) isPortUpdateDesc_Port() {} -func (*PortUpdateDesc_Genetlink) isPortUpdateDesc_Port() {} +func (*PortUpdateDesc_Dummy) isPortUpdateDesc_Port() {} type PortUpdateRequest struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1121,7 +1121,7 @@ func (x *KernelPortUpdateDesc) GetOutputs() []*ActionDesc { return nil } -type GenetlinkPortUpdateDesc struct { +type DummyPortUpdateDesc struct { state protoimpl.MessageState `protogen:"open.v1"` Inputs []*ActionDesc `protobuf:"bytes,1,rep,name=inputs,proto3" json:"inputs,omitempty"` Outputs []*ActionDesc `protobuf:"bytes,2,rep,name=outputs,proto3" json:"outputs,omitempty"` @@ -1129,20 +1129,20 @@ type GenetlinkPortUpdateDesc struct { sizeCache protoimpl.SizeCache } -func (x *GenetlinkPortUpdateDesc) Reset() { - *x = GenetlinkPortUpdateDesc{} +func (x *DummyPortUpdateDesc) Reset() { + *x = DummyPortUpdateDesc{} mi := &file_proto_forwarding_forwarding_port_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GenetlinkPortUpdateDesc) String() string { +func (x *DummyPortUpdateDesc) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GenetlinkPortUpdateDesc) ProtoMessage() {} +func (*DummyPortUpdateDesc) ProtoMessage() {} -func (x *GenetlinkPortUpdateDesc) ProtoReflect() protoreflect.Message { +func (x *DummyPortUpdateDesc) ProtoReflect() protoreflect.Message { mi := &file_proto_forwarding_forwarding_port_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1154,19 +1154,19 @@ func (x *GenetlinkPortUpdateDesc) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GenetlinkPortUpdateDesc.ProtoReflect.Descriptor instead. -func (*GenetlinkPortUpdateDesc) Descriptor() ([]byte, []int) { +// Deprecated: Use DummyPortUpdateDesc.ProtoReflect.Descriptor instead. +func (*DummyPortUpdateDesc) Descriptor() ([]byte, []int) { return file_proto_forwarding_forwarding_port_proto_rawDescGZIP(), []int{13} } -func (x *GenetlinkPortUpdateDesc) GetInputs() []*ActionDesc { +func (x *DummyPortUpdateDesc) GetInputs() []*ActionDesc { if x != nil { return x.Inputs } return nil } -func (x *GenetlinkPortUpdateDesc) GetOutputs() []*ActionDesc { +func (x *DummyPortUpdateDesc) GetOutputs() []*ActionDesc { if x != nil { return x.Outputs } @@ -1670,15 +1670,15 @@ var File_proto_forwarding_forwarding_port_proto protoreflect.FileDescriptor const file_proto_forwarding_forwarding_port_proto_rawDesc = "" + "\n" + "&proto/forwarding/forwarding_port.proto\x12\n" + - "forwarding\x1a\x17google/rpc/status.proto\x1a(proto/forwarding/forwarding_action.proto\x1a(proto/forwarding/forwarding_common.proto\"\xf1\x02\n" + + "forwarding\x1a\x17google/rpc/status.proto\x1a(proto/forwarding/forwarding_action.proto\x1a(proto/forwarding/forwarding_common.proto\"\xe5\x02\n" + "\bPortDesc\x121\n" + "\tport_type\x18\x01 \x01(\x0e2\x14.forwarding.PortTypeR\bportType\x12+\n" + "\aport_id\x18\x02 \x01(\v2\x12.forwarding.PortIdR\x06portId\x12+\n" + "\x03cpu\x18\x03 \x01(\v2\x17.forwarding.CPUPortDescH\x00R\x03cpu\x124\n" + "\x06kernel\x18\x04 \x01(\v2\x1a.forwarding.KernelPortDescH\x00R\x06kernel\x12+\n" + "\x03tap\x18\x05 \x01(\v2\x17.forwarding.TAPPortDescH\x00R\x03tap\x12.\n" + - "\x04fake\x18\x06 \x01(\v2\x18.forwarding.FakePortDescH\x00R\x04fake\x12=\n" + - "\tgenetlink\x18\a \x01(\v2\x1d.forwarding.GenetlinkPortDescH\x00R\tgenetlinkB\x06\n" + + "\x04fake\x18\x06 \x01(\v2\x18.forwarding.FakePortDescH\x00R\x04fake\x121\n" + + "\x05dummy\x18\a \x01(\v2\x19.forwarding.DummyPortDescH\x00R\x05dummyB\x06\n" + "\x04port\"\xb1\x01\n" + "\vCPUPortDesc\x12\x19\n" + "\bqueue_id\x18\x01 \x01(\tR\aqueueId\x12!\n" + @@ -1699,8 +1699,8 @@ const file_proto_forwarding_forwarding_port_proto_rawDesc = "" + "\fFakePortDesc\x12\x17\n" + "\ain_file\x18\x01 \x01(\tR\x06inFile\x12\x19\n" + "\bout_file\x18\x02 \x01(\tR\aoutFile\x12\x17\n" + - "\ahw_lane\x18\x03 \x01(\rR\x06hwLane\"U\n" + - "\x11GenetlinkPortDesc\x12\x1f\n" + + "\ahw_lane\x18\x03 \x01(\rR\x06hwLane\"Q\n" + + "\rDummyPortDesc\x12\x1f\n" + "\vdevice_name\x18\x01 \x01(\tR\n" + "deviceName\x12\x1f\n" + "\vadmin_state\x18\x02 \x01(\bR\n" + @@ -1710,15 +1710,15 @@ const file_proto_forwarding_forwarding_port_proto_rawDesc = "" + "\n" + "context_id\x18\x02 \x01(\v2\x15.forwarding.ContextIdR\tcontextId\"M\n" + "\x0fPortCreateReply\x12:\n" + - "\fobject_index\x18\x02 \x01(\v2\x17.forwarding.ObjectIndexR\vobjectIndex\"\x95\x04\n" + + "\fobject_index\x18\x02 \x01(\v2\x17.forwarding.ObjectIndexR\vobjectIndex\"\x89\x04\n" + "\x0ePortUpdateDesc\x121\n" + "\x03cpu\x18\x01 \x01(\v2\x1d.forwarding.CPUPortUpdateDescH\x00R\x03cpu\x12C\n" + "\taggregate\x18\x02 \x01(\v2#.forwarding.AggregatePortUpdateDescH\x00R\taggregate\x12S\n" + "\raggregate_add\x18\x03 \x01(\v2,.forwarding.AggregatePortAddMemberUpdateDescH\x00R\faggregateAdd\x12V\n" + "\raggregate_del\x18\x04 \x01(\v2/.forwarding.AggregatePortRemoveMemberUpdateDescH\x00R\faggregateDel\x12U\n" + "\x0eaggregate_algo\x18\x05 \x01(\v2,.forwarding.AggregatePortAlgorithmUpdateDescH\x00R\raggregateAlgo\x12:\n" + - "\x06kernel\x18\x06 \x01(\v2 .forwarding.KernelPortUpdateDescH\x00R\x06kernel\x12C\n" + - "\tgenetlink\x18\a \x01(\v2#.forwarding.GenetlinkPortUpdateDescH\x00R\tgenetlinkB\x06\n" + + "\x06kernel\x18\x06 \x01(\v2 .forwarding.KernelPortUpdateDescH\x00R\x06kernel\x127\n" + + "\x05dummy\x18\a \x01(\v2\x1f.forwarding.DummyPortUpdateDescH\x00R\x05dummyB\x06\n" + "\x04port\"\xaa\x01\n" + "\x11PortUpdateRequest\x12+\n" + "\aport_id\x18\x01 \x01(\v2\x12.forwarding.PortIdR\x06portId\x124\n" + @@ -1731,8 +1731,8 @@ const file_proto_forwarding_forwarding_port_proto_rawDesc = "" + "\aoutputs\x18\x02 \x03(\v2\x16.forwarding.ActionDescR\aoutputs\"x\n" + "\x14KernelPortUpdateDesc\x12.\n" + "\x06inputs\x18\x01 \x03(\v2\x16.forwarding.ActionDescR\x06inputs\x120\n" + - "\aoutputs\x18\x02 \x03(\v2\x16.forwarding.ActionDescR\aoutputs\"{\n" + - "\x17GenetlinkPortUpdateDesc\x12.\n" + + "\aoutputs\x18\x02 \x03(\v2\x16.forwarding.ActionDescR\aoutputs\"w\n" + + "\x13DummyPortUpdateDesc\x12.\n" + "\x06inputs\x18\x01 \x03(\v2\x16.forwarding.ActionDescR\x06inputs\x120\n" + "\aoutputs\x18\x02 \x03(\v2\x16.forwarding.ActionDescR\aoutputs\"v\n" + "\x15AggregateSelectAction\x12+\n" + @@ -1766,15 +1766,15 @@ const file_proto_forwarding_forwarding_port_proto_rawDesc = "" + "context_id\x18\x02 \x01(\v2\x15.forwarding.ContextIdR\tcontextId\x122\n" + "\toperation\x18\x03 \x01(\v2\x14.forwarding.PortInfoR\toperation\">\n" + "\x0ePortStateReply\x12,\n" + - "\x06status\x18\x01 \x01(\v2\x14.forwarding.PortInfoR\x06status*\xb1\x01\n" + + "\x06status\x18\x01 \x01(\v2\x14.forwarding.PortInfoR\x06status*\xad\x01\n" + "\bPortType\x12\x19\n" + "\x15PORT_TYPE_UNSPECIFIED\x10\x00\x12\x16\n" + "\x12PORT_TYPE_CPU_PORT\x10\x01\x12\x1c\n" + "\x18PORT_TYPE_AGGREGATE_PORT\x10\x02\x12\x14\n" + "\x10PORT_TYPE_KERNEL\x10\x03\x12\x11\n" + "\rPORT_TYPE_TAP\x10\x04\x12\x12\n" + - "\x0ePORT_TYPE_FAKE\x10\x05\x12\x17\n" + - "\x13PORT_TYPE_GENETLINK\x10\x06*\xae\x01\n" + + "\x0ePORT_TYPE_FAKE\x10\x05\x12\x13\n" + + "\x0fPORT_TYPE_DUMMY\x10\x06*\xae\x01\n" + "\x16AggregateHashAlgorithm\x12(\n" + "$AGGREGATE_HASH_ALGORITHM_UNSPECIFIED\x10\x00\x12\"\n" + "\x1eAGGREGATE_HASH_ALGORITHM_CRC16\x10\x02\x12\"\n" + @@ -1813,7 +1813,7 @@ var file_proto_forwarding_forwarding_port_proto_goTypes = []any{ (*KernelPortDesc)(nil), // 6: forwarding.KernelPortDesc (*TAPPortDesc)(nil), // 7: forwarding.TAPPortDesc (*FakePortDesc)(nil), // 8: forwarding.FakePortDesc - (*GenetlinkPortDesc)(nil), // 9: forwarding.GenetlinkPortDesc + (*DummyPortDesc)(nil), // 9: forwarding.DummyPortDesc (*PortCreateRequest)(nil), // 10: forwarding.PortCreateRequest (*PortCreateReply)(nil), // 11: forwarding.PortCreateReply (*PortUpdateDesc)(nil), // 12: forwarding.PortUpdateDesc @@ -1821,7 +1821,7 @@ var file_proto_forwarding_forwarding_port_proto_goTypes = []any{ (*PortUpdateReply)(nil), // 14: forwarding.PortUpdateReply (*CPUPortUpdateDesc)(nil), // 15: forwarding.CPUPortUpdateDesc (*KernelPortUpdateDesc)(nil), // 16: forwarding.KernelPortUpdateDesc - (*GenetlinkPortUpdateDesc)(nil), // 17: forwarding.GenetlinkPortUpdateDesc + (*DummyPortUpdateDesc)(nil), // 17: forwarding.DummyPortUpdateDesc (*AggregateSelectAction)(nil), // 18: forwarding.AggregateSelectAction (*AggregatePortUpdateDesc)(nil), // 19: forwarding.AggregatePortUpdateDesc (*AggregatePortAddMemberUpdateDesc)(nil), // 20: forwarding.AggregatePortAddMemberUpdateDesc @@ -1844,7 +1844,7 @@ var file_proto_forwarding_forwarding_port_proto_depIdxs = []int32{ 6, // 3: forwarding.PortDesc.kernel:type_name -> forwarding.KernelPortDesc 7, // 4: forwarding.PortDesc.tap:type_name -> forwarding.TAPPortDesc 8, // 5: forwarding.PortDesc.fake:type_name -> forwarding.FakePortDesc - 9, // 6: forwarding.PortDesc.genetlink:type_name -> forwarding.GenetlinkPortDesc + 9, // 6: forwarding.PortDesc.dummy:type_name -> forwarding.DummyPortDesc 28, // 7: forwarding.CPUPortDesc.export_field_ids:type_name -> forwarding.PacketFieldId 4, // 8: forwarding.PortCreateRequest.port:type_name -> forwarding.PortDesc 29, // 9: forwarding.PortCreateRequest.context_id:type_name -> forwarding.ContextId @@ -1855,7 +1855,7 @@ var file_proto_forwarding_forwarding_port_proto_depIdxs = []int32{ 21, // 14: forwarding.PortUpdateDesc.aggregate_del:type_name -> forwarding.AggregatePortRemoveMemberUpdateDesc 22, // 15: forwarding.PortUpdateDesc.aggregate_algo:type_name -> forwarding.AggregatePortAlgorithmUpdateDesc 16, // 16: forwarding.PortUpdateDesc.kernel:type_name -> forwarding.KernelPortUpdateDesc - 17, // 17: forwarding.PortUpdateDesc.genetlink:type_name -> forwarding.GenetlinkPortUpdateDesc + 17, // 17: forwarding.PortUpdateDesc.dummy:type_name -> forwarding.DummyPortUpdateDesc 27, // 18: forwarding.PortUpdateRequest.port_id:type_name -> forwarding.PortId 29, // 19: forwarding.PortUpdateRequest.context_id:type_name -> forwarding.ContextId 12, // 20: forwarding.PortUpdateRequest.update:type_name -> forwarding.PortUpdateDesc @@ -1863,8 +1863,8 @@ var file_proto_forwarding_forwarding_port_proto_depIdxs = []int32{ 31, // 22: forwarding.CPUPortUpdateDesc.outputs:type_name -> forwarding.ActionDesc 31, // 23: forwarding.KernelPortUpdateDesc.inputs:type_name -> forwarding.ActionDesc 31, // 24: forwarding.KernelPortUpdateDesc.outputs:type_name -> forwarding.ActionDesc - 31, // 25: forwarding.GenetlinkPortUpdateDesc.inputs:type_name -> forwarding.ActionDesc - 31, // 26: forwarding.GenetlinkPortUpdateDesc.outputs:type_name -> forwarding.ActionDesc + 31, // 25: forwarding.DummyPortUpdateDesc.inputs:type_name -> forwarding.ActionDesc + 31, // 26: forwarding.DummyPortUpdateDesc.outputs:type_name -> forwarding.ActionDesc 27, // 27: forwarding.AggregateSelectAction.port_id:type_name -> forwarding.PortId 31, // 28: forwarding.AggregateSelectAction.actions:type_name -> forwarding.ActionDesc 27, // 29: forwarding.AggregatePortUpdateDesc.port_ids:type_name -> forwarding.PortId @@ -1903,7 +1903,7 @@ func file_proto_forwarding_forwarding_port_proto_init() { (*PortDesc_Kernel)(nil), (*PortDesc_Tap)(nil), (*PortDesc_Fake)(nil), - (*PortDesc_Genetlink)(nil), + (*PortDesc_Dummy)(nil), } file_proto_forwarding_forwarding_port_proto_msgTypes[8].OneofWrappers = []any{ (*PortUpdateDesc_Cpu)(nil), @@ -1912,7 +1912,7 @@ func file_proto_forwarding_forwarding_port_proto_init() { (*PortUpdateDesc_AggregateDel)(nil), (*PortUpdateDesc_AggregateAlgo)(nil), (*PortUpdateDesc_Kernel)(nil), - (*PortUpdateDesc_Genetlink)(nil), + (*PortUpdateDesc_Dummy)(nil), } type x struct{} out := protoimpl.TypeBuilder{ From d8b9f26caa85ee1e58c052114e188a3591ac72d6 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 2 Nov 2026 09:09:03 -0800 Subject: [PATCH 12/15] Update ports.go Rename genetlink to dummy --- dataplane/saiserver/ports.go | 50 +++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 03318e11..d47a4dc8 100644 --- a/dataplane/saiserver/ports.go +++ b/dataplane/saiserver/ports.go @@ -114,6 +114,28 @@ const ( numSchedulerGroups = 12 ) +func (port *port) updatePortList(id uint64) error { + switchID, ok := port.mgr.GetSwitchID() + if !ok { + return fmt.Errorf("failed to get switch ID") + } + switchAttrs := &saipb.SwitchAttribute{} + if err := port.mgr.PopulateAllAttributes(switchID, switchAttrs); err != nil { + return fmt.Errorf("failed to get switch attributes: %v", err) + } + uSwitchID, err := strconv.ParseUint(switchID, 10, 64) + if err != nil { + return err + } + portList := switchAttrs.GetPortList() + portList = append(portList, id) + port.mgr.StoreAttributes(uSwitchID, &saipb.SwitchAttribute{ + PortList: portList, + NumberOfActivePorts: proto.Uint32(uint32(len(portList))), + }) + return nil +} + // CreatePort creates a new port, mapping the port to ethX, where X is assigned sequentially from 1 to n. // Note: If more ports are created than eth devices, no error is returned, but the OperStatus is set to NOT_PRESENT. func (port *port) CreatePort(ctx context.Context, req *saipb.CreatePortRequest) (*saipb.CreatePortResponse, error) { @@ -245,12 +267,12 @@ func (port *port) CreatePort(ctx context.Context, req *saipb.CreatePortRequest) fwdPort := &fwdpb.PortCreateRequest{ ContextId: &fwdpb.ContextId{Id: port.dataplane.ID()}, Port: &fwdpb.PortDesc{ - PortType: fwdpb.PortType_PORT_TYPE_GENETLINK, + PortType: fwdpb.PortType_PORT_TYPE_DUMMY, PortId: &fwdpb.PortId{ ObjectId: &fwdpb.ObjectId{Id: fmt.Sprint(id)}, }, - Port: &fwdpb.PortDesc_Genetlink{ - Genetlink: &fwdpb.GenetlinkPortDesc{ + Port: &fwdpb.PortDesc_Dummy{ + Dummy: &fwdpb.DummyPortDesc{ DeviceName: dev, AdminState: req.GetAdminState(), }, @@ -262,6 +284,9 @@ func (port *port) CreatePort(ctx context.Context, req *saipb.CreatePortRequest) } attrs.OperStatus = saipb.PortOperStatus_PORT_OPER_STATUS_DOWN.Enum() port.mgr.StoreAttributes(id, attrs) + if err := port.updatePortList(id); err != nil { + return nil, err + } return &saipb.CreatePortResponse{ Oid: id, }, nil @@ -304,26 +329,9 @@ func (port *port) CreatePort(ctx context.Context, req *saipb.CreatePortRequest) attrs.OperStatus = saipb.PortOperStatus_PORT_OPER_STATUS_DOWN.Enum() } port.mgr.StoreAttributes(id, attrs) - - // Update the switch's port list. - switchID, ok := port.mgr.GetSwitchID() - if !ok { - return nil, fmt.Errorf("failed to get switch ID") - } - switchAttrs := &saipb.SwitchAttribute{} - if err := port.mgr.PopulateAllAttributes(switchID, switchAttrs); err != nil { - return nil, fmt.Errorf("failed to get switch attributes: %v", err) - } - uSwitchID, err := strconv.ParseUint(switchID, 10, 64) - if err != nil { + if err := port.updatePortList(id); err != nil { return nil, err } - portList := switchAttrs.GetPortList() - portList = append(portList, id) - port.mgr.StoreAttributes(uSwitchID, &saipb.SwitchAttribute{ - PortList: portList, - NumberOfActivePorts: proto.Uint32(uint32(len(portList))), - }) nid, err := port.dataplane.ObjectNID(ctx, &fwdpb.ObjectNIDRequest{ ContextId: &fwdpb.ContextId{Id: port.dataplane.ID()}, From 05036ad9eb6b5e56151010fdfc1886e18f7a9804 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 2 Nov 2026 09:29:30 -0800 Subject: [PATCH 13/15] Update BUILD Fix gazelle errors --- dataplane/forwarding/fwdport/ports/BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataplane/forwarding/fwdport/ports/BUILD b/dataplane/forwarding/fwdport/ports/BUILD index a1d6a0c1..60cb2094 100644 --- a/dataplane/forwarding/fwdport/ports/BUILD +++ b/dataplane/forwarding/fwdport/ports/BUILD @@ -6,8 +6,8 @@ go_library( "common.go", "cpu.go", "doc.go", - "fake.go", "dummy.go", + "fake.go", "group.go", "kernel.go", "tap.go", From 240fe27111fa04b582ac9e4fe02b670b6c9980ca Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 2 Nov 2026 11:59:27 -0800 Subject: [PATCH 14/15] Update dummy.go --- dataplane/forwarding/fwdport/ports/dummy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/dataplane/forwarding/fwdport/ports/dummy.go b/dataplane/forwarding/fwdport/ports/dummy.go index c40d90b0..4c86225d 100644 --- a/dataplane/forwarding/fwdport/ports/dummy.go +++ b/dataplane/forwarding/fwdport/ports/dummy.go @@ -107,6 +107,7 @@ func (dummyBuilder) Build(portDesc *fwdpb.PortDesc, ctx *fwdcontext.Context) (fw p := dummyPort{ ctx: ctx, desc: portDesc, + devName: kp.Dummy.GetDeviceName(), adminState: adminState, } list := append(fwdport.CounterList, fwdaction.CounterList...) From e3849d10f72f86e884ecd8d278e5a40e197f5686 Mon Sep 17 00:00:00 2001 From: gavinz-ship-it Date: Mon, 2 Nov 2026 13:05:15 -0800 Subject: [PATCH 15/15] Update dummy.go Update comments --- dataplane/forwarding/fwdport/ports/dummy.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dataplane/forwarding/fwdport/ports/dummy.go b/dataplane/forwarding/fwdport/ports/dummy.go index 4c86225d..e75ab0c6 100644 --- a/dataplane/forwarding/fwdport/ports/dummy.go +++ b/dataplane/forwarding/fwdport/ports/dummy.go @@ -29,9 +29,8 @@ func init() { fwdport.Register(fwdpb.PortType_PORT_TYPE_DUMMY, dummyBuilder{}) } -// dummyPort is a ports that receives from and writes a linux network device. -// Note: This is a "virtual" port, it doesn't perform any IO, but represents a dummy -// port running on a remote CPU port. +// dummyPort is a ports that drops all packets written to it. It is used to +// represent a port that is not present in the forwarding plane. type dummyPort struct { fwdobject.Base desc *fwdpb.PortDesc