From a27e984beab409c1c114a03dfe928b014d8826e4 Mon Sep 17 00:00:00 2001 From: liora Date: Sun, 22 May 2022 10:04:40 +0300 Subject: [PATCH 01/10] Add IP interface loopback action design --- .../images/feature_overview.svg | 3 + .../loopback-action/images/interface_vlan.svg | 3 + .../ip-interface-loopback-action-design.md | 318 ++++++++++++++++++ 3 files changed, 324 insertions(+) create mode 100755 doc/ip-interface/loopback-action/images/feature_overview.svg create mode 100755 doc/ip-interface/loopback-action/images/interface_vlan.svg create mode 100644 doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md diff --git a/doc/ip-interface/loopback-action/images/feature_overview.svg b/doc/ip-interface/loopback-action/images/feature_overview.svg new file mode 100755 index 0000000000..3518d45921 --- /dev/null +++ b/doc/ip-interface/loopback-action/images/feature_overview.svg @@ -0,0 +1,3 @@ + + +
5.5.5.5 via 1.1.1.2
5.5.5.5 via 1.1.1.2
route table
route table
dip: 5.5.5.5
sip: any
dip: 5.5.5.5...
packet
packet
1.1.1.1/24
1.1.1.1/24
1.1.1.2/24
1.1.1.2/24
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/ip-interface/loopback-action/images/interface_vlan.svg b/doc/ip-interface/loopback-action/images/interface_vlan.svg new file mode 100755 index 0000000000..70143e6b1f --- /dev/null +++ b/doc/ip-interface/loopback-action/images/interface_vlan.svg @@ -0,0 +1,3 @@ + + +CLIset VLAN_INTERFACE|Vlan100{loopback_action:drop}ConfigDBreturn
verify user input 
verify user...
IntfMgrdnotify VLAN_INTERFACE|Vlan100{loopback_action:drop}
postpone handling until iface exist in state DB
postpone handling unt...
AppDBset INTF_TABLE|Vlan100{loopback_action:drop}returnSAIIntfOrchnotify INTF_TABLE|Vlan100{loopback_action:drop}call set_router_interface_attribute SAI_ROUTER_INTERFACE_ATTR_LOOPBACK_PACKET_ACTIONreturn
cache update
log error if failed
cache update...
Loopback action set on Interface VLAN
Loopback action set on Interface VLAN
CLI
CLI
ConfigDB
ConfigDB
IntfMgrd
IntfMgrd
AppDB
AppDB
IntfOrch
IntfOrch
SAI
SAI
verify data
cache check
If already set, do nothing
verify data...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md new file mode 100644 index 0000000000..b918f55b19 --- /dev/null +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -0,0 +1,318 @@ +# SONiC IP Interface Loopback Action +## High level design document +## Table of contents +- [Revision](#revision) +- [Scope](#scope) +- [1 Introduction](#1-introduction) + - [1.1 Feature overview](#11-feature-overview) + - [1.2 Requirements](#12-requirements) + - [1.2.1 Functionality](#121-functionality) + - [1.2.2 Command interface](#122-command-interface) + - [1.2.3 Error handling](#123-error-handling) + - [1.2.4 Event logging](#124-event-logging) +- [2 Design](#2-design) + - [2.1 Overview](#21-overview) + - [2.2 DB schema](#22-db-schema) + - [2.2.1 Config DB](#221-config-db) + - [2.2.2 App DB](#222-app-db) + - [2.2.3 Configuration migration](#223-configuration-migration) + - [2.3 Flows](#23-flows) + - [2.3.1 Loopback action set interface vlan](#231-loopback-action-set-interface-vlan) + - [2.3.1.1 Handle set in runtime](#2311-handle-set-in-runtime) + - [2.3.1.2 Handle set in init](#2312-handle-set-in-init) + - [2.3.2 Loopback action set interface Ethernet](#232-loopback-action-set-interface-ethernet) + - [2.3.3 Loopback action set interface port-channel](#233-loopback-action-set-interface-port-channel) + - [2.3.4 IP interface creation](#234-ip-interface-creation) + - [2.4 SAI](#24-sai) + - [2.5 Statistics](#25-statistics) + - [2.6 CLI](#26-cli) + - [2.6.1 Config command](#261-config-command) + - [2.6.2 Show command](#262-show-command) + - [2.7 YANG model](#27-yang-model) + - [2.8 Warm/Fast boot](#28-warmfast-boot) +- [3 Test plan](#3-test-plan) + - [3.1 Unit tests via VS](#31-unit-tests-via-vs) + - [3.2 System tests](#32-system-tests) +- [4 Open items](#4-open-items) + +## Revision +| Rev | Date | Author | Description | +|:---:|:----------:|:--------------:|:----------------| +| 0.1 | 18/05/2022 | Lior Avramov | Initial version | + +## Scope +This document describes the high level design of IP interface loopback action feature in SONiC + +## List of figures +[Figure 1: feature overview](#figure-1-feature-overview) +[Figure 2: interface vlan](#figure-2-interface-vlan) + +# 1 Introduction +## 1.1 Feature overview +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. +1. When loopback action is configured to drop, those packets will be dropped. +2. When loopback action is configured to forward, those packets will be forwarded. + +![feature overview](images/feature_overview.svg "Figure 1: feature overview") +###### Figure 1: feature overview + +## 1.2 Requirements +### 1.2.1 Functionality +**This feature will support the following functionality:** +1. Loopback action can be set on IP interface. +2. IP Interface can be one of the following: + 1. Interface vlan + 2. Interface Ethernet + 3. Interface port-channel +3. Loopback action can be set to "drop" or "forward". +4. CLI does not allow to set loopback action on non IP interface. Interface is considered as IP interface if it has entry in: + 1. VLAN_INTERFACE table for interface vlan (e.g. VLAN_INTERFACE|Vlan100) + 2. INTERFACE table for interface Ethernet (e.g. INTERFACE|Ethernet232) + 3. PORTCHANNEL_INTERFACE table for interface port-channel (e.g. PORTCHANNEL_INTERFACE|PortChannel1) +5. The configured loopback action can be viewed by show command in CLI. + +### 1.2.2 Command interface +**This feature will support the following commands:** +1. config: set IP interface loopback action. +2. show: display the configured loopback action. + +### 1.2.3 Error handling +**This feature will provide error handling for the next situations:** +1. In CLI: invalid action, invalid interace, non ip interface +2. In SWSS: invalid action, invalid interace, non ip interface, invalid DB operation + +### 1.2.4 Event logging +**This feature will provide event logging for:** loopback action set on IP interface. + +###### Table 1: Event logging +| Event | Severity | +|:------------------------------------------|:---------| +| IP interface loopback action set: success | NOTICE | +| IP interface loopback action set: error | ERROR | + +# 2 Design +## 2.1 Overview +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. There is an existing mechanizm in intforch that postpones handling of changes in INTF_TABLE until interface is ready, we will use it. + +## 2.2 DB schema +### 2.2.1 Config DB +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". + +1. 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", + "mpls": "enable" + }, +} +``` + +2. INTERFACE +``` +INTERFACE|interface-name + "loopback_action": action +``` +Example: + +``` +"INTERFACE": { + "Ethernet248": { + "loopback_action": "forward", + "mac_addr": "00:01:02:03:04:11", + "mpls": "enable" + }, +} +``` +3. PORTCHANNEL_INTERFACE +``` +PORTCHANNEL_INTERFACE|interface-name + "loopback_action": action +``` +Example: +``` +"PORTCHANNEL_INTERFACE": { + "PortChannel1": { + "loopback_action": "drop", + "mac_addr": "00:01:02:03:04:12", + "mpls": "enable" + }, +} +``` + +### 2.2.2 App DB +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", + "mpls": "enable" + } + } +``` +Example for interface Ethernet: +``` + "INTF_TABLE": { + "Ethernet248": { + "loopback_action": "drop", + "mac_addr": "00:01:02:03:04:11", + "mpls": "enable" + } + } +``` +Example for interface port-channel: +``` + "INTF_TABLE": { + "PortChannel1": { + "loopback_action": "drop", + "mac_addr": "00:01:02:03:04:12", + "mpls": "enable" + } + } +``` + +### 2.2.3 Configuration migration +No special handling is required + +## 2.3 Flows + +### 2.3.1 Loopback action set interface vlan +#### 2.3.1.1 Handle set in runtime +![interface vlan](images/interface_vlan.svg "Figure 2: interface vlan") +###### Figure 2: interface vlan + +#### 2.3.1.2 Handle set in init +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, mpls enable, loopback action etc. + +### 2.3.2 Loopback action set interface Ethernet +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](#221-config-db). + +### 2.3.3 Loopback action set interface port-channel +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](#221-config-db). + +### 2.3.4 IP interface creation +If loopback action was not configured by the user, default loopback action is derived from SAI behavioral model which is forward. + +## 2.4 SAI +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: +###### Table 2: 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; +``` + +## 2.5 Statistics +Packets that will dropped due to loopback action will be counted in RX_ERR in IP interface statistics. +``` +root@sonic:~# show interfaces counters rif + IFACE RX_OK RX_BPS RX_PPS RX_ERR TX_OK TX_BPS TX_PPS TX_ERR +----------- ------- -------- -------- -------- ------- -------- -------- -------- +Ethernet232 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0 +``` + +## 2.6 CLI +### 2.6.1 Config command + +The following command will be added to configure IP interface loopback action: +``` +config interface loopback-action +``` +action options: "drop", "forward" + +Examples: +``` +config interface loopback-action Ethernet248 drop +config interface loopback-action Vlan100 forward +``` + +### 2.6.2 Show command +The following command will be added 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 +``` + +## 2.7 YANG model +The following YANG models will be extended in order to provide support for loopback action: +1. sonic-interface.yang -> container INTERFACE +2. sonic-portchannel.yang -> container PORTCHANNEL_INTERFACE +3. sonic-vlan.yang -> container VLAN_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"; + } +} +``` + +## 2.8 Warm/Fast boot +No special handling is required + +# 3 Test plan +## 3.1 Unit tests via VS +Add the following test cases in file sonic-swss/tests/test_interface.py. +Test case will perform the following: +1. Create IP interface by writing to config DB +2. Set loopback action on IP interface +3. Check table INTF_TABLE in App DB +4. Check table SAI_OBJECT_TYPE_ROUTER_INTERFACE in ASIC DB +5. Create port-channel IP interface and repeat steps 2 to 4. +6. Create interface VLAN and repeat steps 2 to 4. + +## 3.2 System tests +Will be added after review with verification team. + +# 4 Open items +1. Minigraph for MSFT. From 3cee898924c0ba8285e491b877c3954069683dc5 Mon Sep 17 00:00:00 2001 From: liora Date: Mon, 23 May 2022 17:51:09 +0300 Subject: [PATCH 02/10] Fix review comments --- .../ip-interface-loopback-action-design.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index b918f55b19..cd8654c38c 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -50,7 +50,7 @@ This document describes the high level design of IP interface loopback action fe # 1 Introduction ## 1.1 Feature overview 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. -1. When loopback action is configured to drop, those packets will be dropped. +1. 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](#25-statistics) 2. When loopback action is configured to forward, those packets will be forwarded. ![feature overview](images/feature_overview.svg "Figure 1: feature overview") @@ -59,8 +59,8 @@ IP interface loopback action is a feature that allows user to change the way rou ## 1.2 Requirements ### 1.2.1 Functionality **This feature will support the following functionality:** -1. Loopback action can be set on IP interface. -2. IP Interface can be one of the following: +1. Loopback action can be set on an IP interface. +2. An IP Interface can be one of the following: 1. Interface vlan 2. Interface Ethernet 3. Interface port-channel @@ -242,7 +242,7 @@ typedef enum _sai_router_interface_attr_t ``` ## 2.5 Statistics -Packets that will dropped due to loopback action will be counted in RX_ERR in IP interface statistics. +Packets that are dropped due to loopback action will be counted in TX_ERR in IP interface statistics. ``` root@sonic:~# show interfaces counters rif IFACE RX_OK RX_BPS RX_PPS RX_ERR TX_OK TX_BPS TX_PPS TX_ERR @@ -316,3 +316,4 @@ Will be added after review with verification team. # 4 Open items 1. Minigraph for MSFT. +2. VLAN sub interface not covered. From dd25e073284c26c7381c1db8cd77a7c8ff6c8799 Mon Sep 17 00:00:00 2001 From: liora Date: Mon, 23 May 2022 17:54:44 +0300 Subject: [PATCH 03/10] Fix more review comments --- .../loopback-action/ip-interface-loopback-action-design.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index cd8654c38c..1cd54bb954 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -65,7 +65,7 @@ IP interface loopback action is a feature that allows user to change the way rou 2. Interface Ethernet 3. Interface port-channel 3. Loopback action can be set to "drop" or "forward". -4. CLI does not allow to set loopback action on non IP interface. Interface is considered as IP interface if it has entry in: +4. CLI will reject loopback action setting on a non IP interface. Interface is considered as an IP interface if it has entry in: 1. VLAN_INTERFACE table for interface vlan (e.g. VLAN_INTERFACE|Vlan100) 2. INTERFACE table for interface Ethernet (e.g. INTERFACE|Ethernet232) 3. PORTCHANNEL_INTERFACE table for interface port-channel (e.g. PORTCHANNEL_INTERFACE|PortChannel1) From b04e885935fafd6dc43b8b4975fe519c1db8a1d3 Mon Sep 17 00:00:00 2001 From: liora Date: Mon, 23 May 2022 19:28:18 +0300 Subject: [PATCH 04/10] Fix more review comments --- .../ip-interface-loopback-action-design.md | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index 1cd54bb954..d18170b601 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -70,6 +70,7 @@ IP interface loopback action is a feature that allows user to change the way rou 2. INTERFACE table for interface Ethernet (e.g. INTERFACE|Ethernet232) 3. PORTCHANNEL_INTERFACE table for interface port-channel (e.g. PORTCHANNEL_INTERFACE|PortChannel1) 5. The configured loopback action can be viewed by show command in CLI. +6. 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. ### 1.2.2 Command interface **This feature will support the following commands:** @@ -78,8 +79,8 @@ IP interface loopback action is a feature that allows user to change the way rou ### 1.2.3 Error handling **This feature will provide error handling for the next situations:** -1. In CLI: invalid action, invalid interace, non ip interface -2. In SWSS: invalid action, invalid interace, non ip interface, invalid DB operation +1. In CLI: invalid action, invalid interface, non ip interface +2. In SWSS: invalid action, invalid DB operation, invalid interface ### 1.2.4 Event logging **This feature will provide event logging for:** loopback action set on IP interface. @@ -93,7 +94,7 @@ IP interface loopback action is a feature that allows user to change the way rou # 2 Design ## 2.1 Overview 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. There is an existing mechanizm in intforch that postpones handling of changes in INTF_TABLE until interface is ready, we will use it. +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. ## 2.2 DB schema ### 2.2.1 Config DB @@ -111,7 +112,7 @@ Example: "Vlan100": { "loopback_action": "drop", "mac_addr": "00:01:02:03:04:10", - "mpls": "enable" + "ipv6_use_link_local_only": "enable" }, } ``` @@ -128,7 +129,7 @@ Example: "Ethernet248": { "loopback_action": "forward", "mac_addr": "00:01:02:03:04:11", - "mpls": "enable" + "ipv6_use_link_local_only": "enable" }, } ``` @@ -143,7 +144,7 @@ Example: "PortChannel1": { "loopback_action": "drop", "mac_addr": "00:01:02:03:04:12", - "mpls": "enable" + "ipv6_use_link_local_only": "enable" }, } ``` @@ -160,9 +161,8 @@ Example for interface vlan: "Vlan100": { "loopback_action": "drop", "mac_addr": "00:01:02:03:04:10", - "mpls": "enable" - } - } + "ipv6_use_link_local_only": "enable" + ``` Example for interface Ethernet: ``` @@ -170,7 +170,7 @@ Example for interface Ethernet: "Ethernet248": { "loopback_action": "drop", "mac_addr": "00:01:02:03:04:11", - "mpls": "enable" + "ipv6_use_link_local_only": "enable" } } ``` @@ -180,13 +180,13 @@ Example for interface port-channel: "PortChannel1": { "loopback_action": "drop", "mac_addr": "00:01:02:03:04:12", - "mpls": "enable" + "ipv6_use_link_local_only": "enable" } } ``` ### 2.2.3 Configuration migration -No special handling is required +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. ## 2.3 Flows @@ -244,10 +244,12 @@ typedef enum _sai_router_interface_attr_t ## 2.5 Statistics Packets that are dropped due to loopback action will be counted in TX_ERR in IP interface statistics. ``` -root@sonic:~# show interfaces counters rif - IFACE RX_OK RX_BPS RX_PPS RX_ERR TX_OK TX_BPS TX_PPS TX_ERR ------------ ------- -------- -------- -------- ------- -------- -------- -------- -Ethernet232 0 0.00 B/s 0.00/s 0 0 0.00 B/s 0.00/s 0 +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 ``` ## 2.6 CLI @@ -277,7 +279,7 @@ Example: root@sonic:~# show ip interfaces loopback-action Interface Action ------------ ---------- -Ethernet232 drop +Ethernet232 drop Vlan100 forward ``` @@ -312,8 +314,13 @@ Test case will perform the following: 6. Create interface VLAN and repeat steps 2 to 4. ## 3.2 System tests -Will be added after review with verification team. - -# 4 Open items -1. Minigraph for MSFT. -2. VLAN sub interface not covered. +Add the following test in sonic-mgmt. +Test will perform the following: +1. Create IP interface Ethernet. +2. Loopback action not configured, send traffic, verify lopbacked packets are forwarded. +3. Set loopback action to drop, send traffic, verify lopbacked packets are dropped and TX_ERR in rif counter increased. +4. Save config and reboot, send traffic, verify lopbacked packets are dropped and TX_ERR in rif counter increased. +5. Set loopback action to forward, send traffic, verify lopbacked packets are forwarded. +6. Save config and reboot, send traffic, verify lopbacked packets are forwarded. +7. Create port-channel IP interface and repeat steps 2 to 6. +8. Create interface VLAN and repeat steps 2 to 6. From ce7cfda6a2f177d81dad4821e03525fc7dc5de83 Mon Sep 17 00:00:00 2001 From: liora Date: Mon, 23 May 2022 20:59:31 +0300 Subject: [PATCH 05/10] Fix more review comments --- .../loopback-action/ip-interface-loopback-action-design.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index d18170b601..e5d0dc828b 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -51,7 +51,7 @@ This document describes the high level design of IP interface loopback action fe ## 1.1 Feature overview 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. 1. 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](#25-statistics) -2. When loopback action is configured to forward, those packets will be forwarded. +2. When loopback action is configured to forward, those packets will be forwarded as the pipeline defined. ![feature overview](images/feature_overview.svg "Figure 1: feature overview") ###### Figure 1: feature overview From 05c697032799f0b59d2767d36f22316d953dec1a Mon Sep 17 00:00:00 2001 From: liora Date: Wed, 25 May 2022 08:35:44 +0300 Subject: [PATCH 06/10] Fix more review comments --- .../ip-interface-loopback-action-design.md | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index e5d0dc828b..3fb8ff4d8f 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -22,7 +22,8 @@ - [2.3.1.2 Handle set in init](#2312-handle-set-in-init) - [2.3.2 Loopback action set interface Ethernet](#232-loopback-action-set-interface-ethernet) - [2.3.3 Loopback action set interface port-channel](#233-loopback-action-set-interface-port-channel) - - [2.3.4 IP interface creation](#234-ip-interface-creation) + - [2.3.4 Loopback action set subinterface](#234-loopback-action-set-subinterface) + - [2.3.5 IP interface creation](#235-ip-interface-creation) - [2.4 SAI](#24-sai) - [2.5 Statistics](#25-statistics) - [2.6 CLI](#26-cli) @@ -33,7 +34,6 @@ - [3 Test plan](#3-test-plan) - [3.1 Unit tests via VS](#31-unit-tests-via-vs) - [3.2 System tests](#32-system-tests) -- [4 Open items](#4-open-items) ## Revision | Rev | Date | Author | Description | @@ -63,12 +63,15 @@ IP interface loopback action is a feature that allows user to change the way rou 2. An IP Interface can be one of the following: 1. Interface vlan 2. Interface Ethernet - 3. Interface port-channel + 3. Interface port-channel + 4. Subinterface 3. Loopback action can be set to "drop" or "forward". 4. CLI will reject loopback action setting on a non IP interface. Interface is considered as an IP interface if it has entry in: 1. VLAN_INTERFACE table for interface vlan (e.g. VLAN_INTERFACE|Vlan100) 2. INTERFACE table for interface Ethernet (e.g. INTERFACE|Ethernet232) 3. PORTCHANNEL_INTERFACE table for interface port-channel (e.g. PORTCHANNEL_INTERFACE|PortChannel1) + 4. VLAN_SUB_INTERFACE table for subinterface (e.g. VLAN_SUB_INTERFACE|Ethernet0.10) + 5. The configured loopback action can be viewed by show command in CLI. 6. 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. @@ -136,7 +139,7 @@ Example: 3. PORTCHANNEL_INTERFACE ``` PORTCHANNEL_INTERFACE|interface-name - "loopback_action": action + "loopback_action": action ``` Example: ``` @@ -149,6 +152,22 @@ Example: } ``` +4. 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" + }, +} +``` + ### 2.2.2 App DB To support loopback action set on L3 interface, a new field-value pair is defined in APP DB in table INTF_TABLE. ``` @@ -178,6 +197,16 @@ 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" @@ -206,7 +235,10 @@ Loopback action set on interface Ethernet flow is the same as interface vlan flo ### 2.3.3 Loopback action set interface port-channel 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](#221-config-db). -### 2.3.4 IP interface creation +### 2.3.4 Loopback action set subinterface +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](#221-config-db). + +### 2.3.5 IP interface creation If loopback action was not configured by the user, default loopback action is derived from SAI behavioral model which is forward. ## 2.4 SAI @@ -288,6 +320,7 @@ The following YANG models will be extended in order to provide support for loopb 1. sonic-interface.yang -> container INTERFACE 2. sonic-portchannel.yang -> container PORTCHANNEL_INTERFACE 3. sonic-vlan.yang -> container VLAN_INTERFACE +4. sonic-vlan-sub-interface.yang -> container VLAN_SUB_INTERFACE New leaf loopback_action will be added: ``` From e10058dfae80bc1f56d3f26d2c71c55be60efb6b Mon Sep 17 00:00:00 2001 From: liora Date: Wed, 25 May 2022 09:43:11 +0300 Subject: [PATCH 07/10] Fix more review comments --- .../ip-interface-loopback-action-design.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index 3fb8ff4d8f..c375c787db 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -282,16 +282,16 @@ root@r-lionfish-14:/home/admin# show interfaces counters rif 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 ``` ## 2.6 CLI ### 2.6.1 Config command - -The following command will be added to configure IP interface loopback action: +A new SONiC CLI command is introduced to configure IP interface loopback action. ``` -config interface loopback-action +# Set loopback action per INTERFACE/PORTCHANNEL_INTERFACE/VLAN_INTERFACE/VLAN_SUB_INTERFACE +config interface loopback-action drop|forward ``` -action options: "drop", "forward" Examples: ``` @@ -300,7 +300,7 @@ config interface loopback-action Vlan100 forward ``` ### 2.6.2 Show command -The following command will be added to show the configured loopback action. +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 @@ -337,23 +337,23 @@ No special handling is required # 3 Test plan ## 3.1 Unit tests via VS -Add the following test cases in file sonic-swss/tests/test_interface.py. -Test case will perform the following: +Add the following test case in file sonic-swss/tests/test_interface.py. 1. Create IP interface by writing to config DB 2. Set loopback action on IP interface 3. Check table INTF_TABLE in App DB 4. Check table SAI_OBJECT_TYPE_ROUTER_INTERFACE in ASIC DB 5. Create port-channel IP interface and repeat steps 2 to 4. 6. Create interface VLAN and repeat steps 2 to 4. +7. Create subinterface and repeat steps 2 to 4. ## 3.2 System tests Add the following test in sonic-mgmt. -Test will perform the following: 1. Create IP interface Ethernet. -2. Loopback action not configured, send traffic, verify lopbacked packets are forwarded. +2. Loopback action not configured, send traffic, verify lopbacked packets are forwarded (SAI default). 3. Set loopback action to drop, send traffic, verify lopbacked packets are dropped and TX_ERR in rif counter increased. 4. Save config and reboot, send traffic, verify lopbacked packets are dropped and TX_ERR in rif counter increased. 5. Set loopback action to forward, send traffic, verify lopbacked packets are forwarded. 6. Save config and reboot, send traffic, verify lopbacked packets are forwarded. 7. Create port-channel IP interface and repeat steps 2 to 6. 8. Create interface VLAN and repeat steps 2 to 6. +9. Create subinterface and repeat steps 2 to 6. From 7c3df5e3a35159cfa6443a3a6d145ea8d5ce92f9 Mon Sep 17 00:00:00 2001 From: liora Date: Wed, 25 May 2022 09:46:10 +0300 Subject: [PATCH 08/10] Fix more review comments --- .../loopback-action/ip-interface-loopback-action-design.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index c375c787db..310a925d74 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -227,7 +227,7 @@ When upgrading from SW image which does not support the new schema to a one whic #### 2.3.1.2 Handle set in init 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, mpls enable, loopback action etc. +Those field-value pairs are the interface attributes, e.g. mac address, loopback action etc. ### 2.3.2 Loopback action set interface Ethernet 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](#221-config-db). From 3c25c83c9c91a1449a42fdcec64cc3a379faf39b Mon Sep 17 00:00:00 2001 From: Lior Avramov <73036155+liorghub@users.noreply.github.com> Date: Thu, 26 May 2022 08:24:47 +0300 Subject: [PATCH 09/10] Add more tests to system tests --- .../loopback-action/ip-interface-loopback-action-design.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index 310a925d74..63dfba35f6 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -357,3 +357,5 @@ Add the following test in sonic-mgmt. 7. Create port-channel IP interface and repeat steps 2 to 6. 8. Create interface VLAN and repeat steps 2 to 6. 9. Create subinterface and repeat steps 2 to 6. +10. Set loopback action on non IP interface. +11. Set loopback action on non existing interface. From 714e4b2369af42bb53aac5044459e4c764f174ea Mon Sep 17 00:00:00 2001 From: liora Date: Mon, 30 May 2022 17:32:28 +0300 Subject: [PATCH 10/10] Fix more review comments --- .../ip-interface-loopback-action-design.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md index 63dfba35f6..76ea8deed5 100644 --- a/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md +++ b/doc/ip-interface/loopback-action/ip-interface-loopback-action-design.md @@ -71,9 +71,9 @@ IP interface loopback action is a feature that allows user to change the way rou 2. INTERFACE table for interface Ethernet (e.g. INTERFACE|Ethernet232) 3. PORTCHANNEL_INTERFACE table for interface port-channel (e.g. PORTCHANNEL_INTERFACE|PortChannel1) 4. VLAN_SUB_INTERFACE table for subinterface (e.g. VLAN_SUB_INTERFACE|Ethernet0.10) - 5. The configured loopback action can be viewed by show command in CLI. 6. 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. +7. No changes required in Kernel. ### 1.2.2 Command interface **This feature will support the following commands:** @@ -349,11 +349,11 @@ Add the following test case in file sonic-swss/tests/test_interface.py. ## 3.2 System tests Add the following test in sonic-mgmt. 1. Create IP interface Ethernet. -2. Loopback action not configured, send traffic, verify lopbacked packets are forwarded (SAI default). -3. Set loopback action to drop, send traffic, verify lopbacked packets are dropped and TX_ERR in rif counter increased. -4. Save config and reboot, send traffic, verify lopbacked packets are dropped and TX_ERR in rif counter increased. -5. Set loopback action to forward, send traffic, verify lopbacked packets are forwarded. -6. Save config and reboot, send traffic, verify lopbacked packets are forwarded. +2. Loopback action not configured, send traffic, verify loopbacked packets are forwarded (SAI default). +3. Set loopback action to drop, send traffic, verify loopbacked packets are dropped and TX_ERR in rif counter increased. +4. Save config and reboot, send traffic, verify loopbacked packets are dropped and TX_ERR in rif counter increased. +5. Set loopback action to forward, send traffic, verify loopbacked packets are forwarded. +6. Save config and reboot, send traffic, verify loopbacked packets are forwarded. 7. Create port-channel IP interface and repeat steps 2 to 6. 8. Create interface VLAN and repeat steps 2 to 6. 9. Create subinterface and repeat steps 2 to 6.