diff --git a/dataplane/forwarding/fwdport/ports/BUILD b/dataplane/forwarding/fwdport/ports/BUILD index 61ac66c0c..60cb2094f 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", + "dummy.go", "fake.go", - "genetlink.go", "group.go", "kernel.go", "tap.go", diff --git a/dataplane/forwarding/fwdport/ports/common.go b/dataplane/forwarding/fwdport/ports/common.go index e8cffc45c..a5dfdca97 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, diff --git a/dataplane/forwarding/fwdport/ports/dummy.go b/dataplane/forwarding/fwdport/ports/dummy.go new file mode 100644 index 000000000..e75ab0c65 --- /dev/null +++ b/dataplane/forwarding/fwdport/ports/dummy.go @@ -0,0 +1,117 @@ +// Copyright 2023 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 +// +// http://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. + +package ports + +import ( + "fmt" + + "github.com/openconfig/lemming/dataplane/forwarding/fwdaction" + "github.com/openconfig/lemming/dataplane/forwarding/fwdport" + "github.com/openconfig/lemming/dataplane/forwarding/infra/fwdcontext" + "github.com/openconfig/lemming/dataplane/forwarding/infra/fwdobject" + "github.com/openconfig/lemming/dataplane/forwarding/infra/fwdpacket" + fwdpb "github.com/openconfig/lemming/proto/forwarding" +) + +func init() { + fwdport.Register(fwdpb.PortType_PORT_TYPE_DUMMY, dummyBuilder{}) +} + +// 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 + devName string + adminState fwdpb.PortState + ctx *fwdcontext.Context // Forwarding context containing the port +} + +// Desc returns the port description proto. +func (p *dummyPort) Desc() *fwdpb.PortDesc { + return p.desc +} + +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 *dummyPort) Type() fwdpb.PortType { + return fwdpb.PortType_PORT_TYPE_DUMMY +} + +func (p *dummyPort) Cleanup() { +} + +// Update updates the actions of the port. +func (p *dummyPort) Update(upd *fwdpb.PortUpdateDesc) error { + defer func() { + p.Cleanup() + }() + return nil +} + +func (p *dummyPort) Write(fwdpacket.Packet) (fwdaction.State, error) { + return fwdaction.CONSUME, nil +} + +// Actions returns the port actions of the specified type +func (p *dummyPort) Actions(dir fwdpb.PortAction) fwdaction.Actions { + return nil +} + +// State returns the state of the port. +func (p *dummyPort) 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_DISABLED_DOWN, + AdminStatus: p.adminState, + }, + }, nil +} + +type dummyBuilder struct{} + +// Build creates a new port. +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.Dummy.GetAdminState() { + adminState = fwdpb.PortState_PORT_STATE_ENABLED_UP + } else { + adminState = fwdpb.PortState_PORT_STATE_DISABLED_DOWN + } + p := dummyPort{ + ctx: ctx, + desc: portDesc, + devName: kp.Dummy.GetDeviceName(), + adminState: adminState, + } + list := append(fwdport.CounterList, fwdaction.CounterList...) + if err := p.InitCounters("", list...); err != nil { + return nil, err + } + return &p, nil +} diff --git a/dataplane/forwarding/fwdport/ports/genetlink.go b/dataplane/forwarding/fwdport/ports/genetlink.go deleted file mode 100644 index 3669beafd..000000000 --- a/dataplane/forwarding/fwdport/ports/genetlink.go +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2023 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 -// -// http://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. - -package ports - -import ( - "fmt" - - "github.com/openconfig/lemming/dataplane/forwarding/fwdaction" - "github.com/openconfig/lemming/dataplane/forwarding/fwdport" - "github.com/openconfig/lemming/dataplane/forwarding/infra/fwdcontext" - "github.com/openconfig/lemming/dataplane/forwarding/infra/fwdobject" - "github.com/openconfig/lemming/dataplane/forwarding/infra/fwdpacket" - fwdpb "github.com/openconfig/lemming/proto/forwarding" -) - -func init() { - fwdport.Register(fwdpb.PortType_PORT_TYPE_GENETLINK, genetlinkBuilder{}) -} - -// 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 -// 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 returns the port description proto. -func (p *genetlinkPort) Desc() *fwdpb.PortDesc { - return p.desc -} - -func (p *genetlinkPort) String() string { - desc := fmt.Sprintf("Type=%v;;", fwdpb.PortType_PORT_TYPE_KERNEL, p.input, p.output) - 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 *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() - } - }() - 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) { - return &fwdpb.PortStateReply{ - Status: &fwdpb.PortInfo{ - OperStatus: fwdpb.PortState_PORT_STATE_ENABLED_UP, - AdminStatus: fwdpb.PortState_PORT_STATE_ENABLED_UP, - }, - }, nil -} - -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 -} diff --git a/dataplane/forwarding/fwdport/ports/tap.go b/dataplane/forwarding/fwdport/ports/tap.go index 275a4b5e4..dc099f004 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) } diff --git a/dataplane/saiserver/ports.go b/dataplane/saiserver/ports.go index 847579e2b..d47a4dc8e 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) { @@ -240,19 +262,17 @@ 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{ - PortType: fwdpb.PortType_PORT_TYPE_TAP, + PortType: fwdpb.PortType_PORT_TYPE_DUMMY, PortId: &fwdpb.PortId{ ObjectId: &fwdpb.ObjectId{Id: fmt.Sprint(id)}, }, - Port: &fwdpb.PortDesc_Tap{ - Tap: &fwdpb.TAPPortDesc{ + Port: &fwdpb.PortDesc_Dummy{ + Dummy: &fwdpb.DummyPortDesc{ DeviceName: dev, AdminState: req.GetAdminState(), }, @@ -264,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 @@ -306,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()}, @@ -534,6 +540,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 { diff --git a/proto/forwarding/forwarding_port.pb.go b/proto/forwarding/forwarding_port.pb.go index 690514f0b..cccca0630 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,28 +611,28 @@ func (x *FakePortDesc) GetHwLane() uint32 { return 0 } -type GenetlinkPortDesc struct { +type DummyPortDesc 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 } -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,23 +644,23 @@ 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) GetFamilyName() string { +func (x *DummyPortDesc) GetDeviceName() string { if x != nil { - return x.FamilyName + return x.DeviceName } return "" } -func (x *GenetlinkPortDesc) GetGroupName() string { +func (x *DummyPortDesc) GetAdminState() bool { if x != nil { - return x.GroupName + return x.AdminState } - return "" + return false } type PortCreateRequest struct { @@ -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,26 +1699,26 @@ 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" + - "\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" + + "\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" + + "adminState\"s\n" + "\x11PortCreateRequest\x12(\n" + "\x04port\x18\x01 \x01(\v2\x14.forwarding.PortDescR\x04port\x124\n" + "\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{ diff --git a/proto/forwarding/forwarding_port.proto b/proto/forwarding/forwarding_port.proto index 609835248..d722d0760 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,9 +76,9 @@ message FakePortDesc { uint32 hw_lane = 3; } -message GenetlinkPortDesc { - string family_name = 1; - string group_name = 2; +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; } } @@ -112,7 +112,7 @@ message PortUpdateRequest { } message PortUpdateReply { - + } // A CPUPortUpdateDesc updates the CPU port's input and output actions. @@ -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; }