-
Notifications
You must be signed in to change notification settings - Fork 648
Connect to teamd before adding the lag to STATE_DB #3984
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
f9abf24
3dc6420
f9cae00
8c48f08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,8 @@ | |
| #include "warm_restart.h" | ||
| #include "teamsync.h" | ||
|
|
||
| #include <team.h> | ||
| #include <teamdctl.h> | ||
| #include <unistd.h> | ||
|
|
||
| using namespace std; | ||
|
|
@@ -279,19 +281,51 @@ TeamSync::TeamPortSync::TeamPortSync(const string &lagName, int ifindex, | |
| "Unable to register port change event"); | ||
| } | ||
|
|
||
| struct teamdctl *m_teamdctl = teamdctl_alloc(); | ||
| if (!m_team) | ||
saiarcot895 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| team_free(m_team); | ||
| m_team = NULL; | ||
| throw system_error(make_error_code(errc::address_not_available), | ||
| "Unable to allocate teamdctl socket"); | ||
| } | ||
|
|
||
| err = teamdctl_connect(m_teamdctl, lagName.c_str(), nullptr, "usock"); | ||
| if (err) | ||
| { | ||
| team_free(m_team); | ||
| m_team = NULL; | ||
| teamdctl_free(m_teamdctl); | ||
| throw system_error(make_error_code(errc::connection_refused), | ||
| "Unable to connect to teamd"); | ||
| } | ||
|
|
||
| char *response; | ||
| err = teamdctl_config_get_raw_direct(m_teamdctl, &response); | ||
|
||
| if (err) | ||
| { | ||
| team_free(m_team); | ||
| m_team = NULL; | ||
| teamdctl_disconnect(m_teamdctl); | ||
| teamdctl_free(m_teamdctl); | ||
| throw system_error(make_error_code(errc::io_error), | ||
| "Unable to get config from teamd (to prove that it is running and alive)"); | ||
| } | ||
|
|
||
| teamdctl_disconnect(m_teamdctl); | ||
| teamdctl_free(m_teamdctl); | ||
|
|
||
| break; | ||
| } | ||
| catch (const system_error& e) | ||
| { | ||
| SWSS_LOG_WARN("Failed to initialize team handler. LAG=%s error=%d:%s, attempt=%d", | ||
| lagName.c_str(), e.code().value(), e.what(), count); | ||
|
|
||
| if (++count == max_retries) | ||
| { | ||
| throw; | ||
| } | ||
| else | ||
| { | ||
| SWSS_LOG_WARN("Failed to initialize team handler. LAG=%s error=%d:%s, attempt=%d", | ||
| lagName.c_str(), e.code().value(), e.what(), count); | ||
| } | ||
|
|
||
| sleep(1); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maintainability: These includes are already present in teamsync.h (lines 12-13), which is included on line 13. The duplicate includes are redundant and should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a stylistic choice to explicitly include what I'm using in this file, so that if the header files change, this file doesn't require changing.