Open Ethernet Networking (OpEN) API Guide and Reference Manual
3.6.0.3
|
Multiprotocol Label Switching (MPLS) is a mechanism in high-performance telecommunications networks that directs data from one network node to the next based on short path labels rather than long network addresses, avoiding complex lookups in a routing table.
This document provides a brief description of the Multiprotocol Label Switching (MPLS) OpEN APIs. The MPLS OpEN APIs allows processes outside of the ICOS main process (switchdrvr) to access the following MPLS services:
All 'Set' operations may affect the Switch behavior and configuration.
In the main function, the sample application initializes the OpEN API RPC service by calling openapiClientRegister() and waits for the RPC service in switchdrvr to start. A Client Handle is returned by openapiClientRegister() which is used while invoking the OpEN APIs. The application then exercises the associated OpEN APIs and logs informational and/or error messages on the console. The example application runs to its completion and exits.
mpls_example.c is a sample application that demonstrates the use of the MPLS OpEN API. mpls_example is started from the command line and it has the following usage syntax:
Usage: mpls_example <test#> <arg1> <arg2> ...
routing_example.c is a sample application that demonstrates the usage of the Routing Configuration OpEN APIs. The example application has sample Open API code to add/delete static IPv4 and IPv6 unicast routes that point to MPLS tunnels. The MPLS tunnels are created/deleted as part of the Open API openapiIpRouteAdd() and openapiIpRouteDel(). For example, use the below syntax to add an IPv4 route with prefix 55.0.0.0/8, nexthop address 1.0.0.2, nexthop interface number 10, route preference of 50, and encapsulate the IP packets with one MPLS label 100. Note that the paramter '22' is for adding route and '23' is for deleting route. The parameter '1' represents IPv4 address family and '2' represents IPv6 address family.
To delete the above IPv4 route and the associated MPLS tunnel, use the below syntax:
Similarly, to add and delete IPv6 unicasts routes that point to MPLS tunnel:
openr_example.c is another OpEN Sample C Application that demonstrates the usage of Routing Configuration Open APIs. The example application has sample Open API code to add/delete dynamic IPv4 unicast routes that point to MPLS tunnels. The MPLS tunnels are created/deleted as part of the Open API openapiRouteAddVr() and openapiRouteDelVr().
CLI Command | OpEN API Reference |
---|---|
MPLS Definitions | - |
(Config)# mplsd lfdb create layer-2 <label> swap <label> <interface> <vlan> <mac> | openapiMplsLfdbGet() openapiMplsLfdbCreate() |
(Config)# mplsd lfdb create layer-2 <label> pop <interface> <vlan> <mac> | openapiMplsLfdbGet() openapiMplsLfdbCreate() |
(Config)# mplsd lfdb create layer-2 <label> last-pop <interface> <vlan> <mac> | openapiMplsLfdbGet() openapiMplsLfdbCreate() |
(Config)# mplsd lfdb create ipv4 <label> swap <sub-net/prefix-len> | openapiMplsLfdbGet() openapiMplsLfdbCreate() |
(Config)# mplsd lfdb create ipv4 <label> pop <sub-net/prefix-len> | openapiMplsLfdbGet() openapiMplsLfdbCreate() |
(Config)# mplsd lfdb create ipv6 <label> pop <sub-net/prefix-len> | openapiMplsLfdbGet() openapiMplsLfdbCreate() |
(Config)# mplsd lfdb create ipv6 <label> swap <sub-net/prefix-len> | openapiMplsLfdbGet() openapiMplsLfdbCreate() |
(Config)# mplsd lfdb delete <label> | openapiMplsLfdbGet() openapiMplsLfdbDelete() |
(Config)# mplsd lfdb delete <label>[-label] | openapiMplsLfdbGet() openapiMplsLfdbNextGet() openapiMplsLfdbDelete() |
(Config)# [no] mplsd bgp-advertise | openapiMplsBgpLabelModeSet() |
MPLS Informational Display | - |
(Routing)# show mplsd | openapiMplsGlobalStatusGet() openapiMplsBgpLabelModeGet() |
(Routing)# show mplsd lfdb all | openapiMplsLfdbNextGet() |
(Routing)# show mplsd lfdb static | openapiMplsLfdbNextGet() |
(Routing)# show mplsd lfdb dynamic | openapiMplsLfdbNextGet() |
(Routing)# show mplsd lfdb layer-2 | openapiMplsLfdbNextGet() |
(Routing)# show mplsd lfdb ipv4 | openapiMplsLfdbNextGet() |
(Routing)# show mplsd lfdb ipv6 | openapiMplsLfdbNextGet() |
(Routing)# show mplsd lfdb label <label>[-label] | openapiMplsLfdbNextGet() |
(Routing)# show mplsd tunnels <label>[-label] | openapiMplsTunnelInitiatorGetNext() |
MPLS Clear Statistics | - |
(Routing)# clear counters mplsd | openapiMplsCountersClear() |
# ./mpls
Usage: mpls_example <test#> <arg1> <arg2> ... Test 1: Set MPLS BGP label mode: mpls_example 1 <mode: 0-off/1-on> Test 2: Get MPLS BGP label mode: mpls_example 2 Test 3: Set MPLS BGP label for an interface: mpls_example 3 <interface> <IPv4 = 1/IPv6 = 2> <label id>=""> Test 4: Get MPLS BGP label for an interface: mpls_example 4 <interface> Test 5: Get MPLS global status and statistics: mpls_example 5 Test 6: Show all MPLS LFDB entries: mpls_example 6 Test 7: Create L2 MPLS LFDB entry (Action: pop): mpls_example 7 <ingress label="" id>=""> <static = 1/dynamic = 2/BGP = 3> <interface> <vlan> <mac> Test 8: Create L2 MPLS LFDB entry (Action: last pop): mpls_example 8 <ingress label="" id>=""> <static = 1/dynamic = 2/BGP = 3> <interface> <vlan> <mac> Test 9: Create L2 MPLS LFDB entry (Action: swap): mpls_example 9 <ingress label="" id>=""> <new label="" id>=""> <static = 1/dynamic = 2/BGP = 3> <interface> <vlan> <mac> Test 10: Create L3(IPv4) MPLS LFDB entry: mpls_example 10 <ingress label="" id>=""> <static = 1/dynamic = 2/BGP = 3> <pop = 1/last pop = 2/swap = 3> <subnet> <prefix> Test 11: Create L3(IPv6) MPLS LFDB entry: mpls_example 11 <ingress label="" id>=""> <static = 1/dynamic = 2/BGP = 3> <pop = 1/last pop = 2/swap = 3> <subnet> <prefix> Test 12: Delete MPLS LFDB entry: mpls_example 12 <ingress label="" id>=""> Test 13: Clear MPLS statistics: mpls_example 13 Test 14: MPLS OpEN APIs Sanity: mpls_example 14 Test 15: Show all MPLS tunnel initiator entries: mpls_example 15
# ./mpls 2
ICOS version = 1.22.5.11
MPLS BGP mode: Disable. (result = 0)
# ./mpls 5
ICOS version = 1.22.5.11
MPLS global status and statistics:
MPLS MAC....................................... 00:10:18:7F:FC:E6
LFDB Size...................................... 16384
Maximum number of MPLS tunnels................. 8188 LFDB Label Range............................... 16 - 1048575
Number of MPLS tunnels......................... 0 Number of MPLS tunnels with 1-label............ 0 Number of MPLS tunnels with 2-label............ 0 Number of MPLS tunnels with 3-label............ 0 LFDB Entries................................... 0
LFDB Entries In Hardware....................... 0
LFDB Entries Not In hardware................... 0
LFDB Static Entries............................ 0
LFDB Dynamic Entries........................... 0
LFDB Layer-2 Entries........................... 0
LFDB IPv4 Entries.............................. 0
LFDB IPv6 Entries.............................. 0
LFDB Dynamic Insert Failure Count.............. 0
LFDB High Water Mark........................... 1
ECMP In-Use/High/Max........................... 0/0/128
LFDB Lookup failure packets.................... 0
# ./mpls 7 100 1 5 12 00:10:18:7F:FC:00
ICOS version = 1.22.5.11
MPLS label 100 is created successfully. (result = 0)
# ./mpls 7 107 2 5 12 00:10:18:7F:FC:00
ICOS version = 1.22.5.11
MPLS label 107 is created successfully. (result = 0)
# ./mpls 7 110 2 7 12 00:10:18:7F:FC:00
ICOS version = 1.22.5.11
MPLS label 110 is created successfully. (result = 0)
# ./mpls 6
ICOS version = 1.22.5.11
Label:100 Protocol:Static Type:Layer-2 Subnet:N/A
Egress Label Action:pop Egress Label:N/A
Egress Interface Port:5 Vlan:12 MAC:00:10:18:7F:FC:00
Hardware Status:Not Inserted Not Inserted Reason:No VLAN
Byte Count:0 Packet Count:0
Label:107 Protocol:BGP Type:Layer-2 Subnet:N/A
Egress Label Action:pop Egress Label:N/A
Egress Interface Port:5 Vlan:12 MAC:00:10:18:7F:FC:00
Hardware Status:Not Inserted Not Inserted Reason:No VLAN
Byte Count:0 Packet Count:0
Label:110 Protocol:BGP Type:Layer-2 Subnet:N/A
Egress Label Action:pop Egress Label:N/A
Egress Interface Port:7 Vlan:12 MAC:00:10:18:7F:FC:00
Hardware Status:Not Inserted Not Inserted Reason:No VLAN
Byte Count:0 Packet Count:0
# ./mpls_example 14
ICOS version = 1.22.5.11
Testing MPLS OpEN APIs sanity:
Testing openapiMplsCountersClear():
NULL Client Handle. (result = -22)
openapiMplsCountersClear() sanity successful.
Testing openapiMplsGlobalStatusGet():
NULL Client Handle. (result = -22)
NULL parameter to MPLS global statue get. (result = -22)
openapiMplsGlobalStatusGet() sanity successful.
Testing openapiMplsBgpLabelModeGet():
NULL Client Handle. (result = -22)
NULL parameter to MPLS BGP label mode get. (result = -22)
openapiMplsBgpLabelModeGet() sanity successful.
Testing openapiMplsBgpLabelModeSet():
NULL Client Handle. (result = -22)
Set invalid mode parameter. (result = -22)
openapiMplsBgpLabelModeSet() sanity successful.
Testing openapiMplsLfdbGet():
NULL Client Handle. (result = -22)
NULL parameter to MPLS label entry. (result = -22)
openapiMplsLfdbGet() sanity successful.
Testing openapiMplsLfdbNextGet():
NULL Client Handle. (result = -22)
NULL parameter to MPLS label entry. (result = -22)
openapiMplsLfdbNextGet() sanity successful.
Testing openapiMplsLfdbCreate():
NULL Client Handle. (result = -22)
NULL parameter to MPLS label entry. (result = -22)
openapiMplsLfdbCreate() sanity successful.
Testing openapiMplsLfdbDelete():
NULL Client Handle. (result = -22)
Invalid label ID is specifeid. (result = -29)
openapiMplsLfdbDelete() sanity successful.
# ./mpls_example 15
ICOS version = 8.11.11.1
Next Hop IP Address: 1.0.0.2
MPLS Label(s): 666 777 888
Egress Port: 29 Vlan: 4093 MAC: 00:00:00:01:02:03
Seconds since last update: 902 Number of Routes: 2