@@ -40,8 +40,8 @@ void usage()
40
40
cout << " use configDB data if not specified" << endl;
41
41
}
42
42
43
- void handlePortConfigFile (ProducerStateTable &p, string file);
44
- void handlePortConfigFromConfigDB (ProducerStateTable &p, DBConnector &cfgDb);
43
+ void handlePortConfigFile (ProducerStateTable &p, string file, bool warm );
44
+ void handlePortConfigFromConfigDB (ProducerStateTable &p, DBConnector &cfgDb, bool warm );
45
45
void handleVlanIntfFile (string file);
46
46
void handlePortConfig (ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map);
47
47
void checkPortInitDone (DBConnector *appl_db);
@@ -77,13 +77,7 @@ int main(int argc, char **argv)
77
77
78
78
WarmStart::initialize (" portsyncd" );
79
79
WarmStart::checkWarmStart (" portsyncd" );
80
- if (WarmStart::isWarmStart ())
81
- {
82
- /* clear the init port config buffer */
83
- cout << " portsyncd warm start" << endl;
84
- deque<KeyOpFieldsValuesTuple> vkco;
85
- portCfg.pops (vkco);
86
- }
80
+ const bool warm = WarmStart::isWarmStart ();
87
81
88
82
LinkSync sync (&appl_db, &state_db);
89
83
NetDispatcher::getInstance ().registerMessageHandler (RTM_NEWLINK, &sync );
@@ -95,17 +89,14 @@ int main(int argc, char **argv)
95
89
Select s;
96
90
97
91
netlink.registerGroup (RTNLGRP_LINK);
92
+ netlink.dumpRequest (RTM_GETLINK);
98
93
cout << " Listen to link messages..." << endl;
99
94
100
- /* For portsyncd warm start, don't process init port config again */
101
- if (!WarmStart::isWarmStart ())
95
+ if (!port_config_file.empty ())
102
96
{
103
- if (!port_config_file.empty ())
104
- {
105
- handlePortConfigFile (p, port_config_file);
106
- } else {
107
- handlePortConfigFromConfigDB (p, cfgDb);
108
- }
97
+ handlePortConfigFile (p, port_config_file, warm);
98
+ } else {
99
+ handlePortConfigFromConfigDB (p, cfgDb, warm);
109
100
}
110
101
111
102
s.addSelectable (&netlink);
@@ -137,6 +128,7 @@ int main(int argc, char **argv)
137
128
FieldValueTuple finish_notice (" lanes" , " 0" );
138
129
vector<FieldValueTuple> attrs = { finish_notice };
139
130
p.set (" PortInitDone" , attrs);
131
+ SWSS_LOG_NOTICE (" PortInitDone" );
140
132
141
133
g_init = true ;
142
134
}
@@ -183,7 +175,7 @@ static void notifyPortConfigDone(ProducerStateTable &p)
183
175
p.set (" PortConfigDone" , attrs);
184
176
}
185
177
186
- void handlePortConfigFromConfigDB (ProducerStateTable &p, DBConnector &cfgDb)
178
+ void handlePortConfigFromConfigDB (ProducerStateTable &p, DBConnector &cfgDb, bool warm )
187
179
{
188
180
cout << " Get port configuration from ConfigDB..." << endl;
189
181
@@ -200,13 +192,19 @@ void handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb)
200
192
FieldValueTuple attr (v.first , v.second );
201
193
attrs.push_back (attr);
202
194
}
203
- p.set (k, attrs);
195
+ if (!warm)
196
+ {
197
+ p.set (k, attrs);
198
+ }
204
199
g_portSet.insert (k);
205
200
}
206
- notifyPortConfigDone (p);
201
+ if (!warm)
202
+ {
203
+ notifyPortConfigDone (p);
204
+ }
207
205
}
208
206
209
- void handlePortConfigFile (ProducerStateTable &p, string file)
207
+ void handlePortConfigFile (ProducerStateTable &p, string file, bool warm )
210
208
{
211
209
cout << " Read port configuration file..." << endl;
212
210
@@ -246,49 +244,55 @@ void handlePortConfigFile(ProducerStateTable &p, string file)
246
244
iss >> entry[column];
247
245
}
248
246
249
- /* If port has no alias, then use its name as alias */
250
- string alias;
251
- if ((entry.find (" alias" ) != entry.end ()) && (entry[" alias" ] != " " ))
247
+ if (!warm)
252
248
{
253
- alias = entry[" alias" ];
254
- }
255
- else
256
- {
257
- alias = entry[" name" ];
258
- }
249
+ /* If port has no alias, then use its name as alias */
250
+ string alias;
251
+ if ((entry.find (" alias" ) != entry.end ()) && (entry[" alias" ] != " " ))
252
+ {
253
+ alias = entry[" alias" ];
254
+ }
255
+ else
256
+ {
257
+ alias = entry[" name" ];
258
+ }
259
259
260
- FieldValueTuple lanes_attr (" lanes" , entry[" lanes" ]);
261
- FieldValueTuple alias_attr (" alias" , alias);
260
+ FieldValueTuple lanes_attr (" lanes" , entry[" lanes" ]);
261
+ FieldValueTuple alias_attr (" alias" , alias);
262
262
263
- vector<FieldValueTuple> attrs;
264
- attrs.push_back (lanes_attr);
265
- attrs.push_back (alias_attr);
263
+ vector<FieldValueTuple> attrs;
264
+ attrs.push_back (lanes_attr);
265
+ attrs.push_back (alias_attr);
266
266
267
- if ((entry.find (" speed" ) != entry.end ()) && (entry[" speed" ] != " " ))
268
- {
269
- FieldValueTuple speed_attr (" speed" , entry[" speed" ]);
270
- attrs.push_back (speed_attr);
271
- }
267
+ if ((entry.find (" speed" ) != entry.end ()) && (entry[" speed" ] != " " ))
268
+ {
269
+ FieldValueTuple speed_attr (" speed" , entry[" speed" ]);
270
+ attrs.push_back (speed_attr);
271
+ }
272
272
273
- if ((entry.find (" autoneg" ) != entry.end ()) && (entry[" autoneg" ] != " " ))
274
- {
275
- FieldValueTuple autoneg_attr (" autoneg" , entry[" autoneg" ]);
276
- attrs.push_back (autoneg_attr);
277
- }
273
+ if ((entry.find (" autoneg" ) != entry.end ()) && (entry[" autoneg" ] != " " ))
274
+ {
275
+ FieldValueTuple autoneg_attr (" autoneg" , entry[" autoneg" ]);
276
+ attrs.push_back (autoneg_attr);
277
+ }
278
278
279
- if ((entry.find (" fec" ) != entry.end ()) && (entry[" fec" ] != " " ))
280
- {
281
- FieldValueTuple fec_attr (" fec" , entry[" fec" ]);
282
- attrs.push_back (fec_attr);
283
- }
279
+ if ((entry.find (" fec" ) != entry.end ()) && (entry[" fec" ] != " " ))
280
+ {
281
+ FieldValueTuple fec_attr (" fec" , entry[" fec" ]);
282
+ attrs.push_back (fec_attr);
283
+ }
284
284
285
- p.set (entry[" name" ], attrs);
285
+ p.set (entry[" name" ], attrs);
286
+ }
286
287
287
288
g_portSet.insert (entry[" name" ]);
288
289
}
289
290
290
291
infile.close ();
291
- notifyPortConfigDone (p);
292
+ if (!warm)
293
+ {
294
+ notifyPortConfigDone (p);
295
+ }
292
296
}
293
297
294
298
void handlePortConfig (ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
0 commit comments