-
Notifications
You must be signed in to change notification settings - Fork 694
Populate existing interface cache, bring down before configDone #491
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
02adea5
Populate existing interface cache, bring down before configDone
prsunny 2aaffb2
Merge branch 'master' of git://github.com/prsunny/sonic-swss into prs…
lguohan 28f8227
simplify the logic and add logging
lguohan c83aa28
add logging for publish event to state db
lguohan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| #include "dbconnector.h" | ||
| #include "producerstatetable.h" | ||
| #include "tokenize.h" | ||
| #include "exec.h" | ||
|
|
||
| #include "linkcache.h" | ||
| #include "portsyncd/linksync.h" | ||
|
|
@@ -28,6 +29,13 @@ const string LAG_PREFIX = "PortChannel"; | |
| extern set<string> g_portSet; | ||
| extern bool g_init; | ||
|
|
||
| struct if_nameindex | ||
| { | ||
| unsigned int if_index; | ||
| char *if_name; | ||
| }; | ||
| extern "C" { extern struct if_nameindex *if_nameindex (void) __THROW; } | ||
|
|
||
| LinkSync::LinkSync(DBConnector *appl_db, DBConnector *state_db) : | ||
| m_portTableProducer(appl_db, APP_PORT_TABLE_NAME), | ||
| m_portTable(appl_db, APP_PORT_TABLE_NAME), | ||
|
|
@@ -49,6 +57,37 @@ LinkSync::LinkSync(DBConnector *appl_db, DBConnector *state_db) : | |
| } | ||
| } | ||
| } | ||
|
|
||
| struct if_nameindex *if_ni, *idx_p; | ||
| if_ni = if_nameindex(); | ||
| if (if_ni == NULL) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| for (idx_p = if_ni; ! (idx_p->if_index == 0 && idx_p->if_name == NULL); idx_p++) | ||
| { | ||
| string key = idx_p->if_name; | ||
| if (key.compare(0, INTFS_PREFIX.length(), INTFS_PREFIX)) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| m_ifindexOldNameMap[idx_p->if_index] = key; | ||
|
|
||
| //Bring down the existing kernel interfaces before notifying ConfigDone | ||
| string cmd, res; | ||
| cout << "Executing ip link set " << key << " down - ifindex " << idx_p->if_index << endl; | ||
| cmd = "ip link set " + key + " down "; | ||
| try | ||
| { | ||
| swss::exec(cmd, res); | ||
| } | ||
| catch (...) | ||
| { | ||
| // Ignore error in this flow ; | ||
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj) | ||
|
|
@@ -105,16 +144,9 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj) | |
| * Fix to ignore this and any further messages for this ifindex | ||
| */ | ||
|
|
||
| static std::map<unsigned int, std::string> m_ifindexOldNameMap; | ||
| if (m_ifindexNameMap.find(ifindex) == m_ifindexNameMap.end()) | ||
| { | ||
| if (master) | ||
| { | ||
| m_ifindexOldNameMap[ifindex] = key; | ||
| SWSS_LOG_INFO("nlmsg type:%d Ignoring for %d, master %d", nlmsg_type, ifindex, master); | ||
| return; | ||
| } | ||
| else if (m_ifindexOldNameMap.find(ifindex) != m_ifindexOldNameMap.end()) | ||
| if (m_ifindexOldNameMap.find(ifindex) != m_ifindexOldNameMap.end()) | ||
| { | ||
| if (m_ifindexOldNameMap[ifindex] == key) | ||
| { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should use swss_log