Exemplo n.º 1
0
/*
 * Validate a proposed value against the iSER and/or iSCSI RFC's minimum and
 * maximum values, and set an alternate, if necessary.  Note that the value
 * 'iser_max_value" represents our implementation maximum (typically the max).
 */
static kv_status_t
iser_handle_numerical(nvpair_t *nvp, uint64_t value, const idm_kv_xlate_t *ikvx,
                      uint64_t min_value, uint64_t max_value, uint64_t iser_max_value,
                      nvlist_t *request_nvl, nvlist_t *response_nvl, nvlist_t *negotiated_nvl)
{
    kv_status_t		kvrc;
    int			nvrc;
    boolean_t		respond;

    /* Validate against standard */
    if ((value < min_value) || (value > max_value)) {
        kvrc = KV_VALUE_ERROR;
    } else {
        if (value > iser_max_value) {
            /*
             * Respond back to initiator with our value, and
             * set the return value to unset the transit bit.
             */
            value = iser_max_value;
            kvrc = KV_HANDLED_NO_TRANSIT;
            nvrc = 0;
            respond = B_TRUE;
        } else {
            /* Add this to our negotiated values */
            nvrc = nvlist_add_nvpair(negotiated_nvl, nvp);
            /* Respond if this is not a declarative */
            respond = (ikvx->ik_declarative == B_FALSE);
        }

        /* Response of Simple-value Negotiation */
        if (nvrc == 0 && respond) {
            nvrc = nvlist_add_uint64(response_nvl,
                                     ikvx->ik_key_name, value);
            /* Remove from the request (we've handled it) */
            (void) nvlist_remove_all(request_nvl,
                                     ikvx->ik_key_name);
        }
    }

    if (kvrc == KV_HANDLED_NO_TRANSIT) {
        return (kvrc);
    }

    return (idm_nvstat_to_kvstat(nvrc));
}
Exemplo n.º 2
0
void
fnvlist_add_nvpair(nvlist_t *nvl, nvpair_t *pair)
{
	VERIFY0(nvlist_add_nvpair(nvl, pair));
}