@@ -195,124 +195,37 @@ bool IntfMgr::isIntfChangeVrf(const string &alias, const string &vrfName)
195195
196196void IntfMgr::addHostSubIntf (const string&intf, const string &subIntf, const string &vlan)
197197{
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-
216198 stringstream cmd;
217199 string res;
218200
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) ;
220202 EXEC_WITH_ERROR_THROW (cmd.str (), res);
221203}
222204
223205void IntfMgr::setHostSubIntfMtu (const string &subIntf, const string &mtu)
224206{
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-
248207 stringstream cmd;
249208 string res;
250209
251- cmd << IP_CMD << " link set " << subIntf << " mtu " << mtu;
210+ cmd << IP_CMD " link set " << shellquote ( subIntf) << " mtu " << shellquote ( mtu) ;
252211 EXEC_WITH_ERROR_THROW (cmd.str (), res);
253212}
254213
255214void IntfMgr::setHostSubIntfAdminStatus (const string &subIntf, const string &adminStatus)
256215{
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-
280216 stringstream cmd;
281217 string res;
282218
283- cmd << IP_CMD << " link set " << subIntf << " " << adminStatus;
219+ cmd << IP_CMD " link set " << shellquote ( subIntf) << " " << shellquote ( adminStatus) ;
284220 EXEC_WITH_ERROR_THROW (cmd.str (), res);
285221}
286222
287223void IntfMgr::removeHostSubIntf (const string &subIntf)
288224{
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-
312225 stringstream cmd;
313226 string res;
314227
315- cmd << IP_CMD << " link del " << subIntf;
228+ cmd << IP_CMD " link del " << shellquote ( subIntf) ;
316229 EXEC_WITH_ERROR_THROW (cmd.str (), res);
317230}
318231
0 commit comments