diff --git a/dataplane/saiserver/routing.go b/dataplane/saiserver/routing.go index 05d93916a..9cf7cbfc3 100644 --- a/dataplane/saiserver/routing.go +++ b/dataplane/saiserver/routing.go @@ -288,7 +288,7 @@ func (nhg *nextHopGroup) updateNextHopGroupMember(ctx context.Context, nhgid, mi func (nhg *nextHopGroup) RemoveNextHopGroup(_ context.Context, req *saipb.RemoveNextHopGroupRequest) (*saipb.RemoveNextHopGroupResponse, error) { oid := req.GetOid() if _, ok := nhg.groups[oid]; !ok { - return nil, status.Errorf(codes.FailedPrecondition, "group %d does not exist", oid) + return nil, status.Errorf(codes.NotFound, "group %d does not exist", oid) } delete(nhg.groups, oid) @@ -306,6 +306,19 @@ func (nhg *nextHopGroup) RemoveNextHopGroup(_ context.Context, req *saipb.Remove return &saipb.RemoveNextHopGroupResponse{}, nil } +// RemoveNextHopGroups removes multiple next hop groups specified in the OID. +func (nhg *nextHopGroup) RemoveNextHopGroups(ctx context.Context, req *saipb.RemoveNextHopGroupsRequest) (*saipb.RemoveNextHopGroupsResponse, error) { + resp := &saipb.RemoveNextHopGroupsResponse{} + for _, req := range req.GetReqs() { + res, err := attrmgr.InvokeAndSave(ctx, nhg.mgr, nhg.RemoveNextHopGroup, req) + if err != nil { + return nil, err + } + resp.Resps = append(resp.Resps, res) + } + return resp, nil +} + // CreateNextHopGroupMember adds a next hop to a next hop group. func (nhg *nextHopGroup) CreateNextHopGroupMember(ctx context.Context, req *saipb.CreateNextHopGroupMemberRequest) (*saipb.CreateNextHopGroupMemberResponse, error) { nhgid := req.GetNextHopGroupId() @@ -357,6 +370,19 @@ func (nhg *nextHopGroup) RemoveNextHopGroupMember(ctx context.Context, req *saip return &saipb.RemoveNextHopGroupMemberResponse{}, nil } +// RemoveNextHopGroupMembers removes multiple next hop group members specified in the OID. +func (nhg *nextHopGroup) RemoveNextHopGroupMembers(ctx context.Context, r *saipb.RemoveNextHopGroupMembersRequest) (*saipb.RemoveNextHopGroupMembersResponse, error) { + resp := &saipb.RemoveNextHopGroupMembersResponse{} + for _, req := range r.GetReqs() { + res, err := attrmgr.InvokeAndSave(ctx, nhg.mgr, nhg.RemoveNextHopGroupMember, req) + if err != nil { + return nil, err + } + resp.Resps = append(resp.Resps, res) + } + return resp, nil +} + type nextHop struct { saipb.UnimplementedNextHopServer mgr *attrmgr.AttrMgr diff --git a/dataplane/saiserver/tunnel.go b/dataplane/saiserver/tunnel.go index a4835dba9..ea085a850 100644 --- a/dataplane/saiserver/tunnel.go +++ b/dataplane/saiserver/tunnel.go @@ -48,6 +48,7 @@ func (t *tunnel) CreateTunnel(ctx context.Context, req *saipb.CreateTunnelReques id := t.mgr.NextID() tunType := req.GetType() + switch tunType { case saipb.TunnelType_TUNNEL_TYPE_IPINIP: default: @@ -62,17 +63,12 @@ func (t *tunnel) CreateTunnel(ctx context.Context, req *saipb.CreateTunnelReques if ecnMode == saipb.TunnelEncapEcnMode_TUNNEL_ENCAP_ECN_MODE_STANDARD && dscpMode == saipb.TunnelDscpMode_TUNNEL_DSCP_MODE_UNIFORM_MODEL { // Copy the QOS bits from the inner IP header. actions = append(actions, fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_COPY, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_IP_QOS). WithFieldSrc(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_IP_QOS).WithFieldSrcInstance(1)).Build()) - } else { - return nil, status.Errorf(codes.InvalidArgument, "unsupported encap ecn mode %v and dscp mode: %v", ecnMode, dscpMode) } ttlMode := req.GetEncapTtlMode() - switch ttlMode { - case saipb.TunnelTtlMode_TUNNEL_TTL_MODE_UNIFORM_MODEL: // Copy the TTL from the inner IP header. + if ttlMode == saipb.TunnelTtlMode_TUNNEL_TTL_MODE_UNIFORM_MODEL { // Copy the TTL from the inner IP header. actions = append(actions, fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_COPY, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_IP_HOP). WithFieldSrc(fwdpb.PacketFieldNum_PACKET_FIELD_NUM_IP_HOP).WithFieldSrcInstance(1)).Build()) - default: - return nil, status.Errorf(codes.InvalidArgument, "unsupported ttl mode: %v", ttlMode) } if req.GetEncapSrcIp() != nil { diff --git a/dataplane/standalone/sai/tunnel.cc b/dataplane/standalone/sai/tunnel.cc index 369e2766a..96f0f3173 100644 --- a/dataplane/standalone/sai/tunnel.cc +++ b/dataplane/standalone/sai/tunnel.cc @@ -389,8 +389,8 @@ sai_status_t l_create_tunnel(sai_object_id_t *tunnel_id, sai_object_id_t switch_ lemming::dataplane::sai::CreateTunnelRequest req = convert_create_tunnel(switch_id, attr_count, attr_list); lemming::dataplane::sai::CreateTunnelResponse resp; grpc::ClientContext context; - req.set_switch_(switch_id); - + req.set_switch_(switch_id); + grpc::Status status = tunnel->CreateTunnel(&context, req, &resp); if (!status.ok()) { auto it = context.GetServerTrailingMetadata().find("traceparent");