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

configDB enforcer for interface #357

Merged
merged 7 commits into from
Nov 5, 2017
Merged

Conversation

jipanyang
Copy link
Contributor

Support VLAN interface only for now

Signed-off-by: Jipan Yang [email protected]

What I did
Configuration enforcer for VLAN interface

Why I did it
Support interface configuration via configDB for both initialization and incremental update
How I verified it
VLAN trunk test plan: https://github.com/Azure/SONiC/wiki/VLAN-trunk-test-plan
Details if related

Support VLAN interface only for now

Signed-off-by: Jipan Yang <[email protected]>
@jipanyang
Copy link
Contributor Author

Has dependency on:
sonic-net/sonic-swss-common#146
#355
#336
#344

@lguohan
Copy link
Contributor

lguohan commented Oct 23, 2017

@taoyl-ms , @stcheng to review

DBGFLAGS = -g
endif

intfconfd_SOURCES = intfconfd.cpp intfconf.cpp $(top_srcdir)/cfgorch/cfgorch.cpp
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 23, 2017

Choose a reason for hiding this comment

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

cfgorch [](start = 61, length = 7)

suggest merge "cfgorch", "intfconfd" into one directory #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, cfgagent might be a good name for the directory. Will move intfconfd, vlanconfd and debug cli implmentation cfgmgrtest there. Actually that was the initial arrangement.

#define VLAN_PREFIX "Vlan"
#define LAG_PREFIX "PortChannel"

IntfConf::IntfConf(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, vector<string> tableNames) :
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 23, 2017

Choose a reason for hiding this comment

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

vector [](start = 81, length = 6)

Do you want to copy a vector? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The table names for different DB are different. a vector might not be a good fit here.

Copy link
Contributor

@qiluo-msft qiluo-msft Oct 25, 2017

Choose a reason for hiding this comment

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

I am not sure you are talking about the same thing. I mean that use a copied instance may cost much than a reference. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok


cmd = "ip address " + opCmd + " ";
cmd += ipPrefixStr + " dev " + alias;
swss::exec(cmd, res);
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 23, 2017

Choose a reason for hiding this comment

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

exec [](start = 10, length = 4)

check the return value? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error has been logged in exec if there is any. In this case, error is not really expected.
That is common question for many functions in sonic, end 2 end feedback loop is missing.

Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2017

Choose a reason for hiding this comment

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

I don't agree. Locally if there is any error happens, you should check the return code all the levels up the stack, and quit as soon as possible, or recover depending on the situation. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fine. But I don't see the same criteria applied in orchagent, syncd, those python code and etc.
We could start the endeavor from this.

CfgOrch::syncCfgDB(CFG_VLAN_INTF_TABLE_NAME, m_cfgVlanIntfTable);
}

bool IntfConf::setIntfIp(string &alias, string &opCmd, string &ipPrefixStr)
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 23, 2017

Choose a reason for hiding this comment

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

string & [](start = 25, length = 8)

If using a reference, consider using a const reference if possible. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

return true;
}

bool IntfConf::isIntfStateOk(string &alias)
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 23, 2017

Choose a reason for hiding this comment

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

isIntfStateOk [](start = 15, length = 13)

suggest name: readyIntf

Copy link
Contributor Author

@jipanyang jipanyang Oct 26, 2017

Choose a reason for hiding this comment

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

Honestly I don't see readyIntf a better name than isIntfStateOk, we do put state ok in stateDB though it is not checked for now. If you insist on changing the name, I could do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking the code, there is nothing about "Ok" state. So I guess the original name is not perfect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will add code to check the state:

127.0.0.1:6379[6]> hgetall "PORT_TABLE|Ethernet47"

  1. "state"
  2. "ok"

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see that you check "ok"

continue;
}

IpPrefix ip_prefix(kfvKey(t).substr(kfvKey(t).find(CONFIGDB_KEY_SEPARATOR)+1));
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 23, 2017

Choose a reason for hiding this comment

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

IpPrefix ip_prefix(kfvKey(t).substr(kfvKey(t).find(CONFIGDB_KEY_SEPARATOR)+1)); [](start = 8, length = 79)

Split into multiple statement. It is too complex to read. #Closed

}
catch(const std::exception &e)
{
SWSS_LOG_ERROR("Runtime error: %s", e.what());
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 23, 2017

Choose a reason for hiding this comment

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

return a non zero error code? #Closed

.gitignore Outdated
@@ -43,6 +43,7 @@ deps/
teamsyncd/teamsyncd
fpmsyncd/fpmsyncd
intfsyncd/intfsyncd
cfgagent/intfconfd
Copy link
Contributor

Choose a reason for hiding this comment

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

can you rename to intfmgr?

The role of confd, orchagent, syncd are blurred, it is hard to have a clear cuts of different roles they are playing, so mgr can include all functions, which manages both asic and linux setup. therefore I prefer mgr name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will rename them to intfmgr and vlanmgr. For switch table level configuration, besides switchmgr process itself, the configuration may be used by multiple function modules like VLAN.

I plan to keep the class name of VlanConf, IntfConf and SwitchConf, let me know if you have other suggestions.

#define VLAN_PREFIX "Vlan"
#define LAG_PREFIX "PortChannel"

IntfConf::IntfConf(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, vector<string> tableNames) :
Copy link
Contributor

Choose a reason for hiding this comment

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

as requested above, can you rename to IntfMgr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So process and binary name will be changed to VlanMgr/IntfMgr/SwitchMgr, you want to change the internal class name to xxxMgr too? IntfConfd/VlanConfd were chosen per the offline meeting discussion. Yes, class name may be changed.

@lguohan
Copy link
Contributor

lguohan commented Oct 25, 2017

can you add swssloglevel support for this agent so that we can control the log level of this agent on the fly.

endif


intfconfd_SOURCES = intfconfd.cpp intfconf.cpp $(top_srcdir)/orchagent/orchbase.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

orchbase [](start = 71, length = 8)

Is this file missing in the PR? Why not added it in the same directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is in PR #360

@lguohan
Copy link
Contributor

lguohan commented Oct 25, 2017

retest this please

{
if (m_stateVlanTable.get(alias, temp))
{
SWSS_LOG_DEBUG("Port %s is ready\n", alias.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Vlan is ready.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, will fix it.

string op = kfvOp(t);
if (op == SET_COMMAND)
{
/* Don't proceed if port/lag/VLAN is not ready yet */
Copy link
Contributor

Choose a reason for hiding this comment

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

add more comments here, retry. Later, we need to add subscriber for the state db to get notification when the port/lag/vlan is created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@jipanyang
Copy link
Contributor Author

jipanyang commented Oct 25, 2017

@lguohan lguohan swssloglevel has been supported with "Logger::linkToDbNative("intfconfd");"

root@sonic:/etc/sonic# swssloglevel -p
SAI_API_ACL SAI_LOG_LEVEL_NOTICE
........
intfconfd NOTICE
intfsyncd NOTICE
..........
vlanconfd DEBUG

{
}

void IntfMgr::syncCfgDB()
Copy link
Contributor

Choose a reason for hiding this comment

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

where does this function get called?

configure.ac Outdated
@@ -87,6 +87,7 @@ AC_CONFIG_FILES([
teamsyncd/Makefile
swssconfig/Makefile
tests/Makefile
cfgagent/Makefile
Copy link
Contributor

Choose a reason for hiding this comment

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

cfgagent [](start = 4, length = 8)

cfgmgr

Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

per our discussion, can you change to use orch class for this PR?

@jipanyang
Copy link
Contributor Author

Switched to orch class.
Has dependency on #356

{
return true;
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

return ret == 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

once vlanmgr is merged.

@lguohan
Copy link
Contributor

lguohan commented Nov 5, 2017

@JipanYanga , can you resolve the conflict?

@jipanyang
Copy link
Contributor Author

Conflicts resolved.

@lguohan lguohan merged commit 6e84504 into sonic-net:master Nov 5, 2017
@jipanyang jipanyang deleted the intfconfd branch June 5, 2018 00:29
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
* Fix optimized remove in comparison logic

* Add missing brackets

* Address comments
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.

3 participants