Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update netlink messages handler #2233

Merged
merged 6 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion portsyncd/linksync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj)
/* If netlink for this port has master, we ignore that for now
* This could be the case where the port was removed from VLAN bridge
*/
if (master)
if (master && nlmsg_type == RTM_DELLINK)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let change the comments session above to state that we ignore the DELLINK message if port has master, this is applicable to the case where port was part or VLAN or LAG etc. You should rename the PR title too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

{
return;
}
Expand Down
57 changes: 57 additions & 0 deletions tests/test_portchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,63 @@ def test_Portchannel_tpid(self, dvs, testlog):
tbl._del("PortChannel0002")
time.sleep(1)

def test_portchannel_member_netdev_oper_status(self, dvs, testlog):
config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0)
state_db = swsscommon.DBConnector(swsscommon.STATE_DB, dvs.redis_sock, 0)
app_db = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0)

# create port-channel
tbl = swsscommon.Table(config_db, "PORTCHANNEL")
fvs = swsscommon.FieldValuePairs([("admin_status", "up"),("mtu", "9100"),("oper_status", "up")])
tbl.set("PortChannel111", fvs)

# set port-channel oper status
tbl = swsscommon.ProducerStateTable(app_db, "LAG_TABLE")
fvs = swsscommon.FieldValuePairs([("admin_status", "up"),("mtu", "9100"),("oper_status", "up")])
tbl.set("PortChannel111", fvs)

# add members to port-channel
tbl = swsscommon.Table(config_db, "PORTCHANNEL_MEMBER")
fvs = swsscommon.FieldValuePairs([("NULL", "NULL")])
tbl.set("PortChannel111|Ethernet0", fvs)
tbl.set("PortChannel111|Ethernet4", fvs)

# wait for port-channel netdev creation
time.sleep(1)

# set netdev oper status
(exitcode, _) = dvs.runcmd("ip link set up dev Ethernet0")
assert exitcode == 0, "ip link set failed"

(exitcode, _) = dvs.runcmd("ip link set up dev Ethernet4")
assert exitcode == 0, "ip link set failed"

(exitcode, _) = dvs.runcmd("ip link set dev PortChannel111 carrier on")
assert exitcode == 0, "ip link set failed"

# verify port-channel members netdev oper status
tbl = swsscommon.Table(state_db, "PORT_TABLE")
status, fvs = tbl.get("Ethernet0")
assert status is True
fvs = dict(fvs)
assert fvs['netdev_oper_status'] == 'up'

status, fvs = tbl.get("Ethernet4")
assert status is True
fvs = dict(fvs)
assert fvs['netdev_oper_status'] == 'up'

# remove port-channel members
tbl = swsscommon.Table(config_db, "PORTCHANNEL_MEMBER")
tbl._del("PortChannel111|Ethernet0")
tbl._del("PortChannel111|Ethernet4")

# remove port-channel
tbl = swsscommon.Table(config_db, "PORTCHANNEL")
tbl._del("PortChannel111")

# wait for port-channel deletion
time.sleep(1)

# Add Dummy always-pass test at end as workaroud
# for issue when Flaky fail on final test it invokes module tear-down before retrying
Expand Down