Skip to content

VLAN trunk support: orchagent update.#296

Closed
jipanyang wants to merge 4 commits intosonic-net:v1.0.3from
jipanyang:v1.0.3_vlan_orchagent
Closed

VLAN trunk support: orchagent update.#296
jipanyang wants to merge 4 commits intosonic-net:v1.0.3from
jipanyang:v1.0.3_vlan_orchagent

Conversation

@jipanyang
Copy link
Contributor

VLAN trunk support. Changes in orchagent:

  1. More than one 802.1Q VLAN could be created.
  2. A VLAN could have members of physical ports or LAG or both types of them.
  3. A physical port or LAG could be added to multiple VLANs in tagged mode.
  4. A physical port or LAG could be added to one VLAN in untagged mode.
  5. It shall be possible to config port VLAN ID (pvid) for individual physical port and LAG.

@msftclas
Copy link

@JipanYanga,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by Microsoft. We will now review your pull request.
Thanks,
Microsoft Pull Request Bot

Copy link
Contributor

@stcheng stcheng left a comment

Choose a reason for hiding this comment

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

thanks! please review the comments.

gPortsOrch->setPort(port.m_alias, port);

/* Clean this port from default VLAN */
gPortsOrch->removeDefaultVlanMembers();
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need to call this function here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After removeRouterIntfs(), the port goes back to default VLAN. Since there is no vlan member id available, this is the only way to get the port out of default VLAN.

Not very clear about the expected behavior at sai level. If port is not supposed to be put back to default VLAN, then it could be libsai implementation issue. This line may be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

the port is not supposed to be put back to default VLAN according to the SAI spec. you could remove this line.

Copy link
Contributor

Choose a reason for hiding this comment

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

the port is not supposed to be put back to default VLAN according to the SAI spec. you could remove this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will remove the line of code. Libsai from ASIC vendor should not automatically move the port to default VLAN.

orchagent/port.h Outdated
sai_object_id_t vlan_oid;
sai_vlan_id_t vlan_id;
std::string autostate;
uint32_t mtu;
Copy link
Contributor

Choose a reason for hiding this comment

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

move this mtu to Port structure's variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok.

orchagent/port.h Outdated
sai_vlan_id_t m_vlan_id = 0;
sai_vlan_id_t m_port_vlan_id = DEFAULT_PORT_VLAN_ID; // Port VLAN ID
sai_object_id_t m_vlan_member_id = 0;
port_vlan_members_t m_vlan_members;
Copy link
Contributor

Choose a reason for hiding this comment

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

align the spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok.

{
SWSS_LOG_ENTER();

vector<sai_object_id_t> idv;
Copy link
Contributor

Choose a reason for hiding this comment

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

extra spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

{
Port member;
auto it = port.m_members.begin();
while (it != port.m_members.end())
Copy link
Contributor

Choose a reason for hiding this comment

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

align spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

it = consumer.m_toSync.erase(it);
else
it++;
string autostate;
Copy link
Contributor

Choose a reason for hiding this comment

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

just wondering if autostate is a boolean or a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a value from redis, in type of string. VLAN autostate feature is to be implemented.

* Port has been removed from 1q bridge at PortsOrch constructor,
* also start stipping off VLAN tag.
*/
bool rv = setHostIntfsStripTag(p, SAI_HOSTIF_VLAN_TAG_STRIP);
Copy link
Contributor

Choose a reason for hiding this comment

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

move this piece of code inside the addHostIntfs function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After checking it again, bool PortsOrch::setHostIntfsStripTag(Port &port, sai_hostif_vlan_tag_t strip) is taking Port class as first parameter, while bool PortsOrch::addHostIntfs(sai_object_id_t id, string alias, sai_object_id_t &host_intfs_id) is using port id of type sai_object_id_t .

Probably it is better to keep setHostIntfsStripTag() out side of addHostIntfs(), and leave setHostIntfsStripTag() at initializePort().

Copy link
Contributor

Choose a reason for hiding this comment

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

what shall we do if this function fails here? what about moving this function above under the addHostIntfs function without checking the return value to match the rest of the initialization functions. it seems that if this function fails, there's nothing we could do here. since there's already error message inside this function, we could anyway catch it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, will move the function to addHostIntfs() without checking return value.

}

bool PortsOrch::addVlanMember(Port vlan, Port port, string& tagging_mode)
bool PortsOrch::addVlanMember(Port &vlan, Port &port, string& tagging_mode)
Copy link
Contributor

Choose a reason for hiding this comment

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

align the space, e.g. string &tagging_mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

assert (vlan_member != port.m_vlan_members.end());
sai_tagging_mode = vlan_member->second.vlan_mode;
vlan_member_id = vlan_member->second.vlan_member_id;
sai_status_t status = sai_vlan_api->remove_vlan_member(vlan_member_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

switch with the lower empty line 1586.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

}
}

