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

[config] add support to configure mtu on interface #512

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

leoli-nps
Copy link

Signed-off-by: leo.li leo.li@nephosinc.com

- What I did
Interface mtu configuration support

- How I did it
Python scripts scripts/portconfig and config/main.py modified

- How to verify it
Using sudo conifg interface mtu command and check port status

- Previous command output (if the output of a command-line utility has changed)

admin@sonic:~$ sudo portconfig --help
usage: portconfig [-h] [-v] -p PORT [-l] [-s SPEED] [-f FEC] [-vv]

Set SONiC port parameters

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -p PORT, --port PORT  port name (e.g. Ethernet0)
  -l, --list            list port parametars
  -s SPEED, --speed SPEED
                        port speed value in Mbit
  -f FEC, --fec FEC     port fec mode value in (none, rs, fc)
  -vv, --verbose        Verbose output
admin@sonic:~$
admin@sonic:~$ sudo config interface --help
Usage: config interface [OPTIONS] <interface_name> COMMAND [ARGS]...

  Interface-related configuration tasks

Options:
  --help  Show this message and exit.

Commands:
  ip        Add or remove IP address
  pfc       Set PFC configuration.
  shutdown  Shut down interface
  speed     Set interface speed
  startup   Start up interface
admin@sonic:~$

- New command output (if the output of a command-line utility has changed)

admin@sonic:~$ sudo portconfig --help
usage: portconfig [-h] [-v] -p PORT [-l] [-s SPEED] [-f FEC] [-m MTU] [-vv]

Set SONiC port parameters

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -p PORT, --port PORT  port name (e.g. Ethernet0)
  -l, --list            list port parametars
  -s SPEED, --speed SPEED
                        port speed value in Mbit
  -f FEC, --fec FEC     port fec mode value in (none, rs, fc)
  -m MTU, --mtu MTU     port mtu value in Uint
  -vv, --verbose        Verbose output
admin@sonic:~$
admin@sonic:~$ sudo config interface --help
Usage: config interface [OPTIONS] COMMAND [ARGS]...

  Interface-related configuration tasks

Options:
  --help  Show this message and exit.

Commands:
  ip        Add or remove IP address
  mtu       Set interface mtu
  pfc       Set PFC configuration.
  shutdown  Shut down interface
  speed     Set interface speed
  startup   Start up interface
admin@sonic:~$

- Logs

admin@sonic:~$ sudo config interface mtu Ethernet120 300

Apr 16 07:22:30.029695 sonic NOTICE swss#orchagent: :- doPortTask: Set port Ethernet120 MTU to 300
Apr 16 07:22:30.029695 sonic NOTICE swss#orchagent: :- setRouterIntfsMtu: Set router interface Ethernet120 MTU to 300
Apr 16 07:22:30.032236 sonic NOTICE swss#portmgrd: :- doTask: Configure Ethernet120 MTU to 300
admin@sonic:~$ ip link show Ethernet120
49: Ethernet120: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 300 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 6c:ec:5a:08:2a:b9 brd ff:ff:ff:ff:ff:ff
admin@sonic:~$
admin@sonic:~$ sudo config interface mtu PortChannel0001 300

Apr 16 07:26:08.943151 sonic NOTICE swss#orchagent: :- setRouterIntfsMtu: Set router interface PortChannel0001 MTU to 300
Apr 16 07:26:08.944256 sonic NOTICE teamd#teammgrd: :- setLagMtu: Set port channel PortChannel0001 MTU to 300
admin@sonic:~$ ip link show PortChannel0001
6: PortChannel0001: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 300 qdisc noqueue master Bridge state UP mode DEFAULT group default qlen 1000
    link/ether 6c:ec:5a:08:2a:b9 brd ff:ff:ff:ff:ff:ff
admin@sonic:~$

Signed-off-by: leo.li <leo.li@nephosinc.com>
@prsunny
Copy link
Contributor

prsunny commented Apr 16, 2019

@leoli-nps , this looks to be the IP MTU and not the port MTU. Can we add this in the description?

