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

[intfmgrd]: Merge intfsyncd into intfmgrd #635

Merged
merged 26 commits into from
Dec 27, 2018

Conversation

marian-pritsak
Copy link
Collaborator

Move intfsyncd functionality to intfmgrd, add VRF membership support.

Signed-off-by: Marian Pritsak marianp@mellanox.com

Move intfsyncd functionality to intfmgrd, add VRF membership support.

Signed-off-by: Marian Pritsak <marianp@mellanox.com>

if (keys.size() != 2)
if (!isIntfStateOk(vrf_name))
Copy link
Collaborator

Choose a reason for hiding this comment

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

vrf_name is optional and can be empty here. You would want to check if it is empty. User may just want to configure "mtu" for the interface.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

if (op == SET_COMMAND)
{
/*
* Don't proceed if port/LAG/VLAN is not ready yet.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment is repeated down. I think you can remove this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

}

string alias(keys[0]);
IpPrefix ip_prefix(keys[1]);
setIntfIp(alias, "add", ip_prefix.to_string(), ip_prefix.isV4());
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have to check for return value here. Previously it was via Netlink and hence ensured it was configured in kernel. Now, we have to explicitly check if the address is successfully configured in kernel

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using EXEC_WITH_ERROR_THROW

@@ -43,6 +45,23 @@ bool IntfMgr::setIntfIp(const string &alias, const string &opCmd,
return (ret == 0);
}

bool IntfMgr::setIntfVrf(const string &alias, const string vrfName)
Copy link
Contributor

Choose a reason for hiding this comment

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

The return value shouldn't be a boolean. For proper error checking, you should return the return value which can be 0, 1 or 2 I believe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed function to use EXEC_WITH_ERROR_THROW

return false;
}

setIntfVrf(alias, vrf_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the return values please and call m_appIntfTableProducer only on 0. Print a syslog error for 1 and 2 along with the value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed function to use EXEC_WITH_ERROR_THROW

}
else if (op == DEL_COMMAND)
{
setIntfVrf(alias, "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about return values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed function to use EXEC_WITH_ERROR_THROW

}

string alias(keys[0]);
IpPrefix ip_prefix(keys[1]);
setIntfIp(alias, "add", ip_prefix.to_string(), ip_prefix.isV4());
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

}
else if (op == DEL_COMMAND)
{
setIntfIp(alias, "del", ip_prefix.to_string(), ip_prefix.isV4());
Copy link
Contributor

Choose a reason for hiding this comment

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

Same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed function to use EXEC_WITH_ERROR_THROW

string op = kfvOp(t);
if (op == SET_COMMAND)

if (keys.size() == 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

What does it mean for the key size to be 1? Shouldn't use literals in the code like that. Please define somewhere and explain.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is not some kind enum to define. It means exactly if there are two keys or one

Copy link
Contributor

Choose a reason for hiding this comment

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

My question was to illustrate the need to not use literals in the code. I know what it means. You can still #define somewhere common or even use an enum.

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
Signed-off-by: Marian Pritsak <marianp@mellanox.com>
@prsunny
Copy link
Collaborator

prsunny commented Oct 3, 2018

@marian-pritsak , @lguohan, looking at the VS test failures, there are test cases that do "ifconfig <ip_address>" configurations and rely on the Netlink msgs (intfsyncd) to eventually program the ASIC_DB. The failed tests are route, nexthop, neighbor, port_state and crm (route/ip related) to name a few. We would need to discuss how this can be resolved. Need to fix the VS test cases

@@ -13,6 +13,7 @@ using namespace swss;

#define VLAN_PREFIX "Vlan"
#define LAG_PREFIX "PortChannel"
#define VNET_PREFIX "Vnet"

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 add vs test for this refactoring.

I am think you need to first create

INTERFACE|eth0 with vrf, then check if the interface has been moved to vrf or not.

INTERFACE|eth0|ipaddress, then check if the interface has been assigned with IP address or not.

add another ip address, and check if the interface has been assigned with additional IP.

then, remove the one ip address, and check.

remove another ip address, and check.

Then, check vrf name and check if the interface is moved to another vrf or not.

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.

need to fix the vs test case and add a few more since you have changed the INTERFACE schema.

@nikos-github nikos-github mentioned this pull request Oct 4, 2018

if (!vrfName.empty())
{
cmd << IP_CMD << " link set " << alias << " master " << vrfName;
Copy link
Contributor

Choose a reason for hiding this comment

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

When the interface is enslaved in a vrf, the connected (subnet route) and receive (ip2me route) need to be removed from the old vrf. Is the expectation that SAI will do this automatically?

I don't see this PR taking care of that and I don't see #632 taking care of that either.

Please clarify whether it's been agreed that SAI will do this. If not, then either this PR or the one I mentioned above, need to take care of it, unless I've missed something.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems #632 won't be taking care of this. As such, this PR will need to address the issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@nikos-github , for the current use-case, the interface configuration (in ConfigDB) will have the interface with the VRF name. That means, when it is created first time, it will be enslaved to this VRF. My understanding is in phase 1, we are not planning for dynamically changing the interface from one VRF to another. When we have the full VRF implementation as part of sonic-net/SONiC#242, this shall be taken care.

prsunny added a commit that referenced this pull request Oct 10, 2018
* VNET/VRF Changes  (#6)

* VRF changes

* Fixed an IPv6 address parsing issue

* Updated logs, removed intfmgr changes in favour of PR #635

* Updated VRF table name

* Addressed review comment, test fixes

* Remove extra semi-colon

* Route handling, review comments (#8)

* Vnet route table handling

* Addressed review comments

* Fix for interface routes, add debug logs
@marian-pritsak
Copy link
Collaborator Author

retest this please

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
Signed-off-by: Marian Pritsak <marianp@mellanox.com>
@lguohan
Copy link
Contributor

lguohan commented Oct 19, 2018

@marian-pritsak , there is conflict, can you resolve it?

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
Signed-off-by: Marian Pritsak <marianp@mellanox.com>
Signed-off-by: Marian Pritsak <marianp@mellanox.com>
Signed-off-by: Marian Pritsak <marianp@mellanox.com>
Signed-off-by: Marian Pritsak <marianp@mellanox.com>
@qiluo-msft
Copy link
Contributor

retest this please

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
Signed-off-by: Marian Pritsak <marianp@mellanox.com>
@prsunny
Copy link
Collaborator

prsunny commented Dec 8, 2018

retest this please

prsunny and others added 2 commits December 11, 2018 02:06
Signed-off-by: Marian Pritsak <marianp@mellanox.com>
@marian-pritsak
Copy link
Collaborator Author

@lguohan Fixed vs tests

@@ -836,6 +835,10 @@ def test_swss_port_state_syncup(dvs, testlog):
dvs.stop_swss()
time.sleep(3)

dvs.runcmd("ip addr flush dev Ethernet0")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use the same method as deleting from Interface table? intf_tbl._del.
It looks like we add one way and flush another way

# Defining create neighbor entries (4 ipv4 and 4 ip6, two each on each interface) in linux kernel
intf_tbl = swsscommon.Table(conf_db, "INTERFACE")
fvs = swsscommon.FieldValuePairs([("NULL","NULL")])
intf_tbl.set("Ethernet0|111.0.0.1/24", fvs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to use the same intfs list here as well for consistency, since that is used throughout the function?

@@ -1556,6 +1560,14 @@ def test_routing_WarmRestart(dvs, testlog):
rt_key = json.loads(addobjs[0]['key'])
assert rt_key['dest'] == "192.168.100.0/24"

intf_tbl._del("Ethernet0|111.0.0.1/24")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment to use intfs list

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
@prsunny
Copy link
Collaborator

prsunny commented Dec 14, 2018

@marian-pritsak , can you help look at the VS failure with the latest changes?

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
@marian-pritsak
Copy link
Collaborator Author

marian-pritsak commented Dec 15, 2018

@prsunny, routing warm reboot passes on my VM

@prsunny
Copy link
Collaborator

prsunny commented Dec 18, 2018

retest this please

@sonic-net sonic-net deleted a comment from marian-pritsak Dec 18, 2018
@marian-pritsak
Copy link
Collaborator Author

@prsunny I see that other PRs are failing on routingWarmRestart like #723

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
@prsunny prsunny merged commit 0c07a80 into sonic-net:master Dec 27, 2018
@jipanyang
Copy link
Contributor

@jipanyang, that's right. The loopback config is done via /etc/network. @marian-pritsak , I think intfmgr would need to subscribe for "CFG_LOOPBACK_INTERFACE_TABLE_NAME" as well and update the INTF_TABLE for "lo".

I didn't see this issue got addressed, or have I missed anything here?

oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
* [syncd] Fix notification on shutdown request

* Move check to the beginning of the function
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.

7 participants