elseif

Function

The elseif command configures another matching rule to filter the routes that fail to meet the matching rules specified in the if or elseif clause of the same if condition branch.

By default, the routes that fail to meet the matching rules specified in the if or elseif clause are not further matched against other matching rules.

Format

elseif [ not ] condition-clause [ { and | or } [ not ] condition-clause ] * then

Parameters

Parameter Description Value
not

Filters routes against the opposite of the matching rule following not.

-

condition-clause

Specifies a condition clause.

For details of condition clauses, see the following descriptions:

  • Condition clause that is based on the route cost
  • Condition clause that is based on the source IP address, destination IP address, or next hop IP address of a route
  • Condition clause that is based on the tag of an OSPF or IS-IS route
  • Condition clause that is based on the Local_Pref attribute of a BGP route
  • Condition clause that is based on the AS_Path attribute of a BGP route
  • Condition clause that is based on the community attribute of a BGP route
  • Condition clause that is based on an attribute of a VPN route
  • Condition clause that is based on any of other attributes
and

Filters routes against the matching rule of the previous condition clause and the one following and.

-

or

Filters routes against the matching rule of the previous condition clause or the one following or.

-

then

Introduces the action clause configured for the routes that meet matching rules.

-

Views

Route-filter policy view

Default Level

2: Configuration level

Task Name and Operations

Task Name Operations
route-base write

Usage Guidelines

Usage Scenario

Route-filters are used to filter routes based on sets or a single element and modify route attributes of the routes that meet matching rules. To configure another matching rule to filter the routes that fail to meet the matching rules specified in the if or elseif clause of the same if condition branch, run the elseif command.

The parameters in condition clauses can be specific values or global variables referenced using $+global variable name. The parameters in a route-filter with pre-defined variables can be those defined in this route-filter.

Global variables cannot be referenced by the route attribute sets in the format of {element A, element B...}.

Prerequisites

A matching rule has been configured for the route-filter using the if command.

Follow-up Procedure

Run the apply, approve, refuse, finish, call route-filter, or break command to configure an action for the routes that meet matching rules.

Precautions

The maximum number of nested if clauses is 64. One if clause can connect 32 AND or OR Boolean operators. The keyword NOT can be consecutively nested for a maximum of 4 times.

If ip { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } is configured, the configuration applies to IPv4 prefixes, not to IPv6 prefixes, and IPv6 prefixes match the configuration by default. If IPv6 prefixes also need to be filtered, perform the following configurations:

xpl ipv6-prefix-list ipv6-list-null

end-list

if ip { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } then

if ipv6 { route-source | route-destination | next-hop } in ipv6-list-null then

finish

elseif ip { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } then

apply action-clause

endif

endif

If ipv6 { route-source | route-destination } in { ipv6-prefix-list-name | ipv6-prefix-list } is configured, the configuration applies to IPv6 prefixes, not to IPv4 prefixes, and IPv4 prefixes match the configuration by default. If IPv4 prefixes also need to be filtered, perform the following configurations:

xpl ip-prefix-list ipv4-list-null

end-list

if ipv6 { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } then

if ip { route-source | route-destination | next-hop } in ipv4-list-null then

finish

elseif ip { route-source | route-destination | next-hop } in { ip-prefix-list-name | ip-prefix-list } then

apply action-clause

endif

endif

Example

# Configure a route-filter to set the next hop IP address of the routes with MED 100 and the routes with MED 200 to 1.1.1.1 and 2.2.2.2, respectively.
<HUAWEI> system
[~HUAWEI] xpl route-filter route-filter1
[~HUAWEI-xpl-filter] if med eq 100 then
[~HUAWEI-xpl-filter-if] apply ip next-hop 1.1.1.1
[~HUAWEI-xpl-filter-if] elseif med eq 200 then
[~HUAWEI-xpl-filter-elif] apply ip next-hop 2.2.2.2
[~HUAWEI-xpl-filter-elif] endif
[~HUAWEI-xpl-filter] end-filter
Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >