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

Change nexthop key to ip & ifname #977

Merged
merged 10 commits into from
Oct 2, 2019
Merged

Conversation

tylerlinp
Copy link
Contributor

What I did
Changed nexthop key including ifname.
Made a supplement to vs test of ACL redirect.

Why I did it
To implement VRF, single IP cannot indicate nexthop uniquely.

How I verified it
vs test

Details if related

@tylerlinp
Copy link
Contributor Author

tylerlinp commented Jul 17, 2019

[MirrorOrch]: Init the next hop ip with 0 instead of default constructor
@lguohan lguohan requested a review from prsunny July 26, 2019 21:30
orchagent/neighorch.cpp Show resolved Hide resolved
orchagent/intfsorch.cpp Show resolved Hide resolved

// TODO: set to blackhold if nexthop is empty?
if (ip_addresses.getSize() == 0)
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, if ips = "", you can erase and continue. I don't think we have to introduce 0.0.0.0 to handle this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Introduce 0.0.0.0 is to prepare for handling directly connected routes. It is better to keep ips and aliases same size, in general handling tokenize("", ',') will get empty vector. Zero ip would be used to construct NextHopGroupKey.

@@ -325,6 +325,17 @@ string RouteSync::getNextHopGw(struct rtnl_route *route_obj)
nl_addr2str(addr, gw_ip, MAX_ADDR_SIZE);
result += gw_ip;
}
else
{
if (rtnl_route_get_family(route_obj) == AF_INET)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this change? The RouteOrch can delete the entry if nexthop.size == 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.

As above.

}

inline bool operator<(const NextHopGroupKey &o) const
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need these operators for NHGroupKey. I don't see the usage elsewhere. Please remove if not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe useless, NextHopGroupKey just extended from IpAddresses.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the unused functions

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 used actually. NextHopGroupKey is used as map key. Compare function is needed for map key. So overload operator< is needed.

fvs = swsscommon.FieldValuePairs([
("priority", "100"),
("L4_SRC_PORT", "65000"),
("PACKET_ACTION", "REDIRECT:10.0.0.2|Ethernet4")])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a schema change, Can you update the swss-schema.md ?

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. I will update later.

return port.m_rif_id;
}

string IntfsOrch::getRouterIntfsAlias(const IpAddress &ip)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is ambiguous as same IP can be existing on multiple interfaces in a multi VRF scenario. I don't think we can have a function like this. Is it for some backward compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function will add a vrf argument to support VRF. The VRF PR includes this. Mirror session is using it now, in getNeighborEntry.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add VRF argument to this function in this PR? It can pass default vrf from the caller.

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, actually I had removed it just for this PR.

orchagent/mirrororch.cpp Show resolved Hide resolved

#define NHFLAGS_IFDOWN 0x1 // nexthop's outbound i/f is down

struct NeighborEntry
struct NextHopKey
Copy link
Collaborator

Choose a reason for hiding this comment

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

To me it looks better to be named as NeighborKey than NextHopKey.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now NeighborEntry is same as NextHopKey, I think NeighborEntry can be named as NeighborKey, but I haven't changed it. It is better to distinguish nexthop and neighbor, in some cases just need nexthop although now they are created together.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My thought is, it is Neighorch and this is the key structure. So with NeighborKey, it aligns with the neighbor orch functionality. Nexthop is created from the Neighbor. Just a suggestion to think, not a blocker

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Prince to replace the NextHopKey with NeighborKey and also remove the NeighborEntry. Otherwise it is confusing to have various class names.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, since the two classes NextHopKey and NextHopGroupKey are very large. Please move them outside the header and create a separate header file and the implementation file.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think NexthopKey semantic is more than NeighborKey. A Route has nexthop but not neigh. Neigh can reuse NexthopKey as NeighborKey. But route can't use NeighborKey as nexthop.
Spliting Nexthopkey and NextHopGroupKey is good idea. We will fix it soon.

@stcheng stcheng self-requested a review August 12, 2019 23:27
@prsunny
Copy link
Collaborator

prsunny commented Aug 14, 2019

@tylerlinp , we need to make sure that an old config_db.json with ACL redirect/Mirror session without ifname in schema also shall work with this changes. It is expected to work as if in default VRF.

@shine4chen
Copy link
Contributor

@tylerlinp , we need to make sure that an old config_db.json with ACL redirect/Mirror session without ifname in schema also shall work with this changes. It is expected to work as if in default VRF.

@prsunny Sure, we will revise our HLD and code. In fact We doesn't change mirror session schema in current VRF PR. So mirror backward compatibility is not issue. For Acl redirect we can add support for single ip without interface name.

Copy link

@karthikarum karthikarum left a comment

Choose a reason for hiding this comment

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

we don't have any additional comments.

@prsunny
Copy link
Collaborator

prsunny commented Sep 12, 2019

retest this please

1 similar comment
@prsunny
Copy link
Collaborator

prsunny commented Sep 12, 2019

retest this please

Copy link
Contributor

@stcheng stcheng left a comment

Choose a reason for hiding this comment

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

Could you


#define NHFLAGS_IFDOWN 0x1 // nexthop's outbound i/f is down

struct NeighborEntry
struct NextHopKey
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with Prince to replace the NextHopKey with NeighborKey and also remove the NeighborEntry. Otherwise it is confusing to have various class names.


#define NHFLAGS_IFDOWN 0x1 // nexthop's outbound i/f is down

struct NeighborEntry
struct NextHopKey
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, since the two classes NextHopKey and NextHopGroupKey are very large. Please move them outside the header and create a separate header file and the implementation file.

NextHopKey(const IpAddress &ip, const std::string &alias) : ip_address(ip), alias(alias) {}
NextHopKey(const std::string &str)
{
if (str.find(',') != string::npos)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need this check?

Copy link
Contributor

Choose a reason for hiding this comment

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

It originally come from ipAddress class. Some apps use multi-ipaddresses string to create NexthopKey class. It needs to throw an exception to reminder the apps to use NexthopGroupKey class

@@ -1215,6 +1215,141 @@ def test_AclRuleIcmpV6(self, dvs, testlog):

self.remove_acl_table(acl_table)

def set_admin_status(self, interface, status):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move these helper functions into conftest.py file?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we will do 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.

I have done this in PR #943.

tbl._del(interface + "|" + ip)
time.sleep(1)

def test_AclRuleRedirectToNexthop(self, dvs, testlog):
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is to test a new functionality, could you move this portion into a separate PR?
It could be better to add some unit tests that covers the current changes

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact ACL redirect is the existing function. But no vs test cases can cover it. Since we change nexthop key we add a test case to verify if this function works.

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 have removed the test in this PR and revised it in PR #943. So all new unit tests are added in PR #943.

@prsunny
Copy link
Collaborator

prsunny commented Sep 18, 2019

retest this please

@@ -1,5 +1,9 @@
sonic (1.0.0) stable; urgency=medium

* next-hop key add ifname
Copy link
Contributor

Choose a reason for hiding this comment

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

please keep the changelog as it is since right now we're not updating this file routinely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New version dpkg-deb use the newest time in chaneglog to set deb files timestamp. There is a problem that new files with same size and timestamp cannot be saved to image in process of PR build, so in this PR fpmsynd cannot be updated and many test cases failed. I add changelog just for building swss.deb with newer timestamp and pass tests.
THE PROBLEM MUST BE RESOLVED, or else the VS test become meaningless, for the running version may not be the codes compiled.

Copy link
Contributor

Choose a reason for hiding this comment

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

are you referring to the VS test running under this pull request? and the fpmsyncd is not replaced with the latest binary? if that is the case as you described, I'll check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes,I have forward the email which describes this issue detailly to you. It is common issue, not just on this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

could you check right now if the binaries could overwrite the old ones?
I have added Azure/sonic-build-tools@e9e3957 to fix this issue.

@stcheng
Copy link
Contributor

stcheng commented Sep 19, 2019

could you also resolve the conflicts? thanks!

@qiluo-msft qiluo-msft self-requested a review September 19, 2019 22:19
Tyler Li added 2 commits September 19, 2019 18:31
1. create separate file for NextHopKey and NextHopGroupKey
2. remove test_AclRuleRedirectToNexthop
@shine4chen
Copy link
Contributor

shine4chen commented Sep 20, 2019

@prsunny @stcheng we have resolved the conflicts and address your comments.After changing the timestamp of changelog file, all files can be updated and this PR passed all vs test cases.

@prsunny
Copy link
Collaborator

prsunny commented Sep 23, 2019

retest this please

…thop_key

Resolve conflicts and change nexthop delimiter to '@'

 Conflicts:
	orchagent/mirrororch.cpp
 Modifications:
        doc/swss-schema.md
        orchagent/nexthopkey.h
        orchagent/nexthopgroupkey.h
@tylerlinp
Copy link
Contributor Author

retest this please

Copy link
Contributor

@stcheng stcheng left a comment

Choose a reason for hiding this comment

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

it's better not to update the changelog

@@ -1,5 +1,9 @@
sonic (1.0.0) stable; urgency=medium

* next-hop key add ifname
Copy link
Contributor

Choose a reason for hiding this comment

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

could you check right now if the binaries could overwrite the old ones?
I have added Azure/sonic-build-tools@e9e3957 to fix this issue.

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.

5 participants