Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support single-active BGPaaS object attached to multiple VMIs
Closes-Bug: #1649707 Vrouter-Agent changes to support the multiple VMI interfaces for the given BGPAAS session - Changes to tweak the BGP service port number. 1. If the given BGP service port is X then the same will be shifted by the N number of bits to accomodate the additional VMI interfaces who are sharing this port. 2. It results in the different service port number during the flow configuration for each VMI interface. - Changes to configure the number of bits reserved to share the same service port across VMI interfaces 1. Added new varaible under SERVICE section vrouter-agent.conf file to configre the number of bits reserved to hold the multiple VMI interfaces. - Changes in the UT test cases to validate these changes 1. Test cases are added to share the same service port across multiple VMI interfaces 2. Test cases are added to valdiate the new variable addition to agent.conf file. UT Failure Fix : The changes added to verify the reverse flow in test_bgp_service is not working when the same test cases are run multiple times. This behavior is observed irrespective of the new changes. So to proceed further on this change, we have reverted those reverse flwo checks. Review Comments Handling : In the proposed change, have used local index allocator to keep track the usage of service ports by multiple VMI interfaces. It leads to store this local index across the reboots of compute nodes and will result in additional burden to resource manager to maintain one more state to keep track theses indexes for each service port. To avoid this additional burden, it is decided to re-use the VMI index which are allocated by the agent during the interface creation. This index will be used to identify the each VMI uniquely for the given service port. Some of the caveats with this re-use model as follows, - the reserved shift bits are not directly working with allocatted index, since both are defined seperately and working independently - if the VMI index is going beyond the allocated bits space then same will not be fit in the reserved space, eventhough there is enough space to store the indexes Assumption: - In the case of re-usage of same index during the VMI deletion and addition, the corresponding flows of deleted VMI interfaces will be deleted before adding the newer VMI with re-used index. Have handles all the review comments - updating the source port with newer source port, since the same will be used during the flow configuration. - Retained older source port to identify the users of the given service port from the config Review Comments Hanling-II: After discussion, the logic for the derived port is changed as per the below comment, https://bugs.launchpad.net/juniperopenstack/+bug/1649707/comments/17 Change-Id: Ia282380dfc3dd209d3916d8f64bce89e89c27994
- Loading branch information
Showing
12 changed files
with
353 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) 2017 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
|
||
#include <base/bgp_as_service_utils.h> | ||
/* | ||
* This utils apis will be used by BGP As A Service feature to map | ||
* between the original service port allocated for the given BgpAsAService | ||
* session and the derived service port for each VMI who is sharing the same | ||
* session | ||
* GetDerivedBgpaasServicePortRange - From the given config port range and max | ||
* session, derive the internal port range | ||
* Port range and maximum number of VMIs who is sharing the given BgpAsAService | ||
* session will be given by config | ||
* EncodeBgpaasServicePort - For the given original service port and | ||
* index, derive the service port which will be used by the corresponding | ||
* flow which is associated with the corresponding VMI. | ||
* DecodeBgpaasServicePort - For the given service port, decode the | ||
* original service port and the index for the given port. | ||
*/ | ||
using namespace std; | ||
void BgpaasUtils::GetDerivedBgpaasServicePortRange( | ||
const uint16_t port_range_start, | ||
const uint16_t port_range_end, | ||
const uint32_t max_session, | ||
uint16_t &bgpaas_der_port_start, | ||
uint16_t &bgpaas_der_port_end) { | ||
uint32_t total_der_ports = (port_range_end - port_range_start) * | ||
max_session; | ||
if ( (total_der_ports + port_range_end + 1) > USHRT_MAX) { | ||
bgpaas_der_port_start = bgpaas_der_port_start - total_der_ports; | ||
bgpaas_der_port_end = port_range_start - 1; | ||
} else { | ||
bgpaas_der_port_start = port_range_end + 1; | ||
bgpaas_der_port_end = bgpaas_der_port_start + total_der_ports; | ||
} | ||
} | ||
|
||
BgpaasUtils::BgpAsServicePortIndexPair BgpaasUtils::DecodeBgpaasServicePort( | ||
const uint32_t sport, | ||
const uint32_t max_session, | ||
const uint16_t port_range_start, | ||
const uint16_t port_range_end) { | ||
size_t index = 0; | ||
uint32_t original_sport; | ||
|
||
if ((sport >= port_range_start) && | ||
(sport <= port_range_end)) { | ||
return std::make_pair(sport, index); | ||
} | ||
|
||
uint16_t bgpaas_der_port_start = 0; | ||
uint16_t bgpaas_der_port_end = 0; | ||
GetDerivedBgpaasServicePortRange(port_range_start, | ||
port_range_end, | ||
max_session, | ||
bgpaas_der_port_start, | ||
bgpaas_der_port_end); | ||
|
||
original_sport = ((sport - bgpaas_der_port_start) / (max_session - 1)) | ||
+ port_range_start; | ||
index = ((sport - bgpaas_der_port_start) % (max_session - 1)) + 1; | ||
|
||
return std::make_pair(original_sport, index); | ||
} | ||
|
||
uint32_t BgpaasUtils::EncodeBgpaasServicePort(const uint32_t sport, | ||
const size_t index, | ||
const uint32_t max_session, | ||
const uint16_t port_range_start, | ||
const uint16_t port_range_end) { | ||
if (!index) { | ||
return sport; | ||
} | ||
|
||
uint16_t bgpaas_der_port_start = 0; | ||
uint16_t bgpaas_der_port_end = 0; | ||
GetDerivedBgpaasServicePortRange(port_range_start, | ||
port_range_end, | ||
max_session, | ||
bgpaas_der_port_start, | ||
bgpaas_der_port_end); | ||
|
||
return (bgpaas_der_port_start + ((sport - port_range_start) | ||
* (max_session - 1)) | ||
+ (index - 1)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2017 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
|
||
#ifndef ctrlplane_bgp_as_service_utils_h | ||
#define ctrlplane_bgp_as_service_utils_h | ||
#include <stdlib.h> | ||
#include <limits.h> | ||
#include <inttypes.h> | ||
#include <utility> | ||
|
||
class BgpaasUtils { | ||
public: | ||
typedef std::pair<uint32_t, size_t> BgpAsServicePortIndexPair; | ||
static void GetDerivedBgpaasServicePortRange( | ||
const uint16_t port_range_start, | ||
const uint16_t port_range_end, | ||
const uint32_t max_session, | ||
uint16_t &bgpaas_der_port_start, | ||
uint16_t &bgpaas_der_port_end); | ||
static uint32_t EncodeBgpaasServicePort(const uint32_t sport, | ||
const size_t index, | ||
const uint32_t max_session, | ||
const uint16_t port_range_start, | ||
const uint16_t port_range_end); | ||
static BgpAsServicePortIndexPair DecodeBgpaasServicePort( | ||
const uint32_t sport, | ||
const uint32_t max_session, | ||
const uint16_t port_range_start, | ||
const uint16_t port_range_end); | ||
}; | ||
|
||
#endif // ctrlplane_bgp_service_utils_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.