Skip to content

Populate existing interface cache, bring down before configDone#491

Merged
lguohan merged 4 commits intosonic-net:masterfrom
prsunny:master
May 1, 2018
Merged

Populate existing interface cache, bring down before configDone#491
lguohan merged 4 commits intosonic-net:masterfrom
prsunny:master

Conversation

@prsunny
Copy link
Copy Markdown
Collaborator

@prsunny prsunny commented May 1, 2018

What I did
During swss initialization, iterate through the existing kernel interfaces and populate cache. Also bring down the old interfaces during initialization

Why I did it
During swss initialization (swss restart, load minigraph), it was observed that sometimes Netlink messages are generated for old kernel interfaces which incorrectly results in populating the state_db and notifying subscribers as interface create. By having the old interface cache, this Netlink messages could be ignored.

How I verified it
Do config load_minigraph, service swss restart and verify logs

Details if related
The following logs are meant to show the ifindexes and timestamps on when it is added to state_db

May  1 01:07:44.661599 str-s6100-acs-5 INFO supervisord: portsyncd Existing ifname Ethernet52 index 95
May  1 01:07:44.661651 str-s6100-acs-5 INFO supervisord: portsyncd Executing ip link set Ethernet52 down - ifindex 95
May  1 01:07:44.672936 str-s6100-acs-5 INFO supervisord: portsyncd Existing ifname Ethernet53 index 96
May  1 01:07:44.672936 str-s6100-acs-5 INFO supervisord: portsyncd Executing ip link set Ethernet53 down - ifindex 96
May  1 01:07:44.680075 str-s6100-acs-5 INFO supervisord: portsyncd Existing ifname Ethernet54 index 97
May  1 01:07:44.680075 str-s6100-acs-5 INFO supervisord: portsyncd Executing ip link set Ethernet54 down - ifindex 97
May  1 01:07:44.686330 str-s6100-acs-5 INFO supervisord: portsyncd Existing ifname Ethernet55 index 98
May  1 01:07:44.687798 str-s6100-acs-5 INFO supervisord: portsyncd Executing ip link set Ethernet55 down - ifindex 98
May  1 01:07:44.692745 str-s6100-acs-5 INFO supervisord: portsyncd Existing ifname Ethernet34 index 99
May  1 01:07:44.692745 str-s6100-acs-5 INFO supervisord: portsyncd Executing ip link set Ethernet34 down - ifindex 99
..
May  1 01:07:44.956949 str-s6100-acs-5 INFO supervisord: portsyncd Existing ifname Ethernet36 index 157
May  1 01:07:44.957011 str-s6100-acs-5 INFO supervisord: portsyncd Executing ip link set Ethernet36 down - ifindex 157
May  1 01:07:44.960543 str-s6100-acs-5 INFO supervisord: portsyncd Existing ifname Ethernet37 index 158
May  1 01:07:44.960602 str-s6100-acs-5 INFO supervisord: portsyncd Executing ip link set Ethernet37 down - ifindex 158


May  1 01:09:35.404282 str-s6100-acs-5 NOTICE portsyncd: :- onMsg: Adding to state db Ethernet52, 184
May  1 01:09:35.490402 str-s6100-acs-5 NOTICE portsyncd: :- onMsg: Adding to state db Ethernet53, 185
May  1 01:09:35.577087 str-s6100-acs-5 NOTICE portsyncd: :- onMsg: Adding to state db Ethernet54, 186
..
May  1 01:09:45.309125 str-s6100-acs-5 NOTICE portsyncd: :- onMsg: Adding to state db Ethernet39, 245
May  1 01:09:45.671632 str-s6100-acs-5 NOTICE portsyncd: :- onMsg: Adding to state db Ethernet36, 246
May  1 01:09:45.843315 str-s6100-acs-5 NOTICE portsyncd: :- onMsg: Adding to state db Ethernet37, 247

}
catch (...)
{
// Ignore error in this flow ;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should log error here.


//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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use swss_log

@lguohan
Copy link
Copy Markdown
Contributor

lguohan commented May 1, 2018

May  1 08:58:16.935207 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet28(39)
May  1 08:58:16.965413 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet24(40)
May  1 08:58:16.970633 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet32(41)
May  1 08:58:16.981819 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet36(42)
May  1 08:58:16.993027 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet44(43)
May  1 08:58:17.003327 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet40(44)
May  1 08:58:17.015306 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet4(45)
May  1 08:58:17.026158 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet0(46)
May  1 08:58:17.037543 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet12(47)
May  1 08:58:17.050907 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet8(48)
May  1 08:58:17.065419 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet16(49)
May  1 08:58:17.076029 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet20(50)
May  1 08:58:17.086732 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet48(51)
May  1 08:58:17.099934 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet52(52)
May  1 08:58:17.111543 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet60(53)
May  1 08:58:17.122783 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet56(54)
May  1 08:58:17.132857 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet64(55)
May  1 08:58:17.145691 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet68(56)
May  1 08:58:17.157206 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet76(57)
May  1 08:58:17.168907 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet72(58)
May  1 08:58:17.179944 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet108(59)
May  1 08:58:17.193127 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet104(60)
May  1 08:58:17.204226 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet112(61)
May  1 08:58:17.218236 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet116(62)
May  1 08:58:17.230171 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet120(63)
May  1 08:58:17.242526 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet124(64)
May  1 08:58:17.256382 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet80(65)
May  1 08:58:17.269031 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet84(66)
May  1 08:58:17.282454 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet92(67)
May  1 08:58:17.294604 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet88(68)
May  1 08:58:17.307763 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet96(69)
May  1 08:58:17.322837 str-s6000-on-4 INFO portsyncd: :- LinkSync: Bring down old interface Ethernet100(70)

@lguohan lguohan merged commit bb85c72 into sonic-net:master May 1, 2018
lguohan pushed a commit that referenced this pull request May 1, 2018
* Populate existing interface cache, bring down before configDone

* simplify the logic and add logging

Signed-off-by: Guohan Lu <[email protected]>

* add logging for publish event to state db

Signed-off-by: Guohan Lu <[email protected]>
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
…c-net#491)

* Populate existing interface cache, bring down before configDone

* simplify the logic and add logging

Signed-off-by: Guohan Lu <[email protected]>

* add logging for publish event to state db

Signed-off-by: Guohan Lu <[email protected]>
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
…c-net#491)

* Populate existing interface cache, bring down before configDone

* simplify the logic and add logging

Signed-off-by: Guohan Lu <[email protected]>

* add logging for publish event to state db

Signed-off-by: Guohan Lu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants