datapath-windows/ovsext/Flow.c
/*
 *----------------------------------------------------------------------------
 *  OvsProbeSupportedFeature --
 *    Verifies if the probed feature is supported.
 *
 * Results:
 *   STATUS_SUCCESS if the probed feature is supported.
 *----------------------------------------------------------------------------
 */
OvsProbeSupportedFeature
Verifies if the probed feature is supported.

STATUS_SUCCESS if the probed feature is supported.
OvsProbeSupportedFeature Verifies if the probed feature is supported . STATUS_SUCCESS if the probed feature is supported .
static NTSTATUS
OvsProbeSupportedFeature(POVS_MESSAGE msgIn,
                         PNL_ATTR keyAttr)
{
    NTSTATUS status = STATUS_SUCCESS;
    PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg);
    UINT32 keyAttrOffset = (UINT32)((PCHAR)keyAttr - (PCHAR)nlMsgHdr);
    UINT32 encapOffset = 0;
    PNL_ATTR keyAttrs[__OVS_KEY_ATTR_MAX] = { NULL };
    PNL_ATTR encapAttrs[__OVS_KEY_ATTR_MAX] = { NULL };
    if ((NlAttrParseNested(nlMsgHdr, keyAttrOffset, NlAttrLen(keyAttr),
                           nlFlowKeyPolicy, ARRAY_SIZE(nlFlowKeyPolicy),
                           keyAttrs, ARRAY_SIZE(keyAttrs)))
                           != TRUE) {
        OVS_LOG_ERROR("Key Attr Parsing failed for msg: %p",
                      nlMsgHdr);
        status = STATUS_INVALID_PARAMETER;
        goto done;
    }
    if (keyAttrs[OVS_KEY_ATTR_ENCAP]) {
        encapOffset = (UINT32)((PCHAR)(keyAttrs[OVS_KEY_ATTR_ENCAP])
                          - (PCHAR)nlMsgHdr);
        if ((NlAttrParseNested(nlMsgHdr, encapOffset,
                               NlAttrLen(keyAttrs[OVS_KEY_ATTR_ENCAP]),
                               nlFlowKeyPolicy,
                               ARRAY_SIZE(nlFlowKeyPolicy),
                               encapAttrs, ARRAY_SIZE(encapAttrs)))
                               != TRUE) {
            OVS_LOG_ERROR("Encap Key Attr Parsing failed for msg: %p",
                          nlMsgHdr);
            status = STATUS_INVALID_PARAMETER;
            goto done;
        }
    }
    if (keyAttrs[OVS_KEY_ATTR_MPLS] &&
        keyAttrs[OVS_KEY_ATTR_ETHERTYPE]) {
        ovs_be16 ethType = NlAttrGetU16(keyAttrs[OVS_KEY_ATTR_ETHERTYPE]);
        if (OvsEthertypeIsMpls(ethType)) {
            if (!OvsCountMplsLabels(keyAttrs[OVS_KEY_ATTR_MPLS])) {
                OVS_LOG_ERROR("Maximum supported MPLS labels exceeded.");
                status = STATUS_INVALID_MESSAGE;
            }
        } else {
            OVS_LOG_ERROR("Wrong ethertype for MPLS attribute.");
            status = STATUS_INVALID_PARAMETER;
        }
    } else if (keyAttrs[OVS_KEY_ATTR_RECIRC_ID]) {
        UINT32 recircId = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_RECIRC_ID]);
        if (!recircId) {
            OVS_LOG_ERROR("Invalid recirculation ID.");
            status = STATUS_INVALID_PARAMETER;
        }
    } else if (keyAttrs[OVS_KEY_ATTR_CT_STATE]) {
        UINT32 state = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_CT_STATE]);
        if (!state) {
            status = STATUS_INVALID_PARAMETER;
            OVS_LOG_ERROR("Invalid state specified.");
        }
    } else if (keyAttrs[OVS_KEY_ATTR_CT_ZONE]) {
        UINT16 zone = (NlAttrGetU16(keyAttrs[OVS_KEY_ATTR_CT_ZONE]));
        if (!zone) {
            OVS_LOG_ERROR("Invalid zone specified.");
            status = STATUS_INVALID_PARAMETER;
        }
    } else if (keyAttrs[OVS_KEY_ATTR_CT_MARK]) {
        UINT32 mark = (NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_CT_MARK]));
        if (!mark) {
            OVS_LOG_ERROR("Invalid ct mark specified.");
            status = STATUS_INVALID_PARAMETER;
        }
    } else if (keyAttrs[OVS_KEY_ATTR_CT_LABELS]) {
        const struct ovs_key_ct_labels *ct_labels;
        ct_labels = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_LABELS]);
        if (!ct_labels->ct_labels) {
            OVS_LOG_ERROR("Invalid ct label specified.");
            status = STATUS_INVALID_PARAMETER;
        }
    } else if (keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4]) {
        const struct ovs_key_ct_tuple_ipv4 *ct_tuple_ipv4;
        ct_tuple_ipv4 = NlAttrGet(keyAttrs[OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4]);
        if (!ct_tuple_ipv4) {
            OVS_LOG_ERROR("Invalid ct_tuple_ipv4.");
            status = STATUS_INVALID_PARAMETER;
        }
    } else {
        OVS_LOG_ERROR("Feature not supported.");
        status = STATUS_INVALID_PARAMETER;
    }
