예제 #1
0
def get_allowed_features(args):
    """
    Generates a list of allowed features if any feature restriction is passed as command-line argument, otherwise returns None
    :param args: Argument namespace from argparse
    :return: Either a list of allowed configuration features or None if all features are allowed
    """
    allowed_features = None
    if args.allowed_features is not None:
        allowed_features = feature_parser.parse_feature_list(args.allowed_features)

    if args.disabled_features is not None:
        allowed_features = filter_optional(feature_parser.parse_feature_list(args.disabled_features, disable_list=True),
                                           allowed_features)

    return allowed_features
예제 #2
0
def get_possible_args(router, allowed_features=None):
    static_route = list(
        itertools.product(router.static_routes, router.interfaces))
    ospf_area_range = list(
        itertools.product(  # TODO
            random.sample(list(router.topology.network_list()), k=3), [
                '', 'override-metric 1', ' override-metric 200',
                'override-metric 16777215'
            ], ['', 'restrict']))
    ospf_area_label_switched_path = list(
        itertools.product(['paths'], [1, 100, 65535]))
    ospf_nssa_default_lsa = list(
        itertools.product([1, 100, 16777215],
                          ['', 'metric-type 1', 'metric-type 2'],
                          ['', 'type-7']))
    ospf_nssa_no_summaries = [()]
    ospf_stub_default_metric = [(1, ), (100, ), (16777215, )]
    ospf_stub_no_summaries = [()]
    ospf_external_preference = [(0, ), (100, ), (4294967295, )]
    ospf_no_rfc_1583 = [()]
    ospf_reference_bandwidth = [(9600, ), (1000000000, ), (1000000000000, )]
    ospf_interface_ldp_synchronization = [('', 'disable')]
    ospf_interface_link_protection = [()]
    ospf_interface_metric = [(1, ), (100, ), (65535, )]
    ospf_interface_passive = [()]
    ospf_interface_priority = [(0, ), (100, ), (255, )]
    ospf_interface_te_metric = [(1, ), (100, ), (65535, )]
    ospf_redistribute_direct = [()]
    ospf_redistribute_static = [()]
    ospf_redistribute_bgp = [()]
    ospf_export = [()]
    ospf_import = [()]
    bgp_accepted_prefix_limit = [(1, ), (10, ), (4294967295, )]
    bgp_advertise_external = [('IBGP', )]
    bgp_advertise_inactive = [()]
    bgp_advertise_peer_as = [()]
    bgp_as_override = [('EBGP', )]
    bgp_cluster = []
    bgp_damping = [()]
    bgp_enforce_first_as = [()]
    bgp_local_as = list(
        itertools.product(
            [AS for AS in router.topology.ASes if AS != router.AS],
            ['', ' alias ', ' private ']))
    bgp_metric_out = []
    bgp_multihop = []
    bgp_no_client_reflect = [()]
    bgp_passive = [()]
    bgp_path_selection = [(' always-compare-med ', ),
                          (' external-router-id ', )]
    bgp_remove_private = [()]
    bgp_tcp_mss = [(2048, ), (4096, )]
    bgp_add_path = list(
        itertools.product(
            ['IBGP'], ['receive', 'send path-count 2', 'send path-count 6']
            # 'send prefix-policy add-path-policy']
        ))
    bgp_loops = [(1, ), (5, ), (10, )]
    bgp_prefix_limit = [(1, ), (10, ), (4294967295, )]
    bgp_redistribute_direct = [()]
    bgp_redistribute_static = [()]
    bgp_redistribute_ospf = [()]
    bgp_import = [()]
    bgp_export = [()]
    bgp_local_preference = [(0, ), (50, ), (4294967295, )]
    policy_as_path = []
    policy_as_path_group = []
    policy_community = []
    policy_condition = []
    policy_policy_statement = []
    policy_prefix_list = []
    policy_invert_match = []
    policy_members = []
    policy_apply_path = []
    policy_from_area = [(area, ) for area in router.topology.ospf_areas]
    policy_from_as_path = [(as_path, ) for as_path in router.as_path_lists]
    policy_from_as_path_group = []
    policy_from_color = [
        (0, ),
        (1000, )  # , (4294967295,)
    ]
    policy_from_community = [(comm, ) for comm in router.comm_lists]
    policy_from_family = [('inet', )]
    policy_from_instance = []
    policy_from_interface = [(interface, ) for interface in router.interfaces]
    policy_from_level = []
    policy_from_local_preference = [(0, ), (1000, ), (4294967295, )]
    policy_from_metric = [(1, ), (100, ), (65535, )]
    policy_from_neighbour = [(neighbour, )
                             for neighbour in router.bgp_neighbours]
    policy_from_origin = [('igp', ), ('egp', ), ('incomplete', )]
    policy_from_policy = []
    policy_from_prefix_list = [(prefix_list, )
                               for prefix_list in router.prefix_lists]
    policy_from_prefix_list_filter = list(
        itertools.product(router.prefix_lists,
                          ['exact', 'longer', 'orlonger']))
    policy_from_protocol = [('direct', ), ('static', ), ('ospf', ), ('bgp', )]
    policy_from_rib = []
    policy_from_route_filter = list(
        itertools.product([], [
            'address-mask {mask}', 'exact', 'longer', 'orlonger',
            'prefix-length-range {range}', 'through', 'upto'
        ]))
    policy_from_route_type = [('external', ), ('internal', )]
    policy_from_source_address_filter = []
    policy_from_tag = [
        (0, ),
        (100, )  # , (4294967295,)
    ]
    policy_to_level = []
    policy_to_rib = []
    policy_then_accept = [()]
    policy_then_as_path_expand = [(1, ), (16, ), (32, )]
    policy_then_as_path_prepend = [(as_path, )
                                   for as_path in router.topology.ASes]
    policy_then_color = list(
        itertools.product(['', 'add'], [0, 1000, 4294967295]))
    policy_then_color2 = list(
        itertools.product(['', 'add'], [0, 1000, 4294967295]))
    policy_then_community_add = [(comm, ) for comm in router.comm_lists]
    policy_then_community_delete = [(comm, ) for comm in router.comm_lists]
    policy_then_community_set = [(comm, ) for comm in router.comm_lists]
    policy_then_cos_next_hop_map = []
    policy_then_default_action_accept = [()]
    policy_then_default_action_reject = [()]
    policy_then_external = [(1, ), (2, )]
    policy_then_forwarding_class = []
    policy_then_install_nexthop = []
    policy_then_local_preference = [(0, ), (1000, ), (4294967295, )]
    policy_then_metric = [(1, ), (100, ), (65535, )]
    policy_then_metric_add = [(1, ), (100, ), (65535, )]
    policy_then_metric_expression = []
    policy_then_metric_igp = [(-65535, ), (-100, ), (100, ), (65535, )]
    policy_then_metric2 = [(1, ), (100, ), (65535, )]
    policy_then_metric2_expression = []
    policy_then_next_hop = [(r.router_id, ) for r in router.topology.routers
                            ] + [('peer-address', )]
    policy_then_next_hop_self = [()]
    policy_then_next_policy = []
    policy_then_next_term = []
    policy_then_origin = [('igp', ), ('egp', ), ('incomplete', )]
    policy_then_preference = [(0, ), (1000, ), (4294967295, )]
    policy_then_priority = [('low', ), ('medium', ), ('high', )]
    policy_then_reject = [()]
    policy_then_tag = [
        (0, ),
        (100, )  # , (4294967295,)
    ]

    possible_args = {
        ProtocolIndependentFeatures.STATIC_ROUTE: static_route,
        OSPFFeatures.AREA_RANGE: ospf_area_range,
        OSPFFeatures.AREA_LABEL_SWITCHED_PATH: ospf_area_label_switched_path,
        OSPFFeatures.NSSA_DEFAULT_LSA: ospf_nssa_default_lsa,
        OSPFFeatures.NSSA_NO_SUMMARIES: ospf_nssa_no_summaries,
        OSPFFeatures.STUB_DEFAULT_METRIC: ospf_stub_default_metric,
        OSPFFeatures.STUB_NO_SUMMARIES: ospf_stub_no_summaries,
        OSPFFeatures.EXTERNAL_PREFERENCE: ospf_external_preference,
        OSPFFeatures.NO_RFC_1583: ospf_no_rfc_1583,
        OSPFFeatures.REFERENCE_BANDWIDTH: ospf_reference_bandwidth,
        OSPFFeatures.INTERFACE_LDP_SYNCHRONIZATION:
        ospf_interface_ldp_synchronization,
        OSPFFeatures.INTERFACE_LINK_PROTECTION: ospf_interface_link_protection,
        OSPFFeatures.INTERFACE_METRIC: ospf_interface_metric,
        OSPFFeatures.INTERFACE_PASSIVE: ospf_interface_passive,
        OSPFFeatures.INTERFACE_PRIORITY: ospf_interface_priority,
        OSPFFeatures.INTERFACE_TE_METRIC: ospf_interface_te_metric,
        OSPFFeatures.REDISTRIBUTE_DIRECT: ospf_redistribute_direct,
        OSPFFeatures.REDISTRIBUTE_STATIC: ospf_redistribute_static,
        OSPFFeatures.REDISTRIBUTE_BGP: ospf_redistribute_bgp,
        OSPFFeatures.EXPORT: ospf_export,
        OSPFFeatures.IMPORT: ospf_import,
        BGPFeatures.ACCEPTED_PREFIX_LIMIT: bgp_accepted_prefix_limit,
        BGPFeatures.ADVERTISE_EXTERNAL: bgp_advertise_external,
        BGPFeatures.ADVERTISE_INACTIVE: bgp_advertise_inactive,
        BGPFeatures.ADVERTISE_PEER_AS: bgp_advertise_peer_as,
        BGPFeatures.AS_OVERRIDE: bgp_as_override,
        BGPFeatures.CLUSTER: bgp_cluster,
        BGPFeatures.DAMPING: bgp_damping,
        BGPFeatures.ENFORCE_FIRST_AS: bgp_enforce_first_as,
        BGPFeatures.LOCAL_AS: bgp_local_as,
        BGPFeatures.METRIC_OUT: bgp_metric_out,
        BGPFeatures.MULTIHOP: bgp_multihop,
        BGPFeatures.NO_CLIENT_REFLECT: bgp_no_client_reflect,
        BGPFeatures.PASSIVE: bgp_passive,
        BGPFeatures.PATH_SELECTION: bgp_path_selection,
        BGPFeatures.REMOVE_PRIVATE: bgp_remove_private,
        BGPFeatures.TCP_MSS: bgp_tcp_mss,
        BGPFeatures.ADD_PATH: bgp_add_path,
        BGPFeatures.LOOPS: bgp_loops,
        BGPFeatures.PREFIX_LIMIT: bgp_prefix_limit,
        BGPFeatures.REDISTRIBUTE_DIRECT: bgp_redistribute_direct,
        BGPFeatures.REDISTRIBUTE_STATIC: bgp_redistribute_static,
        BGPFeatures.REDISTRIBUTE_OSPF: bgp_redistribute_ospf,
        BGPFeatures.IMPORT: bgp_import,
        BGPFeatures.EXPORT: bgp_export,
        BGPFeatures.LOCAL_PREFERENCE: bgp_local_preference,
        PolicyFeatures.AS_PATH: policy_as_path,
        PolicyFeatures.AS_PATH_GROUP: policy_as_path_group,
        PolicyFeatures.COMMUNITY: policy_community,
        PolicyFeatures.CONDITION: policy_condition,
        PolicyFeatures.POLICY_STATEMENT: policy_policy_statement,
        PolicyFeatures.PREFIX_LIST: policy_prefix_list,
        PolicyFeatures.INVERT_MATCH: policy_invert_match,
        PolicyFeatures.MEMBERS: policy_members,
        PolicyFeatures.APPLY_PATH: policy_apply_path,
        PolicyFeatures.FROM_AREA: policy_from_area,
        PolicyFeatures.FROM_AS_PATH: policy_from_as_path,
        PolicyFeatures.FROM_AS_PATH_GROUP: policy_from_as_path_group,
        PolicyFeatures.FROM_COLOR: policy_from_color,
        PolicyFeatures.FROM_COMMUNITY: policy_from_community,
        PolicyFeatures.FROM_FAMILY: policy_from_family,
        PolicyFeatures.FROM_INSTANCE: policy_from_instance,
        PolicyFeatures.FROM_INTERFACE: policy_from_interface,
        PolicyFeatures.FROM_LEVEL: policy_from_level,
        PolicyFeatures.FROM_LOCAL_PREFERENCE: policy_from_local_preference,
        PolicyFeatures.FROM_METRIC: policy_from_metric,
        PolicyFeatures.FROM_NEIGHBOUR: policy_from_neighbour,
        PolicyFeatures.FROM_ORIGIN: policy_from_origin,
        PolicyFeatures.FROM_POLICY: policy_from_policy,
        PolicyFeatures.FROM_PREFIX_LIST: policy_from_prefix_list,
        PolicyFeatures.FROM_PREFIX_LIST_FILTER: policy_from_prefix_list_filter,
        PolicyFeatures.FROM_PROTOCOL: policy_from_protocol,
        PolicyFeatures.FROM_RIB: policy_from_rib,
        PolicyFeatures.FROM_ROUTE_FILTER: policy_from_route_filter,
        PolicyFeatures.FROM_ROUTE_TYPE: policy_from_route_type,
        PolicyFeatures.FROM_SOURCE_ADDRESS_FILTER:
        policy_from_source_address_filter,
        PolicyFeatures.FROM_TAG: policy_from_tag,
        PolicyFeatures.TO_LEVEL: policy_to_level,
        PolicyFeatures.TO_RIB: policy_to_rib,
        PolicyFeatures.THEN_ACCEPT: policy_then_accept,
        PolicyFeatures.THEN_AS_PATH_EXPAND: policy_then_as_path_expand,
        PolicyFeatures.THEN_AS_PATH_PREPEND: policy_then_as_path_prepend,
        PolicyFeatures.THEN_COLOR: policy_then_color,
        PolicyFeatures.THEN_COLOR2: policy_then_color2,
        PolicyFeatures.THEN_COMMUNITY_ADD: policy_then_community_add,
        PolicyFeatures.THEN_COMMUNITY_DELETE: policy_then_community_delete,
        PolicyFeatures.THEN_COMMUNITY_SET: policy_then_community_set,
        PolicyFeatures.THEN_COS_NEXT_HOP_MAP: policy_then_cos_next_hop_map,
        PolicyFeatures.THEN_DEFAULT_ACTION_ACCEPT:
        policy_then_default_action_accept,
        PolicyFeatures.THEN_DEFAULT_ACTION_REJECT:
        policy_then_default_action_reject,
        PolicyFeatures.THEN_EXTERNAL: policy_then_external,
        PolicyFeatures.THEN_FORWARDING_CLASS: policy_then_forwarding_class,
        PolicyFeatures.THEN_INSTALL_NEXTHOP: policy_then_install_nexthop,
        PolicyFeatures.THEN_LOCAL_PREFERENCE: policy_then_local_preference,
        PolicyFeatures.THEN_METRIC: policy_then_metric,
        PolicyFeatures.THEN_METRIC_ADD: policy_then_metric_add,
        PolicyFeatures.THEN_METRIC_EXPRESSION: policy_then_metric_expression,
        PolicyFeatures.THEN_METRIC_IGP: policy_then_metric_igp,
        PolicyFeatures.THEN_METRIC2: policy_then_metric2,
        PolicyFeatures.THEN_METRIC2_EXPRESSION: policy_then_metric2_expression,
        PolicyFeatures.THEN_NEXT_HOP: policy_then_next_hop,
        PolicyFeatures.THEN_NEXT_HOP_SELF: policy_then_next_hop_self,
        PolicyFeatures.THEN_NEXT_POLICY: policy_then_next_policy,
        PolicyFeatures.THEN_NEXT_TERM: policy_then_next_term,
        PolicyFeatures.THEN_ORIGIN: policy_then_origin,
        PolicyFeatures.THEN_PREFERENCE: policy_then_preference,
        PolicyFeatures.THEN_PRIORITY: policy_then_priority,
        PolicyFeatures.THEN_REJECT: policy_then_reject,
        PolicyFeatures.THEN_TAG: policy_then_tag
    }

    match_ospf_out = [(feature, *args) for feature in filter_optional(
        match_features_ospf_out, allowed_features)
                      for args in possible_args[feature]]
    match_ospf_in = [(feature, *args) for feature in filter_optional(
        match_features_ospf_in, allowed_features)
                     for args in possible_args[feature]]
    set_ospf_out = [
        (feature, *args)
        for feature in filter_optional(set_features_ospf_out, allowed_features)
        for args in possible_args[feature]
    ]
    set_ospf_in = [
        (feature, *args)
        for feature in filter_optional(set_features_ospf_in, allowed_features)
        for args in possible_args[feature]
    ]
    match_bgp_out = [(feature, *args) for feature in filter_optional(
        match_features_bgp_out, allowed_features)
                     for args in possible_args[feature]]
    match_bgp_in = [
        (feature, *args)
        for feature in filter_optional(match_features_bgp_in, allowed_features)
        for args in possible_args[feature]
    ]
    set_bgp_out = [
        (feature, *args)
        for feature in filter_optional(set_features_bgp_out, allowed_features)
        for args in possible_args[feature]
    ]
    set_bgp_in = [
        (feature, *args)
        for feature in filter_optional(set_features_bgp_in, allowed_features)
        for args in possible_args[feature]
    ]
    possible_args[
        PolicyFeatures.POLICY_MATCH_FEATURE_OSPF_OUT] = match_ospf_out
    possible_args[PolicyFeatures.POLICY_MATCH_FEATURE_OSPF_IN] = match_ospf_in
    possible_args[PolicyFeatures.POLICY_SET_FEATURE_OSPF_OUT] = set_ospf_out
    possible_args[PolicyFeatures.POLICY_SET_FEATURE_OSPF_IN] = set_ospf_in
    possible_args[PolicyFeatures.POLICY_MATCH_FEATURE_BGP_OUT] = match_bgp_out
    possible_args[PolicyFeatures.POLICY_MATCH_FEATURE_BGP_IN] = match_bgp_in
    possible_args[PolicyFeatures.POLICY_SET_FEATURE_BGP_OUT] = set_bgp_out
    possible_args[PolicyFeatures.POLICY_SET_FEATURE_BGP_IN] = set_bgp_in

    return possible_args
