-
Notifications
You must be signed in to change notification settings - Fork 694
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
Changes from 4 commits
f9abf24
3dc6420
f9cae00
8c48f08
17ad529
fc730f9
425500a
a880c61
295afa2
7e84155
1304a59
0abb535
d6b1810
2e3f35c
1edff3c
ca35fd3
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(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If teamd exits, shouldn't we get netlink for interface down, as we registered earlier for netlink events in teamsyncd ? netlink.registerGroup(RTNLGRP_LINK);
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will, but by the time we get the netlink event, portsorch may have already started processing the port channel interface creation. |
||
| if (!m_teamdctl) | ||
| { | ||
| 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"); | ||
judyjoseph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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.