done:
    return status;
}
static NTSTATUS OvsProbeSupportedFeature ( POVS_MESSAGE msgIn , PNL_ATTR keyAttr ) { NTSTATUS status = STATUS_SUCCESS ; PNL_MSG_HDR nlMsgHdr = & ( msgIn -> nlMsg ) ; UINT32 keyAttrOffset = ( UINT32 ) ( ( PCHAR ) keyAttr - ( PCHAR ) nlMsgHdr ) ; UINT32 encapOffset = 0 ; PNL_ATTR keyAttrs [ __OVS_KEY_ATTR_MAX ] = { NULL } ; PNL_ATTR encapAttrs [ __OVS_KEY_ATTR_MAX ] = { NULL } ; if ( ( NlAttrParseNested ( nlMsgHdr , keyAttrOffset , NlAttrLen ( keyAttr ) , nlFlowKeyPolicy , ARRAY_SIZE ( nlFlowKeyPolicy ) , keyAttrs , ARRAY_SIZE ( keyAttrs ) ) ) != TRUE ) { OVS_LOG_ERROR ( " " , nlMsgHdr ) ; status = STATUS_INVALID_PARAMETER ; goto done ; } if ( keyAttrs [ OVS_KEY_ATTR_ENCAP ] ) { encapOffset = ( UINT32 ) ( ( PCHAR ) ( keyAttrs [ OVS_KEY_ATTR_ENCAP ] ) - ( PCHAR ) nlMsgHdr ) ; if ( ( NlAttrParseNested ( nlMsgHdr , encapOffset , NlAttrLen ( keyAttrs [ OVS_KEY_ATTR_ENCAP ] ) , nlFlowKeyPolicy , ARRAY_SIZE ( nlFlowKeyPolicy ) , encapAttrs , ARRAY_SIZE ( encapAttrs ) ) ) != TRUE ) { OVS_LOG_ERROR ( " " , nlMsgHdr ) ; status = STATUS_INVALID_PARAMETER ; goto done ; } } if ( keyAttrs [ OVS_KEY_ATTR_MPLS ] && keyAttrs [ OVS_KEY_ATTR_ETHERTYPE ] ) { ovs_be16 ethType = NlAttrGetU16 ( keyAttrs [ OVS_KEY_ATTR_ETHERTYPE ] ) ; if ( OvsEthertypeIsMpls ( ethType ) ) { if ( ! OvsCountMplsLabels ( keyAttrs [ OVS_KEY_ATTR_MPLS ] ) ) { OVS_LOG_ERROR ( " " ) ; status = STATUS_INVALID_MESSAGE ; } } else { OVS_LOG_ERROR ( " " ) ; status = STATUS_INVALID_PARAMETER ; } } else if ( keyAttrs [ OVS_KEY_ATTR_RECIRC_ID ] ) { UINT32 recircId = NlAttrGetU32 ( keyAttrs [ OVS_KEY_ATTR_RECIRC_ID ] ) ; if ( ! recircId ) { OVS_LOG_ERROR ( " " ) ; status = STATUS_INVALID_PARAMETER ; } } else if ( keyAttrs [ OVS_KEY_ATTR_CT_STATE ] ) { UINT32 state = NlAttrGetU32 ( keyAttrs [ OVS_KEY_ATTR_CT_STATE ] ) ; if ( ! state ) { status = STATUS_INVALID_PARAMETER ; OVS_LOG_ERROR ( " " ) ; } } else if ( keyAttrs [ OVS_KEY_ATTR_CT_ZONE ] ) { UINT16 zone = ( NlAttrGetU16 ( keyAttrs [ OVS_KEY_ATTR_CT_ZONE ] ) ) ; if ( ! zone ) { OVS_LOG_ERROR ( " " ) ; status = STATUS_INVALID_PARAMETER ; } } else if ( keyAttrs [ OVS_KEY_ATTR_CT_MARK ] ) { UINT32 mark = ( NlAttrGetU32 ( keyAttrs [ OVS_KEY_ATTR_CT_MARK ] ) ) ; if ( ! mark ) { OVS_LOG_ERROR ( " " ) ; status = STATUS_INVALID_PARAMETER ; } } else if ( keyAttrs [ OVS_KEY_ATTR_CT_LABELS ] ) { const struct ovs_key_ct_labels * ct_labels ; ct_labels = NlAttrGet ( keyAttrs [ OVS_KEY_ATTR_CT_LABELS ] ) ; if ( ! ct_labels -> ct_labels ) { OVS_LOG_ERROR ( " " ) ; status = STATUS_INVALID_PARAMETER ; } } else if ( keyAttrs [ OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4 ] ) { const struct ovs_key_ct_tuple_ipv4 * ct_tuple_ipv4 ; ct_tuple_ipv4 = NlAttrGet ( keyAttrs [ OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV4 ] ) ; if ( ! ct_tuple_ipv4 ) { OVS_LOG_ERROR ( " " ) ; status = STATUS_INVALID_PARAMETER ; } } else { OVS_LOG_ERROR ( " " ) ; status = STATUS_INVALID_PARAMETER ; } done : return status ; }
OvsProbeSupportedFeature
    Verifies if the probed feature is supported.
OvsProbeSupportedFeature Verifies if the probed feature is supported .
/* Get flow keys attributes */ /* Get tunnel keys attributes */