Skip to content

Commit

Permalink
[cfgmgr]: Integrate MACsecMGR with sonic-buildimage (#1627)
Browse files Browse the repository at this point in the history
1. Fix bug about the return value of `get_value`, it should return `true` if it's OK
2. Fix bug about the type of `MACsecProfile::priority`, the original `uint8_t` will cause a `lexical_convert` failure when the priority is a integer.
3. Polish log in `get_value`.
4. Change the predefined paths for sonic-buildimage integration

Signed-off-by: Ze Gan <[email protected]>
  • Loading branch information
Pterosaur authored Feb 4, 2021
1 parent 5384ace commit c7f27c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
23 changes: 15 additions & 8 deletions cfgmgr/macsecmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
using namespace std;
using namespace swss;

#define WPA_SUPPLICANT_CMD "./wpa_supplicant"
#define WPA_CLI_CMD "./wpa_cli"
#define WPA_CONF "./wpa.conf"
// #define SOCK_DIR "/var/run/macsec/"
#define SOCK_DIR "./"
#define WPA_SUPPLICANT_CMD "/sbin/wpa_supplicant"
#define WPA_CLI_CMD "/sbin/wpa_cli"
#define WPA_CONF "/etc/wpa_supplicant.conf"
#define SOCK_DIR "/var/run/"

constexpr std::uint64_t RETRY_TIME = 30;

Expand Down Expand Up @@ -64,13 +63,21 @@ static bool get_value(
auto value_opt = swss::fvsGetValue(ta, field, true);
if (!value_opt)
{
SWSS_LOG_WARN("Cannot find field : %s", field.c_str());
SWSS_LOG_DEBUG("Cannot find field : %s", field.c_str());
return false;
}

lexical_convert(*value_opt, value);
try
{
lexical_convert(*value_opt, value);
}
catch(const boost::bad_lexical_cast &e)
{
SWSS_LOG_ERROR("Cannot convert value(%s) in field(%s)", value_opt->c_str(), field.c_str());
return false;
}

return false;
return true;
}

static void wpa_cli_commands(std::ostringstream & ostream)
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/macsecmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MACsecMgr : public Orch
using TaskArgs = std::vector<FieldValueTuple>;
struct MACsecProfile
{
std::uint8_t priority;
std::uint32_t priority;
std::string cipher_suite;
std::string primary_cak;
std::string primary_ckn;
Expand Down
2 changes: 1 addition & 1 deletion cfgmgr/macsecmgrd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main(int argc, char **argv)

try
{
// Logger::linkToDbNative("macsecmgrd");
Logger::linkToDbNative("macsecmgrd");
SWSS_LOG_NOTICE("--- Starting macsecmgrd ---");

swss::DBConnector cfgDb("CONFIG_DB", 0);
Expand Down

0 comments on commit c7f27c8

Please sign in to comment.