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
3 changes: 3 additions & 0 deletions common_utils/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
GNMI_GET_FAIL
GNMI_SET
GNMI_SET_FAIL
GNMI_SET_BYPASS
GNOI_REBOOT
GNOI_FACTORY_RESET
GNOI_OS_INSTALL
Expand Down Expand Up @@ -80,6 +81,8 @@ func (c CounterType) String() string {
return "GNMI set"
case GNMI_SET_FAIL:
return "GNMI set fail"
case GNMI_SET_BYPASS:
return "GNMI set bypass"
case GNOI_REBOOT:
return "GNOI reboot"
case GNOI_FACTORY_RESET:
Expand Down
13 changes: 13 additions & 0 deletions gnmi_server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/Azure/sonic-mgmt-common/translib"
"github.com/sonic-net/sonic-gnmi/common_utils"
"github.com/sonic-net/sonic-gnmi/pkg/bypass"
operationalhandler "github.com/sonic-net/sonic-gnmi/pkg/server/operational-handler"
spb "github.com/sonic-net/sonic-gnmi/proto"
spb_gnoi "github.com/sonic-net/sonic-gnmi/proto/gnoi"
Expand Down Expand Up @@ -798,6 +799,18 @@ func (s *Server) Set(ctx context.Context, req *gnmipb.SetRequest) (*gnmipb.SetRe
common_utils.IncCounter(common_utils.GNMI_SET_FAIL)
return nil, grpc.Errorf(codes.Unimplemented, "GNMI native write is disabled")
}

// Fast path: bypass validation for allowed tables/SKUs
allUpdates := append(req.GetReplace(), req.GetUpdate()...)
if resp, used, err := bypass.TrySet(ctx, prefix, req.GetDelete(), allUpdates); used {
if err != nil {
common_utils.IncCounter(common_utils.GNMI_SET_FAIL)
return nil, status.Error(codes.Internal, err.Error())
}
common_utils.IncCounter(common_utils.GNMI_SET_BYPASS)
return resp, nil
}

var targetDbName string
dc, err = sdc.NewMixedDbClient(paths, prefix, origin, encoding, s.config.ZmqPort, s.config.Vrf, &targetDbName)
authTarget = "gnmi_" + targetDbName
Expand Down
Loading