Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default packet action trap for set user trap id #453

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 9 additions & 6 deletions dataplane/saiserver/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ func (a *acl) CreateAclEntry(ctx context.Context, req *saipb.CreateAclEntryReque
return nil, err
}

cpuPortReq := &saipb.GetSwitchAttributeRequest{Oid: switchID, AttrType: []saipb.SwitchAttr{saipb.SwitchAttr_SWITCH_ATTR_CPU_PORT}}
resp := &saipb.GetSwitchAttributeResponse{}
if err := a.mgr.PopulateAttributes(cpuPortReq, resp); err != nil {
return nil, err
}

if req.ActionSetVrf != nil {
aReq.Actions = append(aReq.Actions,
fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_SET, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_PACKET_VRF).
Expand All @@ -315,6 +321,9 @@ func (a *acl) CreateAclEntry(ctx context.Context, req *saipb.CreateAclEntryReque
aReq.Actions = append(aReq.Actions,
fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_SET, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_TRAP_ID).
WithUint64Value(req.GetActionSetUserTrapId().GetOid())).Build())
if req.ActionPacketAction == nil {
aReq.Actions = append(aReq.Actions, fwdconfig.Action(fwdconfig.TransmitAction(fmt.Sprint(resp.GetAttr().GetCpuPort())).WithImmediate(true)).Build())
}
}
if req.ActionCounter != nil {
aReq.Actions = append(aReq.Actions, &fwdpb.ActionDesc{
Expand All @@ -329,12 +338,6 @@ func (a *acl) CreateAclEntry(ctx context.Context, req *saipb.CreateAclEntryReque
})
}

cpuPortReq := &saipb.GetSwitchAttributeRequest{Oid: switchID, AttrType: []saipb.SwitchAttr{saipb.SwitchAttr_SWITCH_ATTR_CPU_PORT}}
resp := &saipb.GetSwitchAttributeResponse{}
if err := a.mgr.PopulateAttributes(cpuPortReq, resp); err != nil {
return nil, err
}

if req.ActionPacketAction != nil {
switch req.GetActionPacketAction().GetPacketAction() {
case saipb.PacketAction_PACKET_ACTION_DROP, saipb.PacketAction_PACKET_ACTION_DENY: // COPY_CANCEL and DROP
Expand Down
8 changes: 8 additions & 0 deletions dataplane/saiserver/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ func TestCreateAclEntry(t *testing.T) {
Value: binary.BigEndian.AppendUint64(nil, 1),
},
},
}, {
ActionType: fwdpb.ActionType_ACTION_TYPE_TRANSMIT,
Action: &fwdpb.ActionDesc_Transmit{
Transmit: &fwdpb.TransmitActionDesc{
Immediate: true,
PortId: &fwdpb.PortId{ObjectId: &fwdpb.ObjectId{Id: "10"}},
},
},
}},
},
}, {
Expand Down
Loading