[mtu] Update the mtu on host interfaces if config DB changes#375
[mtu] Update the mtu on host interfaces if config DB changes#375stcheng merged 1 commit intosonic-net:masterfrom hzheng5:mtu-settings
Conversation
portsyncd/portsyncd.cpp
Outdated
| { | ||
| char system_cmd[1024]; | ||
| snprintf(system_cmd, sizeof(system_cmd), "ip link set %s mtu %s", key.c_str(), value.c_str()); | ||
| int ret_val = system(system_cmd); |
There was a problem hiding this comment.
Generally, I've seen the usage of swss::exec to execute commands instead of direct system call. Can you check? Also, you could use stringstream for the command which would be convenient instead of allocating a buffer and then use snprintf
You could refer: IntfMgr::setIntfIp in intfmgr.cpp
There was a problem hiding this comment.
Thanks Sunny.
Will check.
There was a problem hiding this comment.
Hi @prsunny ,
Just updated the diff with exec. Thanks for your suggestion.
Please help review the latest diff.
Cheers,
Haiyang
Signed-off-by: Haiyang Zheng <[email protected]>
|
Hi @prsunny , Just updated the diff with exec. Thanks for your suggestion. Please help review the latest diff. Cheers, |
| { | ||
| string cmd, res; | ||
| cmd = "ip link set " + key + " mtu " + value; | ||
| swss::exec(cmd, res); |
There was a problem hiding this comment.
Do you want to check for return value?.
There was a problem hiding this comment.
Hi Sunny @prsunny ,
The return value will be checked inside swss::exec, if failed swss::exec will throw an error.
And most places calling swss::exec don't check the res except those show cmd.
some test log for the failure case.
Nov 9 02:45:07.294323 sonic-1 ERR portsyncd: :- exec: ip link set Ethernet8 mtu 9800: Success
Thanks,
Haiyang
…net#375) "Ethernet0|4": { "wred_profile": "[WRED_PROFILE|AZURE_LOSSLESS]", "scheduler": "[SCHEDULER|scheduler.0]" }, Signed-off-by: Wenda <[email protected]>
* add missing object types * refactor stats to be generic
…onic-net#375) Signed-off-by: Haiyang Zheng <[email protected]>
Signed-off-by: Haiyang Zheng [email protected]
What I did
Now, portsyncd is subscribed to config DB, and use handlePortConfig to copy port config from config DB to APP DB. Here, we also need to update the host interfaces MTU in linux kernel if the port config changes.
Why I did it
Otherwise, there will be discrepancy between linux kernel MTU and port MTU in config DB/app DB.
How I verified it
Update the port inside config_db.json file with new mtu field, and verify both kernel MTU and ASIC port MTU has been updated properly.
Details if related
This pull request require the following pull request
sonic-net/sonic-buildimage#1128
With both changes, the MTU from config DB will be the only source for Kernel MTU and port MTU on ASIC.