Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "tokenize.h"
#include "ipprefix.h"
#include "intfmgr.h"
#include "interface.h"
#include "exec.h"
#include "shellcmd.h"
#include "macaddress.h"
Expand Down Expand Up @@ -739,7 +740,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
subIntf subIf(alias);
// alias holds the complete sub interface name
// while parentAlias holds the parent port name
/*Check if subinterface is valid and sub interface name length is < 15(IFNAMSIZ)*/

if (!subIf.isValid())
{
SWSS_LOG_ERROR("Invalid subnitf: %s", alias.c_str());
Expand Down Expand Up @@ -839,6 +840,10 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
{
if (m_loopbackIntfList.find(alias) == m_loopbackIntfList.end())
{
if (!isInterfaceNameLenOk(alias))
{
return false;
}
addLoopbackIntf(alias);
m_loopbackIntfList.insert(alias);
SWSS_LOG_INFO("Added %s loopback interface", alias.c_str());
Expand Down Expand Up @@ -893,6 +898,11 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,

if (!parentAlias.empty())
{
if (!isInterfaceNameLenOk(alias))
{
return false;
}

subIntf subIf(alias);
if (m_subIntfList.find(alias) == m_subIntfList.end())
{
Expand Down
7 changes: 7 additions & 0 deletions cfgmgr/teammgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "logger.h"
#include "shellcmd.h"
#include "tokenize.h"
#include "interface.h"
#include "warm_restart.h"
#include "portmgr.h"
#include <swss/redisutility.h>
Expand Down Expand Up @@ -257,6 +258,12 @@ void TeamMgr::doLagTask(Consumer &consumer)
string mtu = DEFAULT_MTU_STR;
string learn_mode;
string tpid;

if (!isInterfaceNameLenOk(alias))
{
it++;
continue;
}

for (auto i : kfvFieldsValues(t))
{
Expand Down
22 changes: 16 additions & 6 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "vlanmgr.h"
#include "exec.h"
#include "tokenize.h"
#include "interface.h"
#include "shellcmd.h"
#include "warm_restart.h"
#include <swss/redisutility.h>
Expand Down Expand Up @@ -282,10 +283,9 @@ void VlanMgr::doVlanTask(Consumer &consumer)

string key = kfvKey(t);

/* Ensure the key starts with "Vlan" otherwise ignore */
if (strncmp(key.c_str(), VLAN_PREFIX, 4))
/* Ensure the key starts with "Vlan" and name length doesn't exceed limit otherwise ignore */
if (!isVlanIfaceNameValid(key) || !isInterfaceNameLenOk(key))
{
SWSS_LOG_ERROR("Invalid key format. No 'Vlan' prefix: %s", key.c_str());
it = consumer.m_toSync.erase(it);
continue;
}
Expand Down Expand Up @@ -484,6 +484,17 @@ bool VlanMgr::isVlanStateOk(const string &alias)
return false;
}

bool VlanMgr::isVlanIfaceNameValid(const string &alias)
{
/* Ensure the vlan interface name starts with "Vlan" */
if (strncmp(alias.c_str(), VLAN_PREFIX, 4))
{
SWSS_LOG_ERROR("Invalid key format. No 'Vlan' prefix: %s", alias.c_str());
return false;
}
return true;
}

bool VlanMgr::isVlanMemberStateOk(const string &vlanMemberKey)
{
vector<FieldValueTuple> temp;
Expand Down Expand Up @@ -553,10 +564,9 @@ void VlanMgr::doVlanMemberTask(Consumer &consumer)

string key = kfvKey(t);

/* Ensure the key starts with "Vlan" otherwise ignore */
if (strncmp(key.c_str(), VLAN_PREFIX, 4))
/* Ensure the key starts with "Vlan" and name length doesn't exceed limit otherwise ignore */
if (!isVlanIfaceNameValid(key))
{
SWSS_LOG_ERROR("Invalid key format. No 'Vlan' prefix: %s", key.c_str());
it = consumer.m_toSync.erase(it);
continue;
}
Expand Down
1 change: 1 addition & 0 deletions cfgmgr/vlanmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class VlanMgr : public Orch
bool isVlanStateOk(const std::string &alias);
bool isVlanMacOk();
bool isVlanMemberStateOk(const std::string &vlanMemberKey);
bool isVlanIfaceNameValid(const std::string &alias);
};

}
Expand Down
7 changes: 7 additions & 0 deletions cfgmgr/vrfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "dbconnector.h"
#include "producerstatetable.h"
#include "tokenize.h"
#include "interface.h"
#include "ipprefix.h"
#include "vrfmgr.h"
#include "exec.h"
Expand Down Expand Up @@ -283,6 +284,12 @@ void VrfMgr::doTask(Consumer &consumer)
SWSS_LOG_ERROR("Failed to create vrf netdev %s", vrfName.c_str());
}

if (!isInterfaceNameLenOk(vrfName))
{
it = consumer.m_toSync.erase(it);
continue;
}

bool status = true;
vector<FieldValueTuple> fvVector;
fvVector.emplace_back("state", "ok");
Expand Down
Loading