예제 #1
0
bool nas_acl_counter_t::_validate_entry_counter (counter c_type, npu_id_t npu_id,
                                                 ndi_obj_id_t *ndi_counter_id_p) const noexcept
{
    switch (c_type) {
        case counter::PKT:
            if (!is_pkt_count_enabled ()) {
                NAS_ACL_LOG_ERR ("Packet counter NOT enabled for counter %ld\n", counter_id());
                return false;
            }
            break;
        case counter::BYTE:
            if (!is_byte_count_enabled ()) {
                NAS_ACL_LOG_ERR ("Byte counter NOT enabled for counter %ld\n", counter_id());
                return false;
            }
            break;
    }

    auto it = _ndi_obj_ids.find (npu_id);
    if (it == _ndi_obj_ids.end()) {
        NAS_ACL_LOG_ERR ("ACL Counter %ld not available in this NPU %d\n",
                         counter_id(), npu_id);
        return false;
    }

    *ndi_counter_id_p = it->second;
    return true;
}
예제 #2
0
bool nas_acl_counter_t::push_delete_obj_to_npu (npu_id_t npu_id)
{
    t_std_error rc = STD_ERR_OK;

    if ((rc = ndi_acl_counter_delete (npu_id, _ndi_obj_ids.at (npu_id)))
        != STD_ERR_OK)
    {
        throw nas::base_exception {rc, __PRETTY_FUNCTION__,
                                  std::string {"NDI Fail: Counter "}
                                  +    std::to_string (counter_id()) +
                                  std::string {" Delete Failed for NPU "}
                                  +    std::to_string (npu_id)};
    }

    NAS_ACL_LOG_DETAIL ("Switch %d: Deleted ACL counter %ld in NPU %d NDI-ID 0x%" PRIx64,
                        get_switch().id(), counter_id(), npu_id, _ndi_obj_ids.at (npu_id));

    _ndi_obj_ids.erase (npu_id);

    return true;
}
예제 #3
0
void nas_acl_action_t::dbg_dump () const
{
    NAS_ACL_LOG_DUMP ("Action: %s", name ());

    switch (_a_info.values_type) {

        case NDI_ACL_ACTION_NO_VALUE:
            break;

        case NDI_ACL_ACTION_PKT_ACTION:
            NAS_ACL_LOG_DUMP ("  Pkt action = %s", _get_pkt_action_name(_a_info.pkt_action));
            break;

        case NDI_ACL_ACTION_PORT:
        case NDI_ACL_ACTION_PORTLIST:
            NAS_ACL_LOG_DUMP ("  Port = ");
            for (auto ifindex: _ifindex_list) {
                NAS_ACL_LOG_DUMP ("%d, ", ifindex);
            }
            NAS_ACL_LOG_DUMP ("");
            break;

        case NDI_ACL_ACTION_U32:
            NAS_ACL_LOG_DUMP ("  U32 = %d",_a_info.values.u32);
            break;

        case NDI_ACL_ACTION_U16:
            NAS_ACL_LOG_DUMP ("  U16 = %d",_a_info.values.u16);
            break;

        case NDI_ACL_ACTION_U8:
            NAS_ACL_LOG_DUMP ("   U8 = %d",_a_info.values.u8);
            break;

        case NDI_ACL_ACTION_OBJ_ID:
            if (is_counter ()) {
                NAS_ACL_LOG_DUMP ("     counter id = %ld", counter_id());
                break;
            } else if (action_type() == BASE_ACL_ACTION_TYPE_REDIRECT_PORT) {
                NAS_ACL_LOG_DUMP ("    Port = ");
                for (auto ifindex: _ifindex_list) {
                    NAS_ACL_LOG_DUMP ("%d, ", ifindex);
                }
                NAS_ACL_LOG_DUMP ("");
            } else {
                for (auto nas2ndi_oid_pair: _nas2ndi_oid_tbl) {
                    NAS_ACL_LOG_DUMP ("     nas external obj id ref = %ld",nas2ndi_oid_pair.first);
                }
            }

            for (auto nas2ndi_oid_pair: _nas2ndi_oid_tbl) {
                auto& ndi_oid_tbl = nas2ndi_oid_pair.second;
                NAS_ACL_LOG_DUMP ("     External NDI obj IDs (blob): count = %ld     ",
                                   ndi_oid_tbl.size());
                for (auto& npu2ndi_oid_pair: ndi_oid_tbl) {
                    NAS_ACL_LOG_DUMP ("(NPU %d, %ld) ",
                            npu2ndi_oid_pair.first, npu2ndi_oid_pair.second );
                }
            }
            NAS_ACL_LOG_DUMP ("");
            break;

        case NDI_ACL_ACTION_MAC_ADDR:
            NAS_ACL_LOG_DUMP ("  mac_match = %0x:%0x:%0x:%0x:%0x:%0x ",
                    _a_info.values.mac[0], _a_info.values.mac[1],
                    _a_info.values.mac[2], _a_info.values.mac[3],
                    _a_info.values.mac[4], _a_info.values.mac[5]);
            break;

        case NDI_ACL_ACTION_IPV4_ADDR:
            {
                char buff [INET_ADDRSTRLEN];
                NAS_ACL_LOG_DUMP ("   ipv4 address = %s",
                                  inet_ntop (AF_INET, &_a_info.values.ipv4, buff, sizeof (buff)));
            }
            break;

        case NDI_ACL_ACTION_IPV6_ADDR:
            {
                char buff [INET6_ADDRSTRLEN];
                NAS_ACL_LOG_DUMP ("   ipv6 address = %s",
                                  inet_ntop (AF_INET6, &_a_info.values.ipv6, buff, sizeof (buff)));
            }
            break;

        default:
            break;
    }
}