/* Disable/enable SwSS recording */
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove this part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ah! I see. thanks! Let me fix this in a separate pull request!

Copy link
Contributor

Choose a reason for hiding this comment

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

#298 thanks.

Copy link
Contributor

@stcheng stcheng left a comment

Choose a reason for hiding this comment

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

minor changes. as for the PVID discussion, we could sync on the phone.

gPortsOrch->setPort(port.m_alias, port);

/* Clean this port from default VLAN */
gPortsOrch->removeDefaultVlanMembers();
Copy link
Contributor

Choose a reason for hiding this comment

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

the port is not supposed to be put back to default VLAN according to the SAI spec. you could remove this line.

bool PortsOrch::setPortPvid (Port &port, sai_uint32_t pvid)
{
SWSS_LOG_ENTER();
vector<Port> portv;
Copy link
Contributor

Choose a reason for hiding this comment

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

extra spaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will remove it.


bool PortsOrch::getPortPvid(Port &port, sai_uint32_t &pvid)
{

Copy link
Contributor

Choose a reason for hiding this comment

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

extra empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will remove it.


for (auto &vme: port.m_vlan_members)
{
if(vme.second.vlan_mode == SAI_VLAN_TAGGING_MODE_UNTAGGED) {
Copy link
Contributor

Choose a reason for hiding this comment

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

here the port VLAN ID is valid only when we are querying the physical port, is that right? a physical port will not have VLAN members. I'm not sure about why the for loop is here. Do we need to add checks at the entrance of this function to ensure the type of the port? If a sync is needed, let's discuss this on the phone.

bool PortsOrch::setHostIntfsStripTag(Port &port, sai_hostif_vlan_tag_t strip)
{
SWSS_LOG_ENTER();
vector<Port> portv;
Copy link
Contributor

Choose a reason for hiding this comment

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

extra spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will remove it.

return false;
}
SWSS_LOG_NOTICE("Set %s to host interface: %s",
hostif_vlan_tag[strip], p.m_alias.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

align the code or use 8 spaces

* Port has been removed from 1q bridge at PortsOrch constructor,
* also start stipping off VLAN tag.
*/
bool rv = setHostIntfsStripTag(p, SAI_HOSTIF_VLAN_TAG_STRIP);
Copy link
Contributor

Choose a reason for hiding this comment

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

what shall we do if this function fails here? what about moving this function above under the addHostIntfs function without checking the return value to match the rest of the initialization functions. it seems that if this function fails, there's nothing we could do here. since there's already error message inside this function, we could anyway catch it.


sai_status_t status = sai_vlan_api->remove_vlan_member(port.m_vlan_member_id);
sai_object_id_t vlan_member_id;
sai_vlan_tagging_mode_t sai_tagging_mode;
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to align spaces here

SWSS_LOG_ERROR("Failed to reset port VLAN ID to DEFAULT_PORT_VLAN_ID pid:%lx",
port.m_port_id);
return false;
if(!setPortPvid(port, DEFAULT_PORT_VLAN_ID))
Copy link
Contributor

Choose a reason for hiding this comment

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

add one space after if

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

{
Port member;

for(auto &name: lag.m_members)
Copy link
Contributor

Choose a reason for hiding this comment

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

one space after for

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok.

@jipanyang
Copy link
Contributor Author

target branch not active.

@jipanyang jipanyang closed this Sep 16, 2017
@jipanyang jipanyang deleted the v1.0.3_vlan_orchagent branch September 16, 2017 06:03
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
* Enhanced "show arp/ndp" output to have vlan member info

* Fixes and restructure

* Addressed review comments, pep8online comments
jianyuewu pushed a commit to jianyuewu/sonic-swss that referenced this pull request Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants