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

[202012] fix dual-tor relay-reply handing issue #40

Merged
merged 20 commits into from
Jul 11, 2023
Merged
2 changes: 2 additions & 0 deletions .azure-pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
sudo apt-get install -y dotnet-sdk-6.0
displayName: install .Net
- script: |
set -ex
sudo apt-get update
sudo apt-get install -y \
libboost-system1.71-dev \
libboost-thread1.71-dev \
Expand Down
12 changes: 10 additions & 2 deletions src/configInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ bool pollSwssNotifcation = true;
std::shared_ptr<boost::thread> mSwssThreadPtr;
swss::Select swssSelect;

extern bool dual_tor_sock;

/**
* @code void initialize_swss()
*
Expand Down Expand Up @@ -116,15 +118,21 @@ void handleRelayNotification(swss::SubscriberStateTable &ipHelpersTable, std::un
void processRelayNotification(std::deque<swss::KeyOpFieldsValuesTuple> &entries, std::unordered_map<std::string, relay_config> &vlans)
{
std::vector<std::string> servers;
bool option_79_default = true;
bool interface_id_default = false;

if (dual_tor_sock) {
interface_id_default = true;
}

for (auto &entry: entries) {
std::string vlan = kfvKey(entry);
std::string operation = kfvOp(entry);
std::vector<swss::FieldValueTuple> fieldValues = kfvFieldsValues(entry);

relay_config intf;
intf.is_option_79 = true;
intf.is_interface_id = false;
intf.is_option_79 = option_79_default;
intf.is_interface_id = interface_id_default;
intf.interface = vlan;
intf.mux_key = "";
intf.state_db = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/configInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct swssNotification {
std::unordered_map<std::string, relay_config> vlans;
swss::SubscriberStateTable *ipHelpersTable;
};

/**
* @code void initialize_swss()
*
Expand Down
17 changes: 13 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@
#include "configInterface.h"

bool dual_tor_sock = false;
char loopback[IF_NAMESIZE] = "Loopback0";

static void usage()
{
printf("Usage: ./dhcp6relay {-d}\n");
printf("\t-d: enable dual tor option\n");
printf("Usage: ./dhcp6relay [-u <loopback interface>]\n");
jcaiMR marked this conversation as resolved.
Show resolved Hide resolved
printf("\tloopback interface: is the loopback interface for dual tor setup\n");
}

int main(int argc, char *argv[]) {
if (argc > 1) {
if (argc > 2) {
switch (argv[1][1])
{
case 'd':
case 'u':
if (strlen(argv[2]) != 0 && strlen(argv[2]) < IF_NAMESIZE) {
std::memset(loopback, 0, IF_NAMESIZE);
std::memcpy(loopback, argv[2], strlen(argv[2]));
} else {
syslog(LOG_ERR, "loopback interface name over length %d.\n", IF_NAMESIZE);
return 1;
}
dual_tor_sock = true;
break;
default:
fprintf(stderr, "%s: Unknown option\n", basename(argv[0]));
usage();
return 0;
}
}
try {
Expand Down
Loading