Exemplo n.º 1
0
def acl_ut_entry_create(table_id, prio=None, counter_id=None):
    global total, passed
    total.append(sys._getframe().f_code.co_name)
    filters = {
        'SRC_IP': {'addr': '23.0.0.1', 'mask': '255.0.0.255'},
        'SRC_MAC': '01:80:c2:00:00:05',
        'IPV6_FLOW_LABEL': 34456,
        'TCP_FLAGS': {'data': '0x17', 'mask': '0x3f'},
        'ECN': {'data': '0x2', 'mask': '0x2'},
        'IP_TYPE': 'IP',
        'IN_PORTS': [a_utl.get_if_name(2), a_utl.get_if_name(3)],
    }

    actions = {
        'SET_SRC_MAC': '01:00:79:08:78:BC',
        'PACKET_ACTION': 'COPY_TO_CPU',
        'REDIRECT_PORT': a_utl.get_if_name(4),
    }
    if (counter_id):
        actions['SET_COUNTER'] = counter_id

    global meter_id
    try:
        meter_id, meter_opaque = a_utl.qos_meter_create(
            m_type='BYTE', cir=300000,
            cbs=800000, pbs=900000)
    except:
        print "Meter install Failed"
        return

    actions['SET_POLICER'] = {'index': meter_id, 'data': meter_opaque}

    global mirror_id_1, mir_opq_1
    global mirror_id_2, mir_opq_2
    try:
        mirror_id_1, mir_opq_1 = a_utl.mirror_create(13)
        mirror_id_2, mir_opq_2 = a_utl.mirror_create(16)
    except:
        print "Mirror Create Failed"
        return

    actions['MIRROR_INGRESS'] = [{'index': mirror_id_1, 'data': mir_opq_1},
                                 {'index': mirror_id_2, 'data': mir_opq_2}]

    try:
        entry_id = nas_acl.create_entry(table_id=table_id, prio=prio,
                                        filter_map=filters, action_map=actions)
    except RuntimeError:
        print (sys._getframe().f_code.co_name + " - Error creating Entry")
        return None

    print (sys._getframe().f_code.co_name +
           " - Created Entry " + str(entry_id))
    raw_input("Check entry is created and Press Enter to continue...")
    passed.append(sys._getframe().f_code.co_name)
    return entry_id
Exemplo n.º 2
0
def acl_ut_entry_create(table_id, prio=None, counter_id=None):
    global total, passed
    total.append(sys._getframe().f_code.co_name)
    filters = {
        'SRC_IP': {'addr': '23.0.0.1', 'mask': '255.0.0.255'},
        'SRC_MAC': '01:80:c2:00:00:05',
        'IPV6_FLOW_LABEL': 34456,
        'TCP_FLAGS': {'data': '0x17', 'mask': '0x3f'},
        'ECN': {'data': '0x2', 'mask': '0x2'},
        'IP_TYPE': 'IP',
        'IN_PORTS': [a_utl.get_if_name(2), a_utl.get_if_name(3)],
    }

    actions = {
        'SET_SRC_MAC': '01:00:79:08:78:BC',
        'PACKET_ACTION': 'COPY_TO_CPU',
        'REDIRECT_PORT': a_utl.get_if_name(4),
    }
    if (counter_id):
        actions['SET_COUNTER'] = counter_id

    global meter_id
    try:
        meter_id, meter_opaque = a_utl.qos_meter_create(
            m_type='BYTE', cir=300000,
            cbs=800000, pbs=900000)
    except:
        print "Meter install Failed"
        return

    actions['SET_POLICER'] = {'index': meter_id, 'data': meter_opaque}

    global mirror_id_1, mir_opq_1
    global mirror_id_2, mir_opq_2
    try:
        mirror_id_1, mir_opq_1 = a_utl.mirror_create(13)
        mirror_id_2, mir_opq_2 = a_utl.mirror_create(16)
    except:
        print "Mirror Create Failed"
        return

    actions['MIRROR_INGRESS'] = [{'index': mirror_id_1, 'data': mir_opq_1},
                                 {'index': mirror_id_2, 'data': mir_opq_2}]

    try:
        entry_id = nas_acl.create_entry(table_id=table_id, prio=prio,
                                        filter_map=filters, action_map=actions)
    except RuntimeError:
        print (sys._getframe().f_code.co_name + " - Error creating Entry")
        return None

    print (sys._getframe().f_code.co_name +
           " - Created Entry " + str(entry_id))
    raw_input("Check entry is created and Press Enter to continue...")
    passed.append(sys._getframe().f_code.co_name)
    return entry_id
Exemplo n.º 3
0
    sys.exit(0)

# Create ACL Table with a list of allowed filters
tid = nas_acl.create_table(stage='INGRESS', prio=sys.argv[1],
                           allow_filters=[
                           'SRC_IP', 'SRC_MAC', 'DST_MAC', 'DST_IP', 'IP_TYPE',
                           'TCP_FLAGS', 'ECN', 'IPV6_FLOW_LABEL', 'IN_PORT'])

if len(sys.argv) < 3:
    sys.exit(0)

# Create ACL counter for this Table
counter_id = nas_acl.create_counter(table_id=tid)

# Create Mirroring sessions
mirr_id_1, mirr_opq_1 = a_utl.mirror_create(15)
mirr_id_2, mirr_opq_2 = a_utl.mirror_create(16)


#
# Example shows how various filters and actions can be specified for ACL entry create
#

filters = {
    'SRC_MAC': '01:80:c2:00:00:05',
    # Auto apply default mask
    'IPV6_FLOW_LABEL': '34456',

    'SRC_IP': {'addr': '23.0.0.1', 'mask': '255.0.0.255'},
    # Specify mask explicitly
    'TCP_FLAGS': {'data': '0x17', 'mask': '0x3f'},
Exemplo n.º 4
0
tid = nas_acl.create_table(stage='INGRESS',
                           prio=sys.argv[1],
                           allow_filters=[
                               'SRC_IP', 'SRC_MAC', 'DST_MAC', 'DST_IP',
                               'IP_TYPE', 'TCP_FLAGS', 'ECN',
                               'IPV6_FLOW_LABEL', 'IN_PORT'
                           ])

if len(sys.argv) < 3:
    sys.exit(0)

# Create ACL counter for this Table
counter_id = nas_acl.create_counter(table_id=tid)

# Create Mirroring sessions
mirr_id_1, mirr_opq_1 = a_utl.mirror_create(15)
mirr_id_2, mirr_opq_2 = a_utl.mirror_create(16)

#
# Example shows how various filters and actions can be specified for ACL entry create
#

filters = {
    'SRC_MAC': '01:80:c2:00:00:05',
    # Auto apply default mask
    'IPV6_FLOW_LABEL': '34456',
    'SRC_IP': {
        'addr': '23.0.0.1',
        'mask': '255.0.0.255'
    },
    # Specify mask explicitly