@@ -195,124 +195,37 @@ bool IntfMgr::isIntfChangeVrf(const string &alias, const string &vrfName)
195
195
196
196
void IntfMgr::addHostSubIntf (const string&intf, const string &subIntf, const string &vlan)
197
197
{
198
- // TODO: remove when validation check at mgmt is in place
199
- for (const auto &c : intf)
200
- {
201
- if (!isalnum (c))
202
- {
203
- SWSS_LOG_ERROR (" Invalid parent port name %s for host sub interface %s" , intf.c_str (), subIntf.c_str ());
204
- return ;
205
- }
206
- }
207
- for (const auto &c : vlan)
208
- {
209
- if (!isdigit (c))
210
- {
211
- SWSS_LOG_ERROR (" Invalid vlan id %s for host sub interface %s" , vlan.c_str (), subIntf.c_str ());
212
- return ;
213
- }
214
- }
215
-
216
198
stringstream cmd;
217
199
string res;
218
200
219
- cmd << IP_CMD << " link add link " << intf << " name " << subIntf << " type vlan id " << vlan;
201
+ cmd << IP_CMD " link add link " << shellquote ( intf) << " name " << shellquote ( subIntf) << " type vlan id " << shellquote ( vlan) ;
220
202
EXEC_WITH_ERROR_THROW (cmd.str (), res);
221
203
}
222
204
223
205
void IntfMgr::setHostSubIntfMtu (const string &subIntf, const string &mtu)
224
206
{
225
- // TODO: remove when validation check at mgmt is in place
226
- size_t found = subIntf.find (VLAN_SUB_INTERFACE_SEPARATOR);
227
- if (found == string::npos)
228
- {
229
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
230
- return ;
231
- }
232
- size_t i = 0 ;
233
- for (const auto &c : subIntf)
234
- {
235
- if (i < found && !isalnum (c))
236
- {
237
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
238
- return ;
239
- }
240
- else if (i > found && !isdigit (c))
241
- {
242
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
243
- return ;
244
- }
245
- i++;
246
- }
247
-
248
207
stringstream cmd;
249
208
string res;
250
209
251
- cmd << IP_CMD << " link set " << subIntf << " mtu " << mtu;
210
+ cmd << IP_CMD " link set " << shellquote ( subIntf) << " mtu " << shellquote ( mtu) ;
252
211
EXEC_WITH_ERROR_THROW (cmd.str (), res);
253
212
}
254
213
255
214
void IntfMgr::setHostSubIntfAdminStatus (const string &subIntf, const string &adminStatus)
256
215
{
257
- // TODO: remove when validation check at mgmt is in place
258
- size_t found = subIntf.find (VLAN_SUB_INTERFACE_SEPARATOR);
259
- if (found == string::npos)
260
- {
261
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
262
- return ;
263
- }
264
- size_t i = 0 ;
265
- for (const auto &c : subIntf)
266
- {
267
- if (i < found && !isalnum (c))
268
- {
269
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
270
- return ;
271
- }
272
- else if (i > found && !isdigit (c))
273
- {
274
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
275
- return ;
276
- }
277
- i++;
278
- }
279
-
280
216
stringstream cmd;
281
217
string res;
282
218
283
- cmd << IP_CMD << " link set " << subIntf << " " << adminStatus;
219
+ cmd << IP_CMD " link set " << shellquote ( subIntf) << " " << shellquote ( adminStatus) ;
284
220
EXEC_WITH_ERROR_THROW (cmd.str (), res);
285
221
}
286
222
287
223
void IntfMgr::removeHostSubIntf (const string &subIntf)
288
224
{
289
- // TODO: remove when validation check at mgmt is in place
290
- size_t found = subIntf.find (VLAN_SUB_INTERFACE_SEPARATOR);
291
- if (found == string::npos)
292
- {
293
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
294
- return ;
295
- }
296
- size_t i = 0 ;
297
- for (const auto &c : subIntf)
298
- {
299
- if (i < found && !isalnum (c))
300
- {
301
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
302
- return ;
303
- }
304
- else if (i > found && !isdigit (c))
305
- {
306
- SWSS_LOG_ERROR (" Invalid host sub interface name: %s" , subIntf.c_str ());
307
- return ;
308
- }
309
- i++;
310
- }
311
-
312
225
stringstream cmd;
313
226
string res;
314
227
315
- cmd << IP_CMD << " link del " << subIntf;
228
+ cmd << IP_CMD " link del " << shellquote ( subIntf) ;
316
229
EXEC_WITH_ERROR_THROW (cmd.str (), res);
317
230
}
318
231
0 commit comments