- Revision
- Scope
- 1 Introduction
- 2 Design
- 3 Test plan
Rev | Date | Author | Description |
---|---|---|---|
0.1 | 18/05/2022 | Lior Avramov | Initial version |
This document describes the high level design of IP interface loopback action feature in SONiC
Figure 1: feature overview
Figure 2: interface vlan
IP interface loopback action is a feature that allows user to change the way router handles routed packets for which egress port equals to ingress port.
- When loopback action is configured to drop, those packets will be dropped. Drppoed packets due to loopback action are counted in rif statistics, see 2.5 Statistics
- When loopback action is configured to forward, those packets will be forwarded as the pipeline defined.
This feature will support the following functionality:
- Loopback action can be set on an IP interface.
- An IP Interface can be one of the following:
- Interface vlan
- Interface Ethernet
- Interface port-channel
- Subinterface
- Loopback action can be set to "drop" or "forward".
- CLI will reject loopback action setting on a non IP interface. Interface is considered as an IP interface if it has entry in:
- VLAN_INTERFACE table for interface vlan (e.g. VLAN_INTERFACE|Vlan100)
- INTERFACE table for interface Ethernet (e.g. INTERFACE|Ethernet232)
- PORTCHANNEL_INTERFACE table for interface port-channel (e.g. PORTCHANNEL_INTERFACE|PortChannel1)
- VLAN_SUB_INTERFACE table for subinterface (e.g. VLAN_SUB_INTERFACE|Ethernet0.10)
- The configured loopback action can be viewed by show command in CLI.
- When SONiC configuration of loopback action is missing the system will behave as it is today, based on SAI behavioural model, forward the loopbacked packets.
- No changes required in Kernel.
This feature will support the following commands:
- config: set IP interface loopback action.
- show: display the configured loopback action.
This feature will provide error handling for the next situations:
- In CLI: invalid action, invalid interface, non ip interface
- In SWSS: invalid action, invalid DB operation, invalid interface
This feature will provide event logging for: loopback action set on IP interface.
Event | Severity |
---|---|
IP interface loopback action set: success | NOTICE |
IP interface loopback action set: error | ERROR |
Intfmgrd subscribes for changes in L3 interface tables VLAN_INTERFACE, INTERFACE and PORTCHANNEL_INTERFACE in config DB. Whenever there is a change in one of these tables, intfmgrd is notified. Intfmgrd then updates INTF_TABLE table in app DB. Upon change in INTF_TABLE, intforch is notified. Intforch performs validity checks, call the relevant SAI API and updates internal cache. The flow in intfmgr is based on the current interface configuration flow.
To support loopback action set on L3 interface, a new field-value pair is defined in CONFIG_DB in the following tables. Valid values are "drop" or "forward".
- VLAN_INTERFACE
VLAN_INTERFACE|interface-name
"loopback_action": action (OPTIONAL)
Example:
"VLAN_INTERFACE": {
"Vlan100": {
"loopback_action": "drop",
"mac_addr": "00:01:02:03:04:10",
"ipv6_use_link_local_only": "enable"
},
}
- INTERFACE
INTERFACE|interface-name
"loopback_action": action
Example:
"INTERFACE": {
"Ethernet248": {
"loopback_action": "forward",
"mac_addr": "00:01:02:03:04:11",
"ipv6_use_link_local_only": "enable"
},
}
- PORTCHANNEL_INTERFACE
PORTCHANNEL_INTERFACE|interface-name
"loopback_action": action
Example:
"PORTCHANNEL_INTERFACE": {
"PortChannel1": {
"loopback_action": "drop",
"mac_addr": "00:01:02:03:04:12",
"ipv6_use_link_local_only": "enable"
},
}
- VLAN_SUB_INTERFACE
VLAN_SUB_INTERFACE|interface-name
"loopback_action": action
Example:
"VLAN_SUB_INTERFACE": {
"Ethernet0.10": {
"loopback_action": "drop",
"mac_addr": "00:01:02:03:04:12",
"ipv6_use_link_local_only": "enable"
},
}
To support loopback action set on L3 interface, a new field-value pair is defined in APP DB in table INTF_TABLE.
INTF_TABLE|interface-name
"loopback_action": action
Example for interface vlan:
"INTF_TABLE": {
"Vlan100": {
"loopback_action": "drop",
"mac_addr": "00:01:02:03:04:10",
"ipv6_use_link_local_only": "enable"
Example for interface Ethernet:
"INTF_TABLE": {
"Ethernet248": {
"loopback_action": "drop",
"mac_addr": "00:01:02:03:04:11",
"ipv6_use_link_local_only": "enable"
}
}
Example for interface port-channel:
"INTF_TABLE": {
"PortChannel1": {
"loopback_action": "drop",
"mac_addr": "00:01:02:03:04:12",
"ipv6_use_link_local_only": "enable"
}
}
Example for subinterface:
"INTF_TABLE": {
"Ethernet0.10": {
"loopback_action": "drop",
"mac_addr": "00:01:02:03:04:12",
"ipv6_use_link_local_only": "enable"
}
}
When upgrading from SW image which does not support the new schema to a one which supports, the new image will not contain loopback action configuration. All existing IP interfaces will behave as today, based on SAI behavioural model, forward the loopbacked packets.
In init, loopback action configuration is being handled as part of the IP interface creation. During init, all field-value pairs of each key in INTF_TABLE table (e.g. INTF_TABLE|Vlan100) are being received in intfOrch together at once. Those field-value pairs are the interface attributes, e.g. mac address, loopback action etc.
Loopback action set on interface Ethernet flow is the same as interface vlan flow besides config DB and app DB keys being used. Used keys are defined in 2.2.1 Config DB.
Loopback action set on interface port-channel flow is the same as interface vlan flow besides config DB and app DB keys being used. Used keys are defined in 2.2.1 Config DB.
Loopback action set on subinterface flow is the same as interface vlan flow besides config DB and app DB keys being used. Used keys are defined in 2.2.1 Config DB.
If loopback action was not configured by the user, default loopback action is derived from SAI behavioral model which is forward.
The following will be used for setting IP interface loopback action.
SAI API:
sai_router_intfs_api->set_router_interface_attribute()
sai_router_intfs_api->create_router_interface()
SAI attribute:
Loopback action | SAI attribute | Attribute value |
---|---|---|
drop | SAI_ROUTER_INTERFACE_ATTR_LOOPBACK_PACKET_ACTION | SAI_PACKET_ACTION_DROP |
forward | SAI_ROUTER_INTERFACE_ATTR_LOOPBACK_PACKET_ACTION | SAI_PACKET_ACTION_FORWARD |
typedef enum _sai_router_interface_attr_t
{
/**
* @brief Packet action when a packet ingress and gets routed on the same RIF
*
* @type sai_packet_action_t
* @flags CREATE_AND_SET
* @default SAI_PACKET_ACTION_FORWARD
*/
SAI_ROUTER_INTERFACE_ATTR_LOOPBACK_PACKET_ACTION,
} sai_router_interface_attr_t;
Packets that are dropped due to loopback action will be counted in TX_ERR in IP interface statistics.
root@r-lionfish-14:/home/admin# show interfaces counters rif
IFACE RX_OK RX_BPS RX_PPS RX_ERR TX_OK TX_BPS TX_PPS TX_ERR
------------ ------- -------- -------- -------- ------- -------- -------- --------
Ethernet236 4 0.00 B/s 0.00/s 1 0 0.00 B/s 0.00/s 0
PortChannel1 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0
Vlan2 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0
Ethernet0.10 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0
A new SONiC CLI command is introduced to configure IP interface loopback action.
# Set loopback action per INTERFACE/PORTCHANNEL_INTERFACE/VLAN_INTERFACE/VLAN_SUB_INTERFACE
config interface loopback-action <intf-name> drop|forward
Examples:
config interface loopback-action Ethernet248 drop
config interface loopback-action Vlan100 forward
A new SONiC CLI command is introduced to show the configured loopback action. IP interfaces that user did not configure loopback action on them, will not be shown in the table.
show ip interfaces loopback-action
Example:
root@sonic:~# show ip interfaces loopback-action
Interface Action
------------ ----------
Ethernet232 drop
Vlan100 forward
The following YANG models will be extended in order to provide support for loopback action:
- sonic-interface.yang -> container INTERFACE
- sonic-portchannel.yang -> container PORTCHANNEL_INTERFACE
- sonic-vlan.yang -> container VLAN_INTERFACE
- sonic-vlan-sub-interface.yang -> container VLAN_SUB_INTERFACE
New leaf loopback_action will be added:
leaf loopback_action {
description "Packet action when a packet ingress and gets routed on the same IP interface";
type string {
pattern "drop|forward";
}
}
No special handling is required
Add the following test case in file sonic-swss/tests/test_interface.py.
- Create IP interface by writing to config DB
- Set loopback action on IP interface
- Check table INTF_TABLE in App DB
- Check table SAI_OBJECT_TYPE_ROUTER_INTERFACE in ASIC DB
- Create port-channel IP interface and repeat steps 2 to 4.
- Create interface VLAN and repeat steps 2 to 4.
- Create subinterface and repeat steps 2 to 4.
Add the following test in sonic-mgmt.
- Create IP interface Ethernet.
- Loopback action not configured, send traffic, verify loopbacked packets are forwarded (SAI default).
- Set loopback action to drop, send traffic, verify loopbacked packets are dropped and TX_ERR in rif counter increased.
- Save config and reboot, send traffic, verify loopbacked packets are dropped and TX_ERR in rif counter increased.
- Set loopback action to forward, send traffic, verify loopbacked packets are forwarded.
- Save config and reboot, send traffic, verify loopbacked packets are forwarded.
- Create port-channel IP interface and repeat steps 2 to 6.
- Create interface VLAN and repeat steps 2 to 6.
- Create subinterface and repeat steps 2 to 6.
- Set loopback action on non IP interface.
- Set loopback action on non existing interface.