Skip to content

Commit 7fc0f73

Browse files
authored
Update netlink messages handler (#2233)
- What I did Ignore netlink DELLINK messages if port has master, this is applicable to the case where port was part of VLAN bridge or LAG. - Why I did it Netlink messages handler in portsyncd was ignoring all messages that had master. Therefore we ignored messages on interfaces that belong to LAG (not only interfaces belong to bridge as intended). The result was "netdev_oper_status" down in PORT_TABLE in state DB for port which is part of LAG although it is actually up. - How I verified it Check "netdev_oper_status" in PORT_TABLE in state DB for port which is part of LAG.
1 parent 40316f7 commit 7fc0f73

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

portsyncd/linksync.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,9 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj)
205205
return;
206206
}
207207

208-
/* If netlink for this port has master, we ignore that for now
209-
* This could be the case where the port was removed from VLAN bridge
210-
*/
211-
if (master)
208+
/* Ignore DELLINK message if port has master, this is applicable to
209+
* the case where port was part of VLAN bridge or LAG */
210+
if (master && nlmsg_type == RTM_DELLINK)
212211
{
213212
return;
214213
}

tests/test_portchannel.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,63 @@ def test_Portchannel_tpid(self, dvs, testlog):
382382
tbl._del("PortChannel0002")
383383
time.sleep(1)
384384

385+
def test_portchannel_member_netdev_oper_status(self, dvs, testlog):
386+
config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0)
387+
state_db = swsscommon.DBConnector(swsscommon.STATE_DB, dvs.redis_sock, 0)
388+
app_db = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0)
389+
390+
# create port-channel
391+
tbl = swsscommon.Table(config_db, "PORTCHANNEL")
392+
fvs = swsscommon.FieldValuePairs([("admin_status", "up"),("mtu", "9100"),("oper_status", "up")])
393+
tbl.set("PortChannel111", fvs)
394+
395+
# set port-channel oper status
396+
tbl = swsscommon.ProducerStateTable(app_db, "LAG_TABLE")
397+
fvs = swsscommon.FieldValuePairs([("admin_status", "up"),("mtu", "9100"),("oper_status", "up")])
398+
tbl.set("PortChannel111", fvs)
399+
400+
# add members to port-channel
401+
tbl = swsscommon.Table(config_db, "PORTCHANNEL_MEMBER")
402+
fvs = swsscommon.FieldValuePairs([("NULL", "NULL")])
403+
tbl.set("PortChannel111|Ethernet0", fvs)
404+
tbl.set("PortChannel111|Ethernet4", fvs)
405+
406+
# wait for port-channel netdev creation
407+
time.sleep(1)
408+
409+
# set netdev oper status
410+
(exitcode, _) = dvs.runcmd("ip link set up dev Ethernet0")
411+
assert exitcode == 0, "ip link set failed"
412+
413+
(exitcode, _) = dvs.runcmd("ip link set up dev Ethernet4")
414+
assert exitcode == 0, "ip link set failed"
415+
416+
(exitcode, _) = dvs.runcmd("ip link set dev PortChannel111 carrier on")
417+
assert exitcode == 0, "ip link set failed"
418+
419+
# verify port-channel members netdev oper status
420+
tbl = swsscommon.Table(state_db, "PORT_TABLE")
421+
status, fvs = tbl.get("Ethernet0")
422+
assert status is True
423+
fvs = dict(fvs)
424+
assert fvs['netdev_oper_status'] == 'up'
425+
426+
status, fvs = tbl.get("Ethernet4")
427+
assert status is True
428+
fvs = dict(fvs)
429+
assert fvs['netdev_oper_status'] == 'up'
430+
431+
# remove port-channel members
432+
tbl = swsscommon.Table(config_db, "PORTCHANNEL_MEMBER")
433+
tbl._del("PortChannel111|Ethernet0")
434+
tbl._del("PortChannel111|Ethernet4")
435+
436+
# remove port-channel
437+
tbl = swsscommon.Table(config_db, "PORTCHANNEL")
438+
tbl._del("PortChannel111")
439+
440+
# wait for port-channel deletion
441+
time.sleep(1)
385442

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

0 commit comments

Comments
 (0)