Skip to content

Commit c7f27c8

Browse files
authored
[cfgmgr]: Integrate MACsecMGR with sonic-buildimage (#1627)
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]>
1 parent 5384ace commit c7f27c8

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

cfgmgr/macsecmgr.cpp

+15-8
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
using namespace std;
2525
using namespace swss;
2626

27-
#define WPA_SUPPLICANT_CMD "./wpa_supplicant"
28-
#define WPA_CLI_CMD "./wpa_cli"
29-
#define WPA_CONF "./wpa.conf"
30-
// #define SOCK_DIR "/var/run/macsec/"
31-
#define SOCK_DIR "./"
27+
#define WPA_SUPPLICANT_CMD "/sbin/wpa_supplicant"
28+
#define WPA_CLI_CMD "/sbin/wpa_cli"
29+
#define WPA_CONF "/etc/wpa_supplicant.conf"
30+
#define SOCK_DIR "/var/run/"
3231

3332
constexpr std::uint64_t RETRY_TIME = 30;
3433

@@ -64,13 +63,21 @@ static bool get_value(
6463
auto value_opt = swss::fvsGetValue(ta, field, true);
6564
if (!value_opt)
6665
{
67-
SWSS_LOG_WARN("Cannot find field : %s", field.c_str());
66+
SWSS_LOG_DEBUG("Cannot find field : %s", field.c_str());
6867
return false;
6968
}
7069

71-
lexical_convert(*value_opt, value);
70+
try
71+
{
72+
lexical_convert(*value_opt, value);
73+
}
74+
catch(const boost::bad_lexical_cast &e)
75+
{
76+
SWSS_LOG_ERROR("Cannot convert value(%s) in field(%s)", value_opt->c_str(), field.c_str());
77+
return false;
78+
}
7279

73-
return false;
80+
return true;
7481
}
7582

7683
static void wpa_cli_commands(std::ostringstream & ostream)

cfgmgr/macsecmgr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MACsecMgr : public Orch
2727
using TaskArgs = std::vector<FieldValueTuple>;
2828
struct MACsecProfile
2929
{
30-
std::uint8_t priority;
30+
std::uint32_t priority;
3131
std::string cipher_suite;
3232
std::string primary_cak;
3333
std::string primary_ckn;

cfgmgr/macsecmgrd.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
4747

4848
try
4949
{
50-
// Logger::linkToDbNative("macsecmgrd");
50+
Logger::linkToDbNative("macsecmgrd");
5151
SWSS_LOG_NOTICE("--- Starting macsecmgrd ---");
5252

5353
swss::DBConnector cfgDb("CONFIG_DB", 0);

0 commit comments

Comments
 (0)