예제 #3
0
def get_possible_args(router, allowed_features=None):
    static_route = list(itertools.product(
        router.static_routes, router.interfaces
    ))
    interface_ospf_cost = [
        (1,), (100,), (65535,)
    ]
    interface_ospf_priority = [
        (0,), (10,), (255,)
    ]
    ospf_auto_cost = [
        (1,), (1000,), (4294967,)
    ]
    ospf_no_compatible_rfc1583 = [
        ()
    ]
    ospf_default_originate = list(itertools.product(
        ['', ' always '], ['', ' metric 1', ' metric 100', ' metric 1677214'],
        ['', ' metric-type 1', ' metric-type 2']
    ))
    ospf_default_metric = [
        (1,), (100,), (1677214,)
    ]
    ospf_distance = [
        (10,), (100,), (255,)
    ]
    ospf_redistribute_connected = [
        (' subnets ',),  ('',)
    ]
    ospf_redistribute_static = [
        (' subnets ',),  ('',)
    ]
    ospf_redistribute_bgp = [
        (router.AS, ' subnets '),  (router.AS, '')
    ]
    ospf_max_metric = list(itertools.product(
        ['', ' external-lsa 1', ' external-lsa 1000', ' external-lsa 16777215'], ['', ' include-stub '],
        ['', ' summary-lsa 1', ' summary-lsa 1000', ' summary-lsa 16777215']
    ))
    ospf_area_filter_list = list(itertools.product(
        router.prefix_lists, [' in ', ' out ']
    ))
    ospf_area_range = list(itertools.product(
        router.topology.networks[router], ['', ' advertise ', ' not-advertise '],
        ['', ' cost 1', ' cost 100', ' cost 16777215']
    ))
    ospf_nssa_stub_area_default_cost = [
        (1,), (100,), (16777215,)
    ]
    ospf_nssa_area_no_redistribution = [
        ()
    ]
    ospf_nssa_area_default_information_originate = list(itertools.product(
        ['', ' metric 1', ' metric 100', ' metric 1677214'],
        ['', ' metric-type 1 ', ' metric-type 2 ']
    ))
    ospf_nssa_area_no_summary = [
        ()
    ]
    ospf_nssa_area_nssa_only = [
        ()
    ]
    ospf_stub_area_no_summary = [
        ()
    ]
    bgp_always_compare_med = [
        ()
    ]
    bgp_bestpath_compare_routerid = [
        ()
    ]
    bgp_bestpath_med_confed = [
        ('',), (' missing-as-worst ',)
    ]
    bgp_bestpath_med_missing = [
        ()
    ]
    bgp_no_client_to_client_reflection = [
        ()
    ]
    bgp_default_local_preference = [
        (0,), (50,), (4294967295,)
    ]
    bgp_deterministic_med = [
        ()
    ]
    bgp_maxas_limit = [
        (1,), (10,), (254,)
    ]
    bgp_default_information_originate = [
        ()
    ]
    bgp_additional_paths_install = [
        ()
    ]
    bgp_auto_summary = [
        ()
    ]
    bgp_dampening = [
        (route_map,) for route_map in router.bgp_in_route_maps + [None]
    ]
    bgp_distance = list(itertools.product(
        [1, 100, 255], repeat=3)
    )
    bgp_redistribute_connected = [
        (None,),  *[(route_map,) for route_map in router.bgp_out_route_maps]
    ]
    bgp_redistribute_static = [
        (None,),  *[(route_map,) for route_map in router.bgp_out_route_maps]
    ]
    bgp_redistribute_ospf = [
        (None,),  *[(route_map,) for route_map in router.bgp_out_route_maps]
    ]
    bgp_synchronization = [
        ()
    ]
    bgp_table_map = [
        ('', route_map) for route_map in router.bgp_in_route_maps
    ]
    bgp_aggregate_address = list(itertools.product(
        router.topology.networks[router], ['', ' as-set '], ['', ' summary-only ']
    ))
    bgp_additional_paths = [
        (' send ',), (' receive ',), (' send receive ',)
    ]
    bgp_neighbour_maximum_prefix = [
        (1,), (100,), (10000,)
    ]
    bgp_neighbour_route_map_in = [
        (rm,) for rm in router.bgp_in_route_maps
    ]
    bgp_neighbour_route_map_out = [
        (rm,) for rm in router.bgp_out_route_maps
    ]
    bgp_neighbour_next_hop_self = [
        ()
    ]
    bgp_neighbour_capability_orf_prefix_list = [
        (' receive ',), (' send ',), (' both ',)
    ]
    bgp_neighbour_default_originate = [
        (route_map,) for route_map in router.bgp_out_route_maps + [None]
    ]
    bgp_neighbour_route_reflector_client = [
        ()
    ]
    bgp_neighbour_weight = [
        (0,), (1000,), (65535,)
    ]

    match_interface = [
        (interface,) for interface in router.interfaces
    ]
    match_ip_address = [
        (prefix_list,) for prefix_list in router.prefix_lists
    ]
    set_interface = [
        (interface,) for interface in router.interfaces
    ]
    set_ip_default_next_hop = [
        (neighbour.address,) for neighbour in router.bgp_neighbours
    ]
    set_ip_next_hop = [
        (neighbour.address,) for neighbour in router.bgp_neighbours
    ]
    set_metric = [
        (1000,), (294967295,), (-294967295,), (-1000,)
    ]
    match_as_path = [
        (as_path_list,) for as_path_list in router.as_path_lists
    ]
    match_community = list(itertools.product(
        router.comm_lists, ['', 'exact']
    ))
    set_local_preference = [
        (0,), (50,), (4294967295,)
    ]
    set_as_path = [
        (AS,) for AS in router.topology.ASes
    ]
    set_comm_list_delete = [
        (comm_list,) for comm_list in router.comm_lists
    ]
    set_community = list(itertools.product(
        [comm for (AS, comm) in router.topology.communities if AS == router.AS], ['', 'additive']
    )) + [('no-export', ''), ('no-advertise', ''), ('internet', ''), ('local-as', ''), ('none', '')]
    set_origin = [
        ('igp',), ('incomplete',), *[(f'egp {AS}',) for AS in router.topology.ASes]
    ]
    set_weight = [
        (0,), (1000,), (65535,)
    ]
    route_map_deny = [
        ()
    ]

    possible_args = {
        RouterFeatures.STATIC_ROUTE: static_route,

        OSPFFeatures.INTERFACE_OSPF_COST: interface_ospf_cost,
        OSPFFeatures.INTERFACE_OSPF_PRIORITY: interface_ospf_priority,
        OSPFFeatures.AUTO_COST: ospf_auto_cost,
        OSPFFeatures.NO_COMPATIBLE_RFC1583: ospf_no_compatible_rfc1583,
        OSPFFeatures.DEFAULT_INFORMATION_ORIGINATE: ospf_default_originate,
        OSPFFeatures.DEFAULT_METRIC: ospf_default_metric,
        OSPFFeatures.DISTANCE: ospf_distance,
        OSPFFeatures.REDISTRIBUTE_CONNECTED: ospf_redistribute_connected,
        OSPFFeatures.REDISTRIBUTE_STATIC: ospf_redistribute_static,
        OSPFFeatures.REDISTRIBUTE_BGP: ospf_redistribute_bgp,
        OSPFFeatures.MAX_METRIC: ospf_max_metric,
        OSPFFeatures.AREA_FILTER_LIST: ospf_area_filter_list,
        OSPFFeatures.AREA_RANGE: ospf_area_range,
        OSPFFeatures.NSSA_STUB_DEFAULT_COST: ospf_nssa_stub_area_default_cost,
        OSPFFeatures.NSSA_NO_REDISTRIBUTION: ospf_nssa_area_no_redistribution,
        OSPFFeatures.NSSA_DEFAULT_INFORMATION_ORIGINATE: ospf_nssa_area_default_information_originate,
        OSPFFeatures.NSSA_NO_SUMMARY: ospf_nssa_area_no_summary,
        OSPFFeatures.NSSA_ONLY: ospf_nssa_area_nssa_only,
        OSPFFeatures.STUB_NO_SUMMARY: ospf_stub_area_no_summary,

        BGPFeatures.ALWAYS_COMPARE_MED: bgp_always_compare_med,
        BGPFeatures.BESTPATH_COMPARE_ROUTERID: bgp_bestpath_compare_routerid,
        BGPFeatures.BESTPATH_MED_CONFED: bgp_bestpath_med_confed,
        BGPFeatures.BESTPATH_MED_MISSING: bgp_bestpath_med_missing,
        BGPFeatures.NO_CLIENT_TO_CLIENT_REFLECTION: bgp_no_client_to_client_reflection,
        BGPFeatures.DEFAULT_LOCAL_PREFERENCE: bgp_default_local_preference,
        BGPFeatures.DETERMINISTIC_MED: bgp_deterministic_med,
        BGPFeatures.MAXAS_LIMIT: bgp_maxas_limit,
        BGPFeatures.DEFAULT_INFORMATION_ORIGINATE: bgp_default_information_originate,
        BGPFeatures.ADDITIONAL_PATHS_INSTALL: bgp_additional_paths_install,
        BGPFeatures.AUTO_SUMMARY: bgp_auto_summary,
        BGPFeatures.BGP_DAMPENING: bgp_dampening,
        BGPFeatures.DISTANCE_BGP: bgp_distance,
        BGPFeatures.REDISTRIBUTE_CONNECTED: bgp_redistribute_connected,
        BGPFeatures.REDISTRIBUTE_STATIC: bgp_redistribute_static,
        BGPFeatures.REDISTRIBUTE_OSPF: bgp_redistribute_ospf,
        BGPFeatures.SYNCHRONIZATION: bgp_synchronization,
        BGPFeatures.TABLE_MAP: bgp_table_map,
        BGPFeatures.AGGREGATE_ADDRESS: bgp_aggregate_address,
        BGPFeatures.ADDITIONAL_PATHS: bgp_additional_paths,
        BGPFeatures.NEIGHBOUR_MAXIMUM_PREFIX: bgp_neighbour_maximum_prefix,
        BGPFeatures.NEIGHBOUR_ROUTE_MAP_IN: bgp_neighbour_route_map_in,
        BGPFeatures.NEIGHBOUR_ROUTE_MAP_OUT: bgp_neighbour_route_map_out,
        BGPFeatures.NEIGHBOUR_NEXT_HOP_SELF: bgp_neighbour_next_hop_self,
        BGPFeatures.NEIGHBOUR_CAPABILITY_ORF_PREFIX_LIST: bgp_neighbour_capability_orf_prefix_list,
        BGPFeatures.NEIGHBOUR_DEFAULT_ORIGINATE: bgp_neighbour_default_originate,
        BGPFeatures.NEIGHBOUR_ROUTE_REFLECTOR_CLIENT: bgp_neighbour_route_reflector_client,
        BGPFeatures.NEIGHBOUR_WEIGHT: bgp_neighbour_weight,

        RouteMapFeatures.MATCH_INTERFACE: match_interface,
        RouteMapFeatures.MATCH_IP_PREFIX_LIST: match_ip_address,
        RouteMapFeatures.SET_INTERFACE: set_interface,
        RouteMapFeatures.SET_IP_DEFAULT_NEXT_HOP: set_ip_default_next_hop,
        RouteMapFeatures.SET_IP_NEXT_HOP: set_ip_next_hop,
        RouteMapFeatures.SET_METRIC: set_metric,
        RouteMapFeatures.MATCH_AS_PATH_ACCESS_LIST: match_as_path,
        RouteMapFeatures.MATCH_COMMUNITY_LIST: match_community,
        RouteMapFeatures.SET_LOCAL_PREFERENCE: set_local_preference,
        RouteMapFeatures.SET_AS_PATH_PREPEND: set_as_path,
        RouteMapFeatures.SET_COMM_LIST_DELETE: set_comm_list_delete,
        RouteMapFeatures.SET_COMMUNITY: set_community,
        RouteMapFeatures.SET_ORIGIN: set_origin,
        RouteMapFeatures.SET_WEIGHT: set_weight,
        RouteMapFeatures.ROUTE_MAP_DENY: route_map_deny,
    }

    match_features_bgp_out = [
        (feature, *args) for feature in filter_optional(match_features_out, allowed_features) for args in possible_args[feature]
    ]
    match_features_bgp_in = [
        (feature, *args) for feature in filter_optional(match_features_in, allowed_features) for args in possible_args[feature]
    ]
    set_features_bgp_out = [
        (feature, *args) for feature in filter_optional(set_features_out, allowed_features) for args in possible_args[feature]
    ]
    set_features_bgp_in = [
        (feature, *args) for feature in filter_optional(set_features_in, allowed_features) for args in possible_args[feature]
    ]
    possible_args[RouteMapFeatures.MATCH_FEATURE_BGP_OUT] = match_features_bgp_out
    possible_args[RouteMapFeatures.MATCH_FEATURE_BGP_IN] = match_features_bgp_in
    possible_args[RouteMapFeatures.SET_FEATURE_BGP_OUT] = set_features_bgp_out
    possible_args[RouteMapFeatures.SET_FEATURE_BGP_IN] = set_features_bgp_in

    return possible_args
