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

BgpUtils-fix-for-clean-up-for-FRR #49

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

banswamy
Copy link
Contributor

@banswamy banswamy commented Dec 14, 2022

Signed-off-by: bmswamy [email protected]

Prerequisites

  • I have read the Contributing Guidelines.
  • I have read the Code of Conduct.
  • If this is a non-trivial change, I have already opened an accompanying Issue.
  • If applicable, I have included documentation updates alongside my code changes.

Description

BgpUtils fix for clean up for FRR

Test Plan

  • Tested the below commands

  • show bgp ipv6 unicast summary json

  • show bgp ipv6 unicast neighbor {ip} routes json

  • show bgp ipv6 unicast neighbor {ip} advertised-routes json

  • Tested the above commands Json information as per task

  • I have added the tested logs below :

LOGS :

I1214 17:41:15.980036 3782 Broker.cpp:348] Disconnecting from controller on url tcp://[2002:db8:0:1::1]:7007
I1214 17:41:15.980118 3782 Broker.cpp:364] Connecting to controller on url tcp://[2002:db8:0:1::1]:7007
E1214 17:41:16.462097 3793 BgpUtils.cpp:215] bgp summary
E1214 17:41:16.462143 3793 BgpUtils.cpp:220] 2620:10d:c089:603::2
E1214 17:41:16.462155 3793 BgpUtils.cpp:224] 1
E1214 17:41:16.462167 3793 BgpUtils.cpp:228] 65123
E1214 17:41:16.462177 3793 BgpUtils.cpp:232] 01:33:27
E1214 17:41:16.462186 3793 BgpUtils.cpp:236] Established
E1214 17:41:16.462194 3793 BgpUtils.cpp:237] *************************************************************************************************
E1214 17:41:16.935168 3793 BgpUtils.cpp:547] Recived Routes

E1214 17:41:16.935207 3793 BgpUtils.cpp:549] print network:2620:10d:c089:800::/56
E1214 17:41:16.935225 3793 BgpUtils.cpp:557] Next hop printing:2620:10d:c089:603::2
E1214 17:41:16.935236 3793 BgpUtils.cpp:561] ********************************************************************************
E1214 17:41:16.935245 3793 BgpUtils.cpp:547] Recived Routes

E1214 17:41:16.935254 3793 BgpUtils.cpp:549] print network:::/0
E1214 17:41:16.935264 3793 BgpUtils.cpp:557] Next hop printing:2620:10d:c089:603::2
E1214 17:41:16.935274 3793 BgpUtils.cpp:561] ********************************************************************************
E1214 17:41:17.526739 3793 BgpUtils.cpp:582] advertisedRoutes
**
E1214 17:41:17.526778 3793 BgpUtils.cpp:585] print network:2620:10d:c089:9520::/60
E1214 17:41:17.526791 3793 BgpUtils.cpp:591] Next hop printing:2620:10d:c089:603::4
E1214 17:41:17.526803 3793 BgpUtils.cpp:594] ********************************************************************************
I1214 17:41:17.527005 3793 StatusApp.cpp:1515] Reporting status to controller

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 14, 2022
Copy link
Contributor

@elludraon elludraon left a comment

Choose a reason for hiding this comment

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

Code does not compile.
You did not handle any errors and this will crash in a lot of places.
Please format your code properly like surrounding code. 80 chars per line, 2 spaces to indent, inline {} braces, etc...

Will do a real review after basics are addressed.

receivedRoutesFormat = kVtyshQuaggaGetBgpReceivedRoutesFormat;
} else /* if (versionOutput.value().rfind("FRRouting", 0) == 0) */ {

//FRROUTING
Copy link
Contributor

Choose a reason for hiding this comment

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

a lot of these new comments are unnecessary... please delete them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the review comments

for (int i = 0; i < neighborCount; ++i) {
// BGP Headers:
// Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
// dynamic object for bgpSummary
Copy link
Contributor

Choose a reason for hiding this comment

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

delete

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the review comments

// dynamic object for bgpSummary
folly::dynamic bgpSummaryInfo = folly::dynamic::object;

bgpSummaryInfo = folly::parseJson(bgpSummary)["peers"];
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to handle errors in parseJson() or else this code will crash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the review comments

}

// Vtysh Bgp Recived Routes Info List
Copy link
Contributor

Choose a reason for hiding this comment

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

delete

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the review comments

unsigned int rowStartIdx = 0;
for (int i = 0; i < rowCount; ++i) {
// Skip the first entry on each row since it is the status code
BgpUtils::createVtyshBgpRecivedRouteInfoList(const std::string &recivedRoutes, const std::string &key, const std::string &value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

  • fix typo "Recived"
  • 80 chars per line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the review comments

}
// Vtysh Bgp Advertised Routes Info List
std::vector<thrift::BgpRouteInfo>
BgpUtils::createVtyshBgpAdvertisedRouteInfoList(const std::string &advertisedRoutes, const std::string &key, const std::string &value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

80 chars per line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the review comments


/**
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

delete extra leading space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the review comments

* Creates a list of thrift::BgpRouteInfo by taking the 'Network' and
* 'Next Hop' values of the vtysh table entries it receives.
* 'Next Hop' values of the vtysh json entries it Advertised Routes.
Copy link
Contributor

Choose a reason for hiding this comment

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

grammar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed the review comments

std::vector<std::string>& headers,
std::vector<std::string>& entries);
static std::vector<thrift::BgpRouteInfo> createVtyshBgpRecivedRouteInfoList(
(const std::string& recivedRoutesInfo,const std::string& key,const std::string& value);
Copy link
Contributor

Choose a reason for hiding this comment

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

extra paren, this code does not compile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry for this I made changes while I am doing the alignment it happened

static std::vector<thrift::BgpRouteInfo> createVtyshBgpRouteInfoList(
int numOfRows, const std::vector<std::string>& entries);
static std::vector<thrift::BgpRouteInfo> createVtyshBgpAdvertisedRouteInfoList(
(const std::string& recivedRoutesInfo,const std::string& key,const std::string& value);
Copy link
Contributor

Choose a reason for hiding this comment

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

extra paren, this code does not compile

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry for this while I am doing the alignment it happened

Copy link
Contributor

@elludraon elludraon left a comment

Choose a reason for hiding this comment

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

Some comments were not properly addressed and formatting is still all over the place.

try {
bgpSummaryInfo = folly::parseJson(bgpSummary)["peers"];
} catch (const std::exception& ex) {
throw std::invalid_argument("Could not parse bgp summary ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please do not re-throw an error... it is not caught. It will crash the program.

advertisedRoutesFormat = kVtyshQuaggaGetBgpAdvertisedRoutesFormat;
receivedRoutesFormat = kVtyshQuaggaGetBgpReceivedRoutesFormat;
} else /* if (versionOutput.value().rfind("FRRouting", 0) == 0) */ {
if (versionOutput.value().rfind("FRRouting", 0) == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment was not addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants