Skip to content
Merged
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
7 changes: 7 additions & 0 deletions orchagent/mirrororch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,13 @@ void MirrorOrch::updateNextHop(const NextHopUpdate& update)
session.nexthopInfo.nexthop = NextHopKey("0.0.0.0", "");
}

// Update State DB Nexthop
setSessionState(name, session, MIRROR_SESSION_NEXT_HOP_IP);

SWSS_LOG_NOTICE("Updated mirror session state db %s nexthop to %s",
name.c_str(), session.nexthopInfo.nexthop.to_string().c_str());


// Resolve the neighbor of the new next hop
updateSession(name, session);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,10 @@ def add_route(self, prefix, nexthop):
self.runcmd("ip route add " + prefix + " via " + nexthop)
time.sleep(1)

def change_route(self, prefix, nexthop):
self.runcmd("ip route change " + prefix + " via " + nexthop)
time.sleep(1)

def remove_route(self, prefix):
self.runcmd("ip route del " + prefix)
time.sleep(1)
Expand Down
8 changes: 2 additions & 6 deletions tests/dvslib/dvs_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,9 @@ def verify_port_mirror_config(self, dvs, ports, direction, session_oid="null"):

def verify_session_db(self, dvs, name, asic_table=None, asic=None, state=None, asic_size=None):
if asic:
fv_pairs = dvs.asic_db.wait_for_entry("ASIC_STATE:SAI_OBJECT_TYPE_MIRROR_SESSION", asic_table)
assert all(fv_pairs.get(k) == v for k, v in asic.items())
if asic_size:
assert asic_size == len(fv_pairs)
dvs.asic_db.wait_for_field_match("ASIC_STATE:SAI_OBJECT_TYPE_MIRROR_SESSION", asic_table, asic)
if state:
fv_pairs = dvs.state_db.wait_for_entry("MIRROR_SESSION_TABLE", name)
assert all(fv_pairs.get(k) == v for k, v in state.items())
dvs.state_db.wait_for_field_match("MIRROR_SESSION_TABLE", name, state)

def verify_session_policer(self, dvs, policer_oid, cir):
if cir:
Expand Down
41 changes: 36 additions & 5 deletions tests/test_mirror_port_erspan.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ def test_PortMirrorERSpanAddRemove(self, dvs, testlog):
self.dvs_mirror.verify_session_status(session, status="inactive")

# add IP address to Ethernet16
dvs.add_ip_address("Ethernet16", "10.0.0.0/31")
dvs.add_ip_address("Ethernet16", "10.0.0.0/30")
self.dvs_mirror.verify_session_status(session, status="inactive")

# add neighbor to Ethernet16
dvs.add_neighbor("Ethernet16", "10.0.0.1", "02:04:06:08:10:12")
self.dvs_mirror.verify_session_status(session, status="inactive")

# add another neighbor to Ethernet16
dvs.add_neighbor("Ethernet16", "10.0.0.2", "02:04:06:08:10:13")
self.dvs_mirror.verify_session_status(session, status="inactive")

# add route to mirror destination via 10.0.0.1
dvs.add_route("2.2.2.2", "10.0.0.1")
src_mac = dvs.runcmd("bash -c \"ip link show eth0 | grep ether | awk '{print $2}'\"")[1].strip().upper()
Expand All @@ -57,23 +61,50 @@ def test_PortMirrorERSpanAddRemove(self, dvs, testlog):
"SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": "02:04:06:08:10:12",
"SAI_MIRROR_SESSION_ATTR_SRC_MAC_ADDRESS": src_mac,
"SAI_MIRROR_SESSION_ATTR_GRE_PROTOCOL_TYPE": "25944"}

expected_state_db = {"status": "active",
"monitor_port": "Ethernet16",
"dst_mac": "02:04:06:08:10:12",
"route_prefix": "2.2.2.2/32"}
"monitor_port": "Ethernet16",
"dst_mac": "02:04:06:08:10:12",
"route_prefix": "2.2.2.2/32",
"next_hop_ip": "10.0.0.1@Ethernet16"}

self.dvs_mirror.verify_session_status(session)
self.dvs_mirror.verify_session(dvs, session, asic_db=expected_asic_db, state_db=expected_state_db, src_ports=src_asic_ports, asic_size=11)
# change route to mirror destination via 10.0.0.2
dvs.change_route("2.2.2.2", "10.0.0.2")
expected_asic_db = {"SAI_MIRROR_SESSION_ATTR_MONITOR_PORT": pmap.get("Ethernet16"),
"SAI_MIRROR_SESSION_ATTR_TYPE": "SAI_MIRROR_SESSION_TYPE_ENHANCED_REMOTE",
"SAI_MIRROR_SESSION_ATTR_ERSPAN_ENCAPSULATION_TYPE": "SAI_ERSPAN_ENCAPSULATION_TYPE_MIRROR_L3_GRE_TUNNEL",
"SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION": "4",
"SAI_MIRROR_SESSION_ATTR_TOS": "32",
"SAI_MIRROR_SESSION_ATTR_TTL": "100",
"SAI_MIRROR_SESSION_ATTR_SRC_IP_ADDRESS": "1.1.1.1",
"SAI_MIRROR_SESSION_ATTR_DST_IP_ADDRESS": "2.2.2.2",
"SAI_MIRROR_SESSION_ATTR_DST_MAC_ADDRESS": "02:04:06:08:10:13",
"SAI_MIRROR_SESSION_ATTR_SRC_MAC_ADDRESS": src_mac,
"SAI_MIRROR_SESSION_ATTR_GRE_PROTOCOL_TYPE": "25944"}

expected_state_db = {"status": "active",
"monitor_port": "Ethernet16",
"dst_mac": "02:04:06:08:10:13",
"route_prefix": "2.2.2.2/32",
"next_hop_ip": "10.0.0.2@Ethernet16"}

self.dvs_mirror.verify_session_status(session)
self.dvs_mirror.verify_session(dvs, session, asic_db=expected_asic_db, state_db=expected_state_db, src_ports=src_asic_ports, asic_size=11)

# remove route
dvs.remove_route("2.2.2.2")
self.dvs_mirror.verify_session_status(session, status="inactive")

# remove neighbor
dvs.remove_neighbor("Ethernet16", "10.0.0.1")
self.dvs_mirror.verify_session_status(session, status="inactive")
dvs.remove_neighbor("Ethernet16", "10.0.0.2")
self.dvs_mirror.verify_session_status(session, status="inactive")

# remove IP address
dvs.remove_ip_address("Ethernet16", "10.0.0.0/31")
dvs.remove_ip_address("Ethernet16", "10.0.0.0/30")
self.dvs_mirror.verify_session_status(session, status="inactive")

# bring down Ethernet16
Expand Down