예제 #4
0
def get_random_args(router, allowed_features=None):
    static_route = (random.choice(router.static_routes), random.choice(router.interfaces))
    interface_ospf_cost = (random.randint(1, 65535),)
    interface_ospf_priority = (random.randint(0, 255),)
    ospf_auto_cost = (random.randint(1, 4294967),)
    ospf_no_compatible_rfc1583 = ()
    ospf_default_originate = (random.choice(['', ' always ']),
                              random.choice(['', ' metric ' + str(random.randint(1, 1677214))]),
                              random.choice(['', ' metric-type 1', ' metric-type 2']))
    ospf_default_metric = (random.randint(1, 1677214),)
    ospf_distance = (random.randint(10, 255),)
    ospf_redistribute_connected = (random.choice(['', ' subnets ']),)
    ospf_redistribute_static = (random.choice(['', ' subnets ']),)
    ospf_redistribute_bgp = (router.AS, random.choice(['', ' subnets ']))
    ospf_max_metric = (random.choice(['', ' external-lsa ' + str(random.randint(1, 16777215))]),
                       random.choice(['', ' include-stub ']),
                       random.choice(['', ' summary-lsa ' + str(random.randint(1, 16777215))]))
    ospf_area_filter_list = (random.choice(router.prefix_lists), random.choice([' in ', ' out ']))
    ospf_area_range = (random.choice(router.topology.networks[router]),
                       random.choice(['', ' advertise ', ' not-advertise ']),
                       random.choice(['', ' cost ' + str(random.randint(1, 16777215))]))
    ospf_nssa_stub_area_default_cost = (random.randint(1, 16777215),)
    ospf_nssa_area_no_redistribution = ()
    ospf_nssa_area_default_information_originate = (random.choice(['', ' metric ' + str(random.randint(1, 1677214))]),
                                                    random.choice(['', ' metric-type 1 ', ' metric-type 2 ']))
    ospf_nssa_area_no_summary = ()
    ospf_nssa_area_nssa_only = ()
    ospf_stub_area_no_summary = ()
    bgp_always_compare_med = ()
    bgp_bestpath_compare_routerid = ()
    bgp_bestpath_med_confed = (random.choice(['', ' missing-as-worst ']),)
    bgp_bestpath_med_missing = ()
    bgp_no_client_to_client_reflection = ()
    bgp_default_local_preference = (random.randint(0, 4294967295),)
    bgp_deterministic_med = ()
    bgp_maxas_limit = (random.randint(1, 254),)
    bgp_default_information_originate = ()
    bgp_additional_paths_install = ()
    bgp_auto_summary = ()
    bgp_dampening = (random.choice(router.bgp_in_route_maps + [None]),)
    bgp_distance = (random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
    bgp_redistribute_connected = (random.choice(router.bgp_out_route_maps + [None]),)
    bgp_redistribute_static = (random.choice(router.bgp_out_route_maps + [None]),)
    bgp_redistribute_ospf = (random.choice(router.bgp_out_route_maps + [None]),)
    bgp_synchronization = ()
    bgp_table_map = ('', random.choice(router.bgp_in_route_maps))
    bgp_aggregate_address = (random.choice(router.topology.networks[router]),
                             random.choice(['', ' as-set ']),
                             random.choice(['', ' summary-only ']))
    bgp_additional_paths = (random.choice([' send ', ' receive ', ' send receive ']))
    bgp_neighbour_maximum_prefix = (random.randint(1, 10000),)
    bgp_neighbour_route_map_in = (random.choice(router.bgp_in_route_maps),)
    bgp_neighbour_route_map_out = (random.choice(router.bgp_in_route_maps),)
    bgp_neighbour_next_hop_self = ()
    bgp_neighbour_capability_orf_prefix_list = (random.choice([' receive ', ' send ', ' both ']),)
    bgp_neighbour_default_originate = (random.choice(router.bgp_out_route_maps + [None]),)
    bgp_neighbour_route_reflector_client = ()
    bgp_neighbour_weight = (random.randint(0, 65535),)

    match_interface = (random.choice(router.interfaces),)
    match_ip_address = (random.choice(router.prefix_lists),)
    set_interface = (random.choice(router.interfaces),)
    set_ip_default_next_hop = (random.choice([neighbour.address for neighbour in router.bgp_neighbours]),)
    set_ip_next_hop = (random.choice([neighbour.address for neighbour in router.bgp_neighbours]),)
    set_metric = (random.randint(-294967295, 294967295),)
    match_as_path = (random.choice(router.as_path_lists),)
    match_community = (random.choice(router.comm_lists), random.choice(['', 'exact']))
    set_local_preference = (random.randint(0, 4294967295),)
    set_as_path = (random.choice(router.topology.ASes),)
    set_comm_list_delete = (random.choice(router.comm_lists),)
    set_community = random.choice([
        (random.choice([f'{AS}:{comm}' for (AS, comm) in router.topology.communities if AS == router.AS]),
         random.choice(['', 'additive'])),
        ('no-export', ''), ('no-advertise', ''), ('internet', ''), ('local-as', ''), ('none', '')])
    set_origin = (random.choice(['igp', 'incomplete', *[f'egp {AS}' for AS in router.topology.ASes]]),)
    set_weight = (random.randint(0, 65535),)
    route_map_deny = ()

    args = {
        RouterFeatures.STATIC_ROUTE: static_route,

        OSPFFeatures.INTERFACE_OSPF_COST: interface_ospf_cost,
        OSPFFeatures.INTERFACE_OSPF_PRIORITY: interface_ospf_priority,
        OSPFFeatures.AUTO_COST: ospf_auto_cost,
        OSPFFeatures.NO_COMPATIBLE_RFC1583: ospf_no_compatible_rfc1583,
        OSPFFeatures.DEFAULT_INFORMATION_ORIGINATE: ospf_default_originate,
        OSPFFeatures.DEFAULT_METRIC: ospf_default_metric,
        OSPFFeatures.DISTANCE: ospf_distance,
        OSPFFeatures.REDISTRIBUTE_CONNECTED: ospf_redistribute_connected,
        OSPFFeatures.REDISTRIBUTE_STATIC: ospf_redistribute_static,
        OSPFFeatures.REDISTRIBUTE_BGP: ospf_redistribute_bgp,
        OSPFFeatures.MAX_METRIC: ospf_max_metric,
        OSPFFeatures.AREA_FILTER_LIST: ospf_area_filter_list,
        OSPFFeatures.AREA_RANGE: ospf_area_range,
        OSPFFeatures.NSSA_STUB_DEFAULT_COST: ospf_nssa_stub_area_default_cost,
        OSPFFeatures.NSSA_NO_REDISTRIBUTION: ospf_nssa_area_no_redistribution,
        OSPFFeatures.NSSA_DEFAULT_INFORMATION_ORIGINATE: ospf_nssa_area_default_information_originate,
        OSPFFeatures.NSSA_NO_SUMMARY: ospf_nssa_area_no_summary,
        OSPFFeatures.NSSA_ONLY: ospf_nssa_area_nssa_only,
        OSPFFeatures.STUB_NO_SUMMARY: ospf_stub_area_no_summary,

        BGPFeatures.ALWAYS_COMPARE_MED: bgp_always_compare_med,
        BGPFeatures.BESTPATH_COMPARE_ROUTERID: bgp_bestpath_compare_routerid,
        BGPFeatures.BESTPATH_MED_CONFED: bgp_bestpath_med_confed,
        BGPFeatures.BESTPATH_MED_MISSING: bgp_bestpath_med_missing,
        BGPFeatures.NO_CLIENT_TO_CLIENT_REFLECTION: bgp_no_client_to_client_reflection,
        BGPFeatures.DEFAULT_LOCAL_PREFERENCE: bgp_default_local_preference,
        BGPFeatures.DETERMINISTIC_MED: bgp_deterministic_med,
        BGPFeatures.MAXAS_LIMIT: bgp_maxas_limit,
        BGPFeatures.DEFAULT_INFORMATION_ORIGINATE: bgp_default_information_originate,
        BGPFeatures.ADDITIONAL_PATHS_INSTALL: bgp_additional_paths_install,
        BGPFeatures.AUTO_SUMMARY: bgp_auto_summary,
        BGPFeatures.BGP_DAMPENING: bgp_dampening,
        BGPFeatures.DISTANCE_BGP: bgp_distance,
        BGPFeatures.REDISTRIBUTE_CONNECTED: bgp_redistribute_connected,
        BGPFeatures.REDISTRIBUTE_STATIC: bgp_redistribute_static,
        BGPFeatures.REDISTRIBUTE_OSPF: bgp_redistribute_ospf,
        BGPFeatures.SYNCHRONIZATION: bgp_synchronization,
        BGPFeatures.TABLE_MAP: bgp_table_map,
        BGPFeatures.AGGREGATE_ADDRESS: bgp_aggregate_address,
        BGPFeatures.ADDITIONAL_PATHS: bgp_additional_paths,
        BGPFeatures.NEIGHBOUR_MAXIMUM_PREFIX: bgp_neighbour_maximum_prefix,
        BGPFeatures.NEIGHBOUR_ROUTE_MAP_IN: bgp_neighbour_route_map_in,
        BGPFeatures.NEIGHBOUR_ROUTE_MAP_OUT: bgp_neighbour_route_map_out,
        BGPFeatures.NEIGHBOUR_NEXT_HOP_SELF: bgp_neighbour_next_hop_self,
        BGPFeatures.NEIGHBOUR_CAPABILITY_ORF_PREFIX_LIST: bgp_neighbour_capability_orf_prefix_list,
        BGPFeatures.NEIGHBOUR_DEFAULT_ORIGINATE: bgp_neighbour_default_originate,
        BGPFeatures.NEIGHBOUR_ROUTE_REFLECTOR_CLIENT: bgp_neighbour_route_reflector_client,
        BGPFeatures.NEIGHBOUR_WEIGHT: bgp_neighbour_weight,

        RouteMapFeatures.MATCH_INTERFACE: match_interface,
        RouteMapFeatures.MATCH_IP_PREFIX_LIST: match_ip_address,
        RouteMapFeatures.SET_INTERFACE: set_interface,
        RouteMapFeatures.SET_IP_DEFAULT_NEXT_HOP: set_ip_default_next_hop,
        RouteMapFeatures.SET_IP_NEXT_HOP: set_ip_next_hop,
        RouteMapFeatures.SET_METRIC: set_metric,
        RouteMapFeatures.MATCH_AS_PATH_ACCESS_LIST: match_as_path,
        RouteMapFeatures.MATCH_COMMUNITY_LIST: match_community,
        RouteMapFeatures.SET_LOCAL_PREFERENCE: set_local_preference,
        RouteMapFeatures.SET_AS_PATH_PREPEND: set_as_path,
        RouteMapFeatures.SET_COMM_LIST_DELETE: set_comm_list_delete,
        RouteMapFeatures.SET_COMMUNITY: set_community,
        RouteMapFeatures.SET_ORIGIN: set_origin,
        RouteMapFeatures.SET_WEIGHT: set_weight,
        RouteMapFeatures.ROUTE_MAP_DENY: route_map_deny,
    }

    match_features_bgp_out = random.choice([(feature, *args[feature]) for feature in filter_optional(match_features_out, allowed_features)])
    match_features_bgp_in = random.choice([(feature, *args[feature]) for feature in filter_optional(match_features_in, allowed_features)])
    set_features_bgp_out = random.choice([(feature, *args[feature]) for feature in filter_optional(set_features_out, allowed_features)])
    set_features_bgp_in = random.choice([(feature, *args[feature]) for feature in filter_optional(set_features_in, allowed_features)])
    args[RouteMapFeatures.MATCH_FEATURE_BGP_OUT] = match_features_bgp_out
    args[RouteMapFeatures.MATCH_FEATURE_BGP_IN] = match_features_bgp_in
    args[RouteMapFeatures.SET_FEATURE_BGP_OUT] = set_features_bgp_out
    args[RouteMapFeatures.SET_FEATURE_BGP_IN] = set_features_bgp_in

    return args
예제 #5
0
def get_possible_args(router, allowed_features=None):

    local_pref = [(0, ), (50, ), (4294967295, )]
    med = [('deterministic', ), ('always-compare', )]

    if router is None:
        possible_args = {
            GlobalFeatures.LOCAL_PREF: local_pref,
            GlobalFeatures.MED: med,
        }
        return possible_args

    next_hop = [(r.router_id, ) for r in router.topology.routers]
    next_hop_self = [()]
    igp_weight = [(1, ), (100, ), (65535, )]
    static_route = [(net, iface) for net in router.static_routes
                    for iface in router.interfaces]
    action_accept = [()]
    action_deny = [()]
    action_call = []
    action_jump = []
    action_local_pref = [(0, ), (50, ), (4294967295, )]
    action_metric = [(0, ), (1000, ), (65535, )]
    action_metric_internal = [()]
    action_community_add = [(f'{AS}:{comm}', )
                            for (AS, comm) in router.topology.communities
                            if AS == router.AS]
    action_community_strip = [()]
    action_community_remove = [(f'{AS}:{comm}', )
                               for (AS, comm) in router.topology.communities]
    action_as_path_prepend = [(1, ), (5, ), (10, )]
    action_as_path_remove_private = []
    action_red_community_add = []
    match_any = [()]
    match_community = [(f'{AS}:{comm}', )
                       for (AS, comm) in router.topology.communities]
    match_next_hop = list(
        set([(neighbour.address, ) for neighbour in router.bgp_neighbours]))
    match_next_hop_in = []
    match_prefix = []
    match_prefix_in = []
    match_path = [(AS, ) for AS in router.topology.ASes]

    possible_args = {
        GlobalFeatures.LOCAL_PREF: local_pref,
        GlobalFeatures.MED: med,
        RouterFeatures.NEXT_HOP: next_hop,
        RouterFeatures.NEXT_HOP_SELF: next_hop_self,
        RouterFeatures.IGP_WEIGHT: igp_weight,
        RouterFeatures.STATIC_ROUTE: static_route,
        FilterFeatures.ACTION_ACCEPT: action_accept,
        FilterFeatures.ACTION_DENY: action_deny,
        FilterFeatures.ACTION_CALL: action_call,
        FilterFeatures.ACTION_JUMP: action_jump,
        FilterFeatures.ACTION_LOCAL_PREF: action_local_pref,
        FilterFeatures.ACTION_METRIC: action_metric,
        FilterFeatures.ACTION_METRIC_INTERNAL: action_metric_internal,
        FilterFeatures.ACTION_COMMUNITY_ADD: action_community_add,
        FilterFeatures.ACTION_COMMUNITY_STRIP: action_community_strip,
        FilterFeatures.ACTION_COMMUNITY_REMOVE: action_community_remove,
        FilterFeatures.ACTION_AS_PATH_PREPEND: action_as_path_prepend,
        FilterFeatures.ACTION_AS_PATH_REMOVE_PRIVATE:
        action_as_path_remove_private,
        FilterFeatures.ACTION_RED_COMMUNITY_ADD: action_red_community_add,
        FilterFeatures.MATCH_ANY: match_any,
        FilterFeatures.MATCH_COMMUNITY: match_community,
        FilterFeatures.MATCH_NEXT_HOP: match_next_hop,
        FilterFeatures.MATCH_NEXT_HOP_IN: match_next_hop_in,
        FilterFeatures.MATCH_PREFIX: match_prefix,
        FilterFeatures.MATCH_PREFIX_IN: match_prefix_in,
        FilterFeatures.MATCH_PATH: match_path
    }

    filter_match_in = [(feature, *args) for feature in filter_optional(
        filter_match_features_in, allowed_features)
                       for args in possible_args[feature]]
    filter_match_out = [(feature, *args) for feature in filter_optional(
        filter_match_features_out, allowed_features)
                        for args in possible_args[feature]]

    filter_action_in = [(feature, *args) for feature in filter_optional(
        filter_action_features_in, allowed_features)
                        for args in possible_args[feature]]
    filter_action_out = [(feature, *args) for feature in filter_optional(
        filter_action_features_out, allowed_features)
                         for args in possible_args[feature]]

    possible_args[FilterFeatures.FILTER_MATCH_IN] = filter_match_in
    possible_args[FilterFeatures.FILTER_ACTION_IN] = filter_action_in
    possible_args[FilterFeatures.FILTER_MATCH_OUT] = filter_match_out
    possible_args[FilterFeatures.FILTER_ACTION_OUT] = filter_action_out

    return possible_args
예제 #6
0
    def get_supported_features(self, allowed_features=None):
        """
        Get all router feature triplets which are supported by this router
        :param allowed_features: Optional parameter, restricts the router feature triplets to only use configuration
        features which are in allowed_features
        :return: list of valid router feature triplets
        """
        disabled_features = self.unsupported_features

        if Protocols.STATIC not in self.enabled_protocols:
            disabled_features.extend(self.feature_list.static_features)
        if Protocols.OSPF not in self.enabled_protocols:
            disabled_features.extend(self.feature_list.ospf_features)
        if Protocols.BGP not in self.enabled_protocols:
            disabled_features.extend(self.feature_list.bgp_features)
        if not self.enable_filters:
            disabled_features.extend(self.feature_list.filter_req_features)

        if allowed_features is not None:
            allowed_features = [
                f for f in allowed_features if f not in disabled_features
            ]
        elif disabled_features:
            allowed_features = [
                f for f in self.feature_list.all_features
                if f not in disabled_features
            ]

        supported_router_features = filter_optional(
            self.feature_list.router_features, allowed_features)
        supported_interface_features = filter_optional(
            self.feature_list.interface_features, allowed_features)
        supported_ospf_area_features = filter_optional(
            self.feature_list.area_features, allowed_features)
        supported_ospf_nssa_features = filter_optional(
            self.feature_list.nssa_features, allowed_features)
        supported_ospf_stub_features = filter_optional(
            self.feature_list.stub_features, allowed_features)
        supported_bgp_neighbour_features = filter_optional(
            self.feature_list.neighbour_features, allowed_features)
        supported_filter_ospf_in_features = filter_optional(
            self.feature_list.filter_ospf_in_features, allowed_features)
        supported_filter_ospf_out_features = filter_optional(
            self.feature_list.filter_ospf_out_features, allowed_features)
        supported_filter_bgp_in_features = filter_optional(
            self.feature_list.filter_bgp_in_features, allowed_features)
        supported_filter_bgp_out_features = filter_optional(
            self.feature_list.filter_bgp_out_features, allowed_features)

        if Protocols.OSPF not in self.enabled_protocols:
            supported_filter_ospf_in_features = []
            supported_filter_ospf_out_features = []
        if Protocols.BGP not in self.enabled_protocols:
            supported_filter_bgp_in_features = []
            supported_filter_bgp_out_features = []

        nssa_areas = [
            a for a in self.ospf_areas if a.type == OSPF_Area_Type.NSSA
        ]
        stub_areas = [
            a for a in self.ospf_areas if a.type == OSPF_Area_Type.STUB
        ]
        ospf_interfaces = [i for i in self.interfaces if i.area is not None]

        filters_ospf_in = [(rm, seq) for rm in self.ospf_in_route_maps
                           for seq in rm.perm]
        filters_ospf_out = [(rm, seq) for rm in self.ospf_out_route_maps
                            for seq in rm.perm]
        filters_bgp_in = [(rm, seq) for rm in self.bgp_in_route_maps
                          for seq in rm.perm]
        filters_bgp_out = [(rm, seq) for rm in self.bgp_out_route_maps
                           for seq in rm.perm]

        interface_features = list(
            itertools.product(supported_interface_features, ospf_interfaces))
        area_features = list(
            itertools.product(supported_ospf_area_features, self.ospf_areas))
        nssa_features = list(
            itertools.product(supported_ospf_nssa_features, nssa_areas))
        stub_features = list(
            itertools.product(supported_ospf_stub_features, stub_areas))
        router_features = list(
            itertools.product(supported_router_features, [None]))
        neighbour_features = list(
            itertools.product(supported_bgp_neighbour_features,
                              [n.address for n in self.bgp_neighbours]))
        filter_ospf_in_features = list(
            itertools.product(supported_filter_ospf_in_features,
                              filters_ospf_in))
        filter_ospf_out_features = list(
            itertools.product(supported_filter_ospf_out_features,
                              filters_ospf_out))
        filter_bgp_in_features = list(
            itertools.product(supported_filter_bgp_in_features,
                              filters_bgp_in))
        if self.router_type == RouterTypes.Cisco7200:
            filter_bgp_in_features.extend([(rm.fixed_match_features[seq],
                                            (rm, seq))
                                           for (rm, seq) in filters_bgp_in])
        filter_bgp_out_features = list(
            itertools.product(supported_filter_bgp_out_features,
                              filters_bgp_out))
        if self.router_type == RouterTypes.Cisco7200:
            filter_bgp_out_features.extend([(rm.fixed_match_features[seq],
                                             (rm, seq))
                                            for (rm, seq) in filters_bgp_out])

        features = (interface_features + area_features + nssa_features +
                    stub_features + router_features + neighbour_features +
                    filter_ospf_in_features + filter_ospf_out_features +
                    filter_bgp_in_features + filter_bgp_out_features)

        return list(
            map(lambda f: (f[0], ) + f[1], itertools.product([self],
                                                             features)))