@leoli-nps
Copy link
Author

  1. The information about setRouterIntfsMtu appears in logs because I have configured IP addresses on both Ethernet120 and PortChannel0001. Therefore, the operation is still used to configure the port MTU, but the corresponding port has the rif configuration, and the corresponding ip MTU is updated.
    We can see the corresponding operation in doPortTask, as shown below:
    if (mtu != 0 && mtu != p.m_mtu)
    {
        if (setPortMtu(p.m_port_id, mtu))
        {
            p.m_mtu = mtu;
            m_portList[alias] = p;
            SWSS_LOG_NOTICE("Set port %s MTU to %u", alias.c_str(), mtu);
            if (p.m_rif_id)
            {
                gIntfsOrch->setRouterIntfsMtu(p);
            }
        }
        else
        {
            SWSS_LOG_ERROR("Failed to set port %s MTU to %u", alias.c_str(), mtu);
            it++;
            continue;
        }
    }
  1. The MTU seen by the command ip link show has also changed accordingly. Because portmgrd responds to the change of port mtu in config_db, it not only updates the port mtu in app_db, but also updates the mtu of the port in the kernel. Teammgrd will do the same.

@prsunny , hope to answer your question.

@prsunny
Copy link
Contributor

prsunny commented May 2, 2019

retest this please

prsunny
prsunny previously approved these changes May 3, 2019
@prsunny
Copy link
Contributor

prsunny commented May 3, 2019

@jleveque , @lguohan , can you review/approve this?

config/main.py Outdated Show resolved Hide resolved
…cking if it is included in the PORT table of ConfigDB

Signed-off-by: leo.li <leo.li@nephosinc.com>
@leoli-nps
Copy link
Author

I made the corresponding changes according to the example, please review.
@jleveque

jleveque
jleveque previously approved these changes May 6, 2019
@prsunny
Copy link
Contributor

prsunny commented May 6, 2019

retest this please

@leoli-nps
Copy link
Author

    def test_CrmAcl(dvs, testlog):
    
        db = swsscommon.DBConnector(4, dvs.redis_sock, 0)
        adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
    
        dvs.runcmd("crm config polling interval 1")
    
        bind_ports = ["Ethernet0", "Ethernet4"]
    
        old_table_used_counter = getCrmCounterValue(dvs, 'ACL_STATS:INGRESS:PORT', 'crm_stats_acl_table_used')
    
        # create ACL table
        ttbl = swsscommon.Table(db, "ACL_TABLE")
        fvs = swsscommon.FieldValuePairs([("policy_desc", "test"), ("type", "L3"), ("ports", ",".join(bind_ports))])
        ttbl.set("test", fvs)
    
        # create ACL rule
        rtbl = swsscommon.Table(db, "ACL_RULE")
        fvs = swsscommon.FieldValuePairs([("priority", "55"), ("PACKET_ACTION", "FORWARD"), ("L4_SRC_PORT", "65000")])
        rtbl.set("test|acl_test_rule", fvs)
    
        time.sleep(2)
    
        new_table_used_counter = getCrmCounterValue(dvs, 'ACL_STATS:INGRESS:PORT', 'crm_stats_acl_table_used')
>       table_used_counter = new_table_used_counter - old_table_used_counter
E       TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'

The prompt message for the test failure is as shown above.
According to the prompts, check the relevant code, may have a relationship with pull#879, please help confirm.
@prsunny

@prsunny
Copy link
Contributor

prsunny commented May 21, 2019

retest this please

@jleveque
Copy link
Contributor

Retest this please

stcheng
stcheng previously approved these changes Jun 7, 2019
@stcheng
Copy link
Contributor

stcheng commented Jun 7, 2019

Retest this please

@prsunny
Copy link
Contributor

prsunny commented Aug 28, 2019

retest this please

@vdahiya12 vdahiya12 dismissed stale reviews from stcheng, jleveque, and prsunny via 8c3a288 July 28, 2021 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants