Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove FDB entries when shutting down the interface #909

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

InventecJamesHuang
Copy link

What I did
Add the flushing FDB feature in PortsOrch to handle the situation when the user shut down the interface.

How I did it
We create the new function named 'removeFDBEntriesByBridgePortID'.
This function is responsible for calling the SAI flush_fdb_entries() function to remove the FDB entries.

There are three situations to call the above function,

  1. In doTask function.
    When SONiC receives the port_state_change op event, if the interface goes down, it calls removeFDBEntriesByBridgePortID() to remove FDB entries.
  2. In removeLag function.
    When SONiC removes the LAG, it also calls removeFDBEntriesByBridgePortID() to remove FDB entries.
  3. In removeLagMember function.
    When SONiC removes one member from the LAG, if it causes the LAG's oper_status goes DOWN ( since the total number of enabled links less than the minimum number of links), it also calls removeFDBEntriesByBridgePortID() to remove FDB entries.

How I verified it
We prepared two physical ports (Ethernet44) and one virtual port (PortChannel1) to test.
First, I enabled two ports and each port learned 5 different FDB entries.

root@SONiC-Inventec-d6556:/home/admin# show mac
  No.    Vlan  MacAddress         Port           Type
 -----  ------  -----------------  -------------  -------
    1      11  00:10:94:00:00:21  PortChannel01  Dynamic
    2      11  00:10:94:00:00:22  PortChannel01  Dynamic
    3      11  00:10:94:00:00:05  Ethernet44     Dynamic
    4      11  00:10:94:00:00:03  Ethernet44     Dynamic
    5      11  00:10:94:00:00:02  Ethernet44     Dynamic
    6      11  00:10:94:00:00:06  Ethernet44     Dynamic
    7      11  00:10:94:00:00:20  PortChannel01  Dynamic
    8      11  00:10:94:00:00:23  PortChannel01  Dynamic
    9      11  00:10:94:00:00:04  Ethernet44     Dynamic  
   10      11  00:10:94:00:00:24  PortChannel01  Dynamic
Total number of entries 10

Shutting down Ethernet44

root@SONiC-Inventec-d6556:/home/admin# config interface shutdown Ethernet44
root@SONiC-Inventec-d6556:/home/admin# show mac
  No.    Vlan  MacAddress         Port           Type
-----  ------  -----------------  -------------  -------
    1      11  00:10:94:00:00:21  PortChannel01  Dynamic
    2      11  00:10:94:00:00:22  PortChannel01  Dynamic
    3      11  00:10:94:00:00:20  PortChannel01  Dynamic
    4      11  00:10:94:00:00:23  PortChannel01  Dynamic
    5      11  00:10:94:00:00:24  PortChannel01  Dynamic
Total number of entries 5

root@SONiC-Inventec-d6556:/home/admin# bcmcmd "l2 show"
l2 show
mac=00:10:94:00:00:24 vlan=11 GPORT=0x0 Trunk=0 Hit
mac=00:10:94:00:00:22 vlan=11 GPORT=0x0 Trunk=0 Hit
mac=00:10:94:00:00:20 vlan=11 GPORT=0x0 Trunk=0 Hit
mac=00:8c:fa:22:5a:12 vlan=1 GPORT=0x0 modid=0 port=0/cpu0 Static CPU
mac=00:10:94:00:00:23 vlan=11 GPORT=0x0 Trunk=0 Hit
mac=00:10:94:00:00:21 vlan=11 GPORT=0x0 Trunk=0 Hit

Shutting down PortChannel01

root@SONiC-Inventec-d6556:/home/admin# config interface shutdown PortChannel01 

root@SONiC-Inventec-d6556:/home/admin# show mac
No.    Vlan    MacAddress    Port    Type
-----  ------  ------------  ------  ------
Total number of entries 0

root@SONiC-Inventec-d6556:/home/admin# bcmcmd "l2 show"
l2 show
mac=00:8c:fa:22:5a:12 vlan=1 GPORT=0x0 modid=0 port=0/cpu0 Static CPU

Test LAG minimun links case
In the beginning, we prepare the LAG channel which includes three ports, and the min_ports setting is 2 and we let this LAG learn 5 different FDB entries.
First, we shut down the Ethernet72 then shut down the Ethernet76, it will cause the LAG oper_status goes down.

root@SONiC-Inventec-d6556:/home/admin# docker exec teamd cat /etc/teamd/PortChannel01.conf
{
    "device": "PortChannel01",
    "hwaddr": "00:8c:fa:22:5a:12",
    "runner": {
        "name": "lacp",
        "active": true,
        "min_ports": 2,
        "tx_hash": ["eth", "ipv4", "ipv6"]
    },
    "link_watch": {
        "name": "ethtool"
    },
    "ports": {
        "Ethernet60": {},
        "Ethernet72": {},
        "Ethernet76": {}
    }
}

root@SONiC-Inventec-d6556:/home/admin# show interfaces portchannel
Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected
  No.  Team Dev       Protocol     Ports
-----  -------------  -----------  -----------------------------------------
   01  PortChannel01  LACP(A)(Up)  Ethernet76(S) Ethernet72(S) Ethernet60(S)

root@SONiC-Inventec-d6556:/home/admin# show mac
  No.    Vlan  MacAddress         Port           Type
-----  ------  -----------------  -------------  -------
    1      11  00:10:94:00:00:22  PortChannel01  Dynamic
    2      11  00:10:94:00:00:24  PortChannel01  Dynamic
    3      11  00:10:94:00:00:23  PortChannel01  Dynamic
    4      11  00:10:94:00:00:20  PortChannel01  Dynamic
    5      11  00:10:94:00:00:21  PortChannel01  Dynamic
Total number of entries 5

root@SONiC-Inventec-d6556:/home/admin# config interface shutdown Ethernet72
root@SONiC-Inventec-d6556:/home/admin# show interfaces portchannel
Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected
  No.  Team Dev       Protocol     Ports
-----  -------------  -----------  -----------------------------------------
   01  PortChannel01  LACP(A)(Up)  Ethernet76(S) Ethernet72(D) Ethernet60(S)
root@SONiC-Inventec-d6556:/home/admin# show mac
  No.    Vlan  MacAddress         Port           Type
-----  ------  -----------------  -------------  -------
    1      11  00:10:94:00:00:22  PortChannel01  Dynamic
    2      11  00:10:94:00:00:24  PortChannel01  Dynamic
    3      11  00:10:94:00:00:23  PortChannel01  Dynamic
    4      11  00:10:94:00:00:20  PortChannel01  Dynamic
    5      11  00:10:94:00:00:21  PortChannel01  Dynamic
Total number of entries 5

root@SONiC-Inventec-d6556:/home/admin# config interface shutdown Ethernet76
root@SONiC-Inventec-d6556:/home/admin# show interfaces portchannel
Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected
  No.  Team Dev       Protocol     Ports
-----  -------------  -----------  -----------------------------------------
   01  PortChannel01  LACP(A)(Dw)  Ethernet76(D) Ethernet72(D) Ethernet60(S)

root@SONiC-Inventec-d6556:/home/admin# show mac
No.    Vlan    MacAddress    Port    Type
-----  ------  -----------

Details if related

@msftclas
Copy link

msftclas commented May 23, 2019

CLA assistant check
All CLA requirements met.

@lguohan lguohan requested a review from prsunny May 24, 2019 09:55
// If the number of enabled members is less than the value of this channel miniport,
// It will cause that the LAG channel oper_status DOWN,
// then we should clear the entire FDB entry.
vector<FieldValueTuple> lag_value;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this here? there is a doLagTask that gets the oper_status command and you could invoke the function removeFDBEntriesByBridgePortID in that flow.

Port port;
if (getPort(id, port))
{
SWSS_LOG_NOTICE("%s status is DOWN, remove the FDB entries.", port.m_alias.c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the bridge port id as well to log message?

vector<sai_attribute_t> flush_attrs;
sai_status_t rv;

SWSS_LOG_NOTICE("SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID By 0x%lx", bridge_port_id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be INFO level

flush_attr.id = SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID;
flush_attr.value.oid = bridge_port_id;
flush_attrs.push_back(flush_attr);
rv = sai_fdb_api->flush_fdb_entries(gSwitchId, (uint32_t)flush_attrs.size(), flush_attrs.data());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the CRM counter be updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants