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 VLAN #356

Merged
merged 8 commits into from
Nov 5, 2017
Merged

configDB enforcer for VLAN #356

merged 8 commits into from
Nov 5, 2017

Conversation

jipanyang
Copy link
Contributor

Signed-off-by: Jipan Yang jipan.yang@alibaba-inc.com

What I did
Configuration enforcer for VLAN

Why I did it
Support vlan 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

@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

Makefile.am Outdated
@@ -1,4 +1,4 @@
SUBDIRS = fpmsyncd neighsyncd intfsyncd portsyncd orchagent swssconfig
SUBDIRS = fpmsyncd neighsyncd intfsyncd portsyncd orchagent swssconfig vlanconfd
Copy link
Contributor

Choose a reason for hiding this comment

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

i prefer vlanmgr than vlanconfd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is already bgpconfd. We may change to vlanmgr from vlanconfd, then it introduces name inconsistency.

As suggested by @qiluo-msft in #357, probably we may merge the files of vlan configuration enforcer and intf configuration enforcer into one flat folder while keeping them in separate processes, other future configuration enforcer (in c++) could follow the same practice.

I don't have strong opinion about the naming of configuration enforcer folder and configuration enforcers themselves, but to avoid multiple iterations of name change and folder rearrangement, could @lguohan @taoyl-ms @qiluo-msft @stcheng agree on the following names:

folder name: cfgagent
vlan configuration enforcer: vlanconfd
intf configuration enforcer: intfconfd

Or please help give names (and folder structure) you all agree on, thanks!

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
@lguohan
Copy link
Contributor

lguohan commented Oct 25, 2017

can you seperate the vlanmgr and switchmgr into two PR?

cmd += DOT1Q_BRIDGE_NAME;
cmd += " name ";
cmd += VLAN_PREFIX + to_string(vlan_id)
+ " type vlan id " + to_string(vlan_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we contruct the command in one line, easier to 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.

I had problem compiling it if put them in one line. Will check again to see how to around the problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think "stringstream" would be a better option here and it takes different types of input so you wudn't have to convert integers to_string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using stringstream looks like a good idea.

gSwtichConfVlan->updateHostFloodControl(port_alias);

// Bring up vlan member port and set MTU to 9100 by default
cmd = "ip link set " + port_alias + " up mtu 9100";
Copy link
Contributor

Choose a reason for hiding this comment

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

9100 hard coded? do we have that value in config db?

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 hard coded in interfaces.j2, not in config DB. Probably port schema in configDB should be updated to have MTU field.

127.0.0.1:6379[4]> hgetall "PORT|Ethernet20"

  1. "alias"
  2. "tenGigE20"
    127.0.0.1:6379[4]> hgetall "VLAN_MEMBER|Vlan1000|Ethernet20"
  3. "tagging_mode"
  4. "untagged"

@jipanyang
Copy link
Contributor Author

@lguohan Ok, will take switch related configuration to a separate PR

VlanConf(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, vector<string> tableNames);
void syncCfgDB();
private:
ProducerStateTable m_appVlanTableProducer, m_appVlanMemberTableProducer;
Copy link
Contributor

Choose a reason for hiding this comment

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

P [](start = 0, length = 2)

can you change all tab to spaces?

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


string mac_str;
swss::exec("ip link show eth0 | grep ether | awk '{print $2}'", mac_str);
gMacAddress = mac_str;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this as an parameter instead of hard code the vlan mac address into the code logic, see -m option in orchagent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SWITCH_ATTR in SWITCH table has switch_mac field, to implement mac fetching from configDB SWITCH. mac could be be taken from there if configured, otherwise eth0 mac is used by default.
mac address here is to set on VLAN.

{
if (m_stateLagTable.get(alias, temp))
{
SWSS_LOG_DEBUG("%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.

\n [](start = 39, length = 2)

remove this '\n', does dot look like we need it.

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

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
swss::exec(cmd, res);

// When port is not member of any VLAN, it shall be detached from Dot1Q bridge!
cmd = "bridge vlan show dev " + port_alias + " | grep None";
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to use the full path for all the commands, otherwise those commands could be override by users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right. I'm thinking of having a common header file with all the commands macro defined, full path is specified in the macro definition.

for (auto i : kfvFieldsValues(t))
{
if (fvField(i) == "tagging_mode")
tagging_mode = fvValue(i);
Copy link
Contributor

Choose a reason for hiding this comment

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

always have {}

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

if (table_name == CFG_VLAN_TABLE_NAME)
doVlanTask(consumer);
else if (table_name == CFG_VLAN_MEMBER_TABLE_NAME)
doVlanMemberTask(consumer);
Copy link
Contributor

Choose a reason for hiding this comment

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

always have {}

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

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
SWSS_LOG_DEBUG("%s", (dumpTuple(consumer, consumer.m_toSync[member_key])).c_str());
}
/*
* There is pending task from consumber pipe, in this case just skip it.
Copy link
Contributor

Choose a reason for hiding this comment

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

consumer

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
EXEC_WITH_ERROR_THROW(cmd.str(), res);
}

void VlanMgr::syncCfgDB()
Copy link
Contributor

Choose a reason for hiding this comment

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

syncCfgDB [](start = 14, length = 9)

where is function gets called?

@jipanyang jipanyang force-pushed the vlanconfd branch 2 times, most recently from 28d5e91 to d8b6fb8 Compare November 2, 2017 10:47
@jipanyang
Copy link
Contributor Author

has dependency on sonic-net/sonic-swss-common#156

@lguohan
Copy link
Contributor

lguohan commented Nov 2, 2017

retest this please

@lguohan
Copy link
Contributor

lguohan commented Nov 2, 2017

retest this please

@lguohan
Copy link
Contributor

lguohan commented Nov 2, 2017

sonic-net/sonic-swss-common#156 is merged, but build still failed.

@jipanyang
Copy link
Contributor Author

Sorry, too many iterations of name change and folder restructuring, I missed OrchBase to Orch name change in few places for last commit. Please check it again.

@lguohan
Copy link
Contributor

lguohan commented Nov 2, 2017

const string VLAN_PREFIX = "Vlan";

this can be removed. minor.


Refers to: portsyncd/linksync.cpp:26 in f67e288. [](commit_id = f67e288, deletion_comment = False)

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
@jipanyang
Copy link
Contributor Author

Removed const string VLAN_PREFIX = "Vlan"; from portsyncd/linksync.cpp
Also the unused g_vlanMap variable form linksync.cpp and portsyncd.cpp


string mac_str;
stringstream cmd;
cmd << IP_CMD << " link show eth0 | " << GREP_CMD << " ether | " << AWK_CMD << " '{print $2}'";
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to use the -m option to get the mac address since it is complicated.

You can check here. https://github.com/Azure/sonic-buildimage/blob/37dc7bd4786c793796530e53da304b5e68b7ed16/files/image_config/interfaces/interfaces-config.sh#L7

For some asic, the switch mac must match certain pattern.
Here for the VLAN mac, you will want it to be the same as the switch mac. Therefore, we need to follow the same procedure.

Copy link
Contributor Author

@jipanyang jipanyang Nov 3, 2017

Choose a reason for hiding this comment

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

Ok, I'm think of using the switch table in configDB which has switch mac field

127.0.0.1:6379[4]> hgetall "SWITCH|SWITCH_ATTR"

  1. "switch_mac"
  2. "00:05:64:30:73:c0"

In interfaces-config.sh, we set the switch_mac to configDB if it is not there already, then use the configDB data in vlanMgr. This way it gives people the option to specify switch mac other than that of eth0.

sonic-net/sonic-buildimage#1108

Copy link
Contributor

@lguohan lguohan Nov 3, 2017

Choose a reason for hiding this comment

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

that is fine, but use eth0 mac directly is not an option. need to remove that part from your current code.

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.

/*
* TODO: support host VLAN mtu setting.
* Host VLAN mtu should be set only after member configured
* and VLAN state is not UNKOWN.
Copy link
Contributor

Choose a reason for hiding this comment

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

UNKOWN-> UNKNOWN

SWSS_LOG_DEBUG("%s mtu %u: Host VLAN mtu setting to be supported.", key.c_str(), mtu);
fvVector.push_back(i);
}
else if (fvField(i) == "members@") {
Copy link
Contributor

Choose a reason for hiding this comment

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

in the new configdb schema, we have VLAN_MEMBER table, we should remove the members@ attribute in VLAN table, otherwise, there cloud potentially be two sources of truth.

We do not need to do this change now. But, please do it in later PR.

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 remove it once minigraph.py update for the member processing is committed.

https://github.com/Azure/sonic-buildimage/pull/1063/files#diff-18b32e4dc045fa3d1c5941a732124c89

it++;
continue;
}
string tagging_mode = "untagged";
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 also update the VLAN_MEMBER scheme in https://github.com/Azure/SONiC/wiki/Configuration ?

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

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.

-m need to be added to specify the mac address of the bridge.

Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
FieldValueTuple a("admin_status", "up");
fvVector.push_back(a);
}
m_appVlanTableProducer.set(key, fvVector);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any plan to deal with the operational state of Vlan interface if not yet done? We may need that to disable routing if vlan interface is down.
If we are doing that, I assume some other entity (like netlink message in linksync.cpp) will update the app-db? In that case, do we have a timing issue here? (e,g, netlink messages came before we put the table to app-db)?

We can address this in future PR if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

we need to define the operational state of vlan first. if it mean all members are down, then we have way to know the member oper status already, we do not need to rely on the netlink to get the vlan op status, then. This is going to be another feature request and thus a separate PR.

@lguohan lguohan merged commit 021ef4f into sonic-net:master Nov 5, 2017
@jipanyang jipanyang deleted the vlanconfd branch June 5, 2018 00:29
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
lguohan pushed a commit that referenced this pull request Aug 24, 2023
What I did
Admin-disable port before applying media-based NPU serdes attributes from media_settings.json.

Why I did it
This fix is needed along with xcvrd changes #377.
Maintain deterministic behavior of interface bring-up, by toggling host_tx_ready flag, which will trigger CMIS reinit for the module once NPU serdes params have been applied.

How I verified it
Validated media_settings being notified and applied on Cisco 8111 with subject changes combined with diffs from #360, #377 and #15453.
Will update final results once #377 is frozen.

Details if related
Proposal for xcvrd changes: #356

Signed-off-by: Aman Singhal <amans@cisco.com>
tshalvi pushed a commit to tshalvi/sonic-swss that referenced this pull request Sep 18, 2023
…c-net#2831)

What I did
Admin-disable port before applying media-based NPU serdes attributes from media_settings.json.

Why I did it
This fix is needed along with xcvrd changes sonic-net#377.
Maintain deterministic behavior of interface bring-up, by toggling host_tx_ready flag, which will trigger CMIS reinit for the module once NPU serdes params have been applied.

How I verified it
Validated media_settings being notified and applied on Cisco 8111 with subject changes combined with diffs from sonic-net#360, sonic-net#377 and #15453.
Will update final results once sonic-net#377 is frozen.

Details if related
Proposal for xcvrd changes: sonic-net#356

Signed-off-by: Aman Singhal <amans@cisco.com>
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