datapath-windows/ovsext/Flow.c
/*
 *----------------------------------------------------------------------------
 *  _MapNlToFlowPut --
 *    Maps input netlink message to OvsFlowPut.
 *----------------------------------------------------------------------------
 */
_MapNlToFlowPut
Maps input netlink message to OvsFlowPut.
_MapNlToFlowPut Maps input netlink message to OvsFlowPut .
static NTSTATUS
_MapNlToFlowPut(POVS_MESSAGE msgIn, PNL_ATTR keyAttr,
                PNL_ATTR actionAttr, PNL_ATTR flowAttrClear,
                OvsFlowPut *mappedFlow)
{
    NTSTATUS rc = STATUS_SUCCESS;
    PNL_MSG_HDR nlMsgHdr = &(msgIn->nlMsg);
    PGENL_MSG_HDR genlMsgHdr = &(msgIn->genlMsg);
    POVS_HDR ovsHdr = &(msgIn->ovsHdr);
    UINT32 keyAttrOffset = (UINT32)((PCHAR)keyAttr - (PCHAR)nlMsgHdr);
    UINT32 tunnelKeyAttrOffset;
    UINT32 encapOffset = 0;
    PNL_ATTR keyAttrs[__OVS_KEY_ATTR_MAX] = {NULL};
    PNL_ATTR tunnelAttrs[__OVS_TUNNEL_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);
        rc = 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);
            rc = STATUS_INVALID_PARAMETER;
            goto done;
        }
    }
    if (keyAttrs[OVS_KEY_ATTR_TUNNEL]) {
        tunnelKeyAttrOffset = (UINT32)((PCHAR)
                              (keyAttrs[OVS_KEY_ATTR_TUNNEL])
                              - (PCHAR)nlMsgHdr);
        if ((NlAttrParseNested(nlMsgHdr, tunnelKeyAttrOffset,
                               NlAttrLen(keyAttrs[OVS_KEY_ATTR_TUNNEL]),
                               nlFlowTunnelKeyPolicy,
                               ARRAY_SIZE(nlFlowTunnelKeyPolicy),
                               tunnelAttrs, ARRAY_SIZE(tunnelAttrs)))
                               != TRUE) {
            OVS_LOG_ERROR("Tunnel key Attr Parsing failed for msg: %p",
                          nlMsgHdr);
            rc = STATUS_INVALID_PARAMETER;
            goto done;
        }
    }
    _MapKeyAttrToFlowPut(keyAttrs, tunnelAttrs,
                         &(mappedFlow->key));
    ASSERT(keyAttrs[OVS_KEY_ATTR_IN_PORT]);
    if (encapOffset) {
        _MapKeyAttrToFlowPut(encapAttrs, tunnelAttrs,
                             &(mappedFlow->key));
    }
    if (actionAttr) {
        mappedFlow->actionsLen = NlAttrGetSize(actionAttr);
        mappedFlow->actions = NlAttrGet(actionAttr);
    }
    mappedFlow->dpNo = ovsHdr->dp_ifindex;
    _MapNlToFlowPutFlags(genlMsgHdr, flowAttrClear,
                         mappedFlow);
done:
    return rc;
}
static NTSTATUS _MapNlToFlowPut ( POVS_MESSAGE msgIn , PNL_ATTR keyAttr , PNL_ATTR actionAttr , PNL_ATTR flowAttrClear , OvsFlowPut * mappedFlow ) { NTSTATUS rc = STATUS_SUCCESS ; PNL_MSG_HDR nlMsgHdr = & ( msgIn -> nlMsg ) ; PGENL_MSG_HDR genlMsgHdr = & ( msgIn -> genlMsg ) ; POVS_HDR ovsHdr = & ( msgIn -> ovsHdr ) ; UINT32 keyAttrOffset = ( UINT32 ) ( ( PCHAR ) keyAttr - ( PCHAR ) nlMsgHdr ) ; UINT32 tunnelKeyAttrOffset ; UINT32 encapOffset = 0 ; PNL_ATTR keyAttrs [ __OVS_KEY_ATTR_MAX ] = { NULL } ; PNL_ATTR tunnelAttrs [ __OVS_TUNNEL_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 ) ; rc = 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 ) ; rc = STATUS_INVALID_PARAMETER ; goto done ; } } if ( keyAttrs [ OVS_KEY_ATTR_TUNNEL ] ) { tunnelKeyAttrOffset = ( UINT32 ) ( ( PCHAR ) ( keyAttrs [ OVS_KEY_ATTR_TUNNEL ] ) - ( PCHAR ) nlMsgHdr ) ; if ( ( NlAttrParseNested ( nlMsgHdr , tunnelKeyAttrOffset , NlAttrLen ( keyAttrs [ OVS_KEY_ATTR_TUNNEL ] ) , nlFlowTunnelKeyPolicy , ARRAY_SIZE ( nlFlowTunnelKeyPolicy ) , tunnelAttrs , ARRAY_SIZE ( tunnelAttrs ) ) ) != TRUE ) { OVS_LOG_ERROR ( " " , nlMsgHdr ) ; rc = STATUS_INVALID_PARAMETER ; goto done ; } } _MapKeyAttrToFlowPut ( keyAttrs , tunnelAttrs , & ( mappedFlow -> key ) ) ; ASSERT ( keyAttrs [ OVS_KEY_ATTR_IN_PORT ] ) ; if ( encapOffset ) { _MapKeyAttrToFlowPut ( encapAttrs , tunnelAttrs , & ( mappedFlow -> key ) ) ; } if ( actionAttr ) { mappedFlow -> actionsLen = NlAttrGetSize ( actionAttr ) ; mappedFlow -> actions = NlAttrGet ( actionAttr ) ; } mappedFlow -> dpNo = ovsHdr -> dp_ifindex ; _MapNlToFlowPutFlags ( genlMsgHdr , flowAttrClear , mappedFlow ) ; done : return rc ; }
_MapNlToFlowPut
    Maps input netlink message to OvsFlowPut.
_MapNlToFlowPut Maps input netlink message to OvsFlowPut .
/* Get flow keys attributes */ /* Get tunnel keys attributes */ /* Map the action */