Skip to content

Multi-asic changes for config bgp commands and utilities.#910

Merged
judyjoseph merged 4 commits intosonic-net:masterfrom
judyjoseph:bgp_cmds
May 21, 2020
Merged

Multi-asic changes for config bgp commands and utilities.#910
judyjoseph merged 4 commits intosonic-net:masterfrom
judyjoseph:bgp_cmds

Conversation

@judyjoseph
Copy link
Contributor

@judyjoseph judyjoseph commented May 12, 2020

- What I did

Changes to config bgp commands for Multi-ASIC devices.

- How I did it

The changes done here are based on the namespace support added in SonicDBConfig/ConfigDBConnector/SonicV2Connector classes in the PR sonic-net/sonic-py-swsssdk#63

To connect to DB in a particular namespace pass the parameter namespace=namespaceName
To connect to the DB in the local context ( where ever we are ) don't pass any namespace input, it would be defaulted to '' (empty string ). This is the default option, so that the changes made here are backward compatible with single ASIC platforms.

The following are the changes introduced in this PR

(a) added a new parameter of config_db to the bgp neighbor helper API's. This approach is better, as now we have to do this once config_db = ConfigDBConnector() in the CLI handler and the config_db instance is passed down as argument to the API.

(b) Modified the API _get_all_neighbor_ipaddresses() to accept an additional parameter ignore_hosts if there are any hosts to be ignored when forming the ip_addr neighbor list.

(c) config bgp commands : In multi-ASIC devices we have both internal BGP sessions between the bgp dockers running in different namespaces and EBGP sessions with external neighbors.

config bgp startup/shutdown all : performs "action" only on the external BGP neighbors.
config bgp startup/shutdown/remove neighbor : performs "action" on any internal/external BGP neighbor based on user input. User has to be careful of not giving the neighbor address of IBGP sessions.

- How to verify it
Verified on a multi-ASIC devices, by running the Config commands.

- Previous command output (if the output of a command-line utility has changed)

- New command output (if the output of a command-line utility has changed)

@judyjoseph judyjoseph requested a review from jleveque May 12, 2020 16:20
jleveque
jleveque previously approved these changes May 12, 2020
@jleveque
Copy link
Contributor

LGTM. Wait for Guohan and Pavel to review.

pavel-shirshov
pavel-shirshov previously approved these changes May 12, 2020
@rlhui
Copy link
Contributor

rlhui commented May 13, 2020

retest this please.

judyjoseph added a commit that referenced this pull request May 13, 2020
@jleveque
Copy link
Contributor

Retest this please

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

I left some comments. Can you please check?

def _get_all_neighbor_ipaddresses(config_db, ignore_local_hosts=False):
"""Returns list of strings containing IP addresses of all BGP neighbors
if the flag ignore_local_hosts is set to True, additional check to see if
if the BGP neighbor AS number is same as local BGP AS number, if so ignore that neigbor.
Copy link
Contributor

Choose a reason for hiding this comment

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

so the name of the function is missleading, because you're filtering out peer with local bgp AS?
Also, we could have dynamic bgp neighbors and bgp_monitor entries.
Should we include them here?

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 was an existing function, to which I added a new parameter ignore_local_hosts to do bgp AS based filtering. I will change the name of the function.

Currently all the functions look in the BGP_NEIGHBOR table alone, we need change in all API's to check the other BGP tables as well. BGP DYNAMIC PEERS and BGP MONITORS. We could do it separately in a different PR if that is ok


if not ip_addrs:
click.get_current_context().fail("Could not locate neighbor '{}'".format(ipaddr_or_hostname))
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.

why the error message was removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These error message are not removed, the "same" message is now moved into the bgp command handlers ( eg: https://github.com/Azure/sonic-utilities/blob/33899cfe36018b8c6b03e9dbd125dfe117c8b56a/config/main.py#L1709 ). This is because for a specific neighbor shut/start case in multi-asic platform, we check in all bgp instances if the neighbor exists before declaring "not exist" with the ERROR message.

@judyjoseph judyjoseph merged commit 221b593 into sonic-net:master May 21, 2020
@judyjoseph judyjoseph deleted the bgp_cmds branch May 21, 2020 05:24
@judyjoseph judyjoseph restored the bgp_cmds branch May 21, 2020 05:24
@judyjoseph judyjoseph deleted the bgp_cmds branch May 21, 2020 05:24
abdosi pushed a commit that referenced this pull request May 21, 2020
* Multi-asic changes for config bgp commands and utilities.

* Review comments update

* Optimized the logic of checking the internal hosts using AS number.

* API changes due to rebase. Also setting ignore_local_hosts=false explicitly in BGP commands so that existing single ASIC platform implementation is unchanged.
abdosi pushed a commit to abdosi/sonic-utilities that referenced this pull request Aug 4, 2020
)

* Multi-asic changes for config bgp commands and utilities.

* Review comments update

* Optimized the logic of checking the internal hosts using AS number.

* API changes due to rebase. Also setting ignore_local_hosts=false explicitly in BGP commands so that existing single ASIC platform implementation is unchanged.
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 28, 2022
 Revert "[config] Add 'interface transceiver' subgroup with 'lpmode' and
 'reset' subcommands (sonic-net#904)"
  Multi-asic changes for config bgp commands and utilities. (sonic-net#910)
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