Skip to content

Commit

Permalink
[muxorch] Skip programming ACL for active-active ports
Browse files Browse the repository at this point in the history
Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
  • Loading branch information
lolyu committed Dec 12, 2022
1 parent 6695113 commit 5c172c6
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 22 deletions.
31 changes: 27 additions & 4 deletions orchagent/muxorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ static bool remove_nh_tunnel(sai_object_id_t nh_id, IpAddress& ipAddr)
return true;
}

MuxCable::MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip, std::set<IpAddress> skip_neighbors)
:mux_name_(name), srv_ip4_(srv_ip4), srv_ip6_(srv_ip6), peer_ip4_(peer_ip), skip_neighbors_(skip_neighbors)
MuxCable::MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip, std::set<IpAddress> skip_neighbors, MuxCableType cable_type)
:mux_name_(name), srv_ip4_(srv_ip4), srv_ip6_(srv_ip6), peer_ip4_(peer_ip), skip_neighbors_(skip_neighbors), cable_type_(cable_type)
{
mux_orch_ = gDirectory.get<MuxOrch*>();
mux_cb_orch_ = gDirectory.get<MuxCableOrch*>();
Expand Down Expand Up @@ -503,6 +503,11 @@ string MuxCable::getState()

bool MuxCable::aclHandler(sai_object_id_t port, string alias, bool add)
{
if (cable_type_ == MuxCableType::ACTIVE_ACTIVE)
{
SWSS_LOG_INFO("Skip programming ACL for mux port %s, cable type %d, add %s", alias.c_str(), cable_type_, add);
return;
}
if (add)
{
acl_handler_ = make_shared<MuxAclHandler>(port, alias);
Expand Down Expand Up @@ -1259,6 +1264,7 @@ bool MuxOrch::handleMuxCfg(const Request& request)
auto srv_ip = request.getAttrIpPrefix("server_ipv4");
auto srv_ip6 = request.getAttrIpPrefix("server_ipv6");

MuxCableType cable_type = MuxCableType::ACTIVE_STANDBY;
std::set<IpAddress> skip_neighbors;

const auto& port_name = request.getKeyString(0);
Expand All @@ -1278,6 +1284,23 @@ bool MuxOrch::handleMuxCfg(const Request& request)
SWSS_LOG_NOTICE("%s: %s was added to ignored neighbor list", port_name.c_str(), soc_ip6.getIp().to_string().c_str());
skip_neighbors.insert(soc_ip6.getIp());
}
else if (name == "cable_type")
{
auto cable_type_str = request.getAttrString("cable_type");
if (cable_type_str == "active-standby")
{
cable_type = MuxCableType::ACTIVE_STANDBY;
}
else if (cable_type_str == "active-active")
{
cable_type = MuxCableType::ACTIVE_ACTIVE;
}
else
{
cable_type = MuxCableType::ACTIVE_STANDBY;
}

}
}

if (op == SET_COMMAND)
Expand All @@ -1295,9 +1318,9 @@ bool MuxOrch::handleMuxCfg(const Request& request)
}

mux_cable_tb_[port_name] = std::make_unique<MuxCable>
(MuxCable(port_name, srv_ip, srv_ip6, mux_peer_switch_, skip_neighbors));
(MuxCable(port_name, srv_ip, srv_ip6, mux_peer_switch_, skip_neighbors, cable_type));

SWSS_LOG_NOTICE("Mux entry for port '%s' was added", port_name.c_str());
SWSS_LOG_NOTICE("Mux entry for port '%s' was added, cable type %d", port_name.c_str(), cable_type);
}
else
{
Expand Down
9 changes: 8 additions & 1 deletion orchagent/muxorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ enum MuxStateChange
MUX_STATE_UNKNOWN_STATE
};

enum MuxCableType
{
ACTIVE_STANDBY,
ACTIVE_ACTIVE
};

// Forward Declarations
class MuxOrch;
class MuxCableOrch;
Expand Down Expand Up @@ -76,7 +82,7 @@ class MuxNbrHandler
class MuxCable
{
public:
MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip, std::set<IpAddress> skip_neighbors);
MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip, std::set<IpAddress> skip_neighbors, MuxCableType cable_type);

bool isActive() const
{
Expand Down Expand Up @@ -111,6 +117,7 @@ class MuxCable
bool nbrHandler(bool enable, bool update_routes = true);

string mux_name_;
MuxCableType cable_type_;

MuxState state_ = MuxState::MUX_STATE_INIT;
bool st_chg_in_progress_ = false;
Expand Down
42 changes: 25 additions & 17 deletions tests/test_mux.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,46 +530,54 @@ def create_and_test_acl(self, appdb, dvs_acl):

dvs_acl.verify_no_acl_rules()

# Set one mux port to standby, verify ACL rule with inport bitmap (1 port)
# Set mux port in active-active cable type, no ACL rules programmed
self.set_mux_state(appdb, "Ethernet0", "standby")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0"], dvs_acl)
dvs_acl.verify_no_acl_rules()

# Set one mux port to standby, verify ACL rule with inport bitmap (1 port)
self.set_mux_state(appdb, "Ethernet4", "standby")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

# Set two mux ports to standby, verify ACL rule with inport bitmap (2 ports)
self.set_mux_state(appdb, "Ethernet4", "standby")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0", "Ethernet4"], dvs_acl)
self.set_mux_state(appdb, "Ethernet8", "standby")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4", "Ethernet8"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

# Set one mux port to active, verify ACL rule with inport bitmap (1 port)
self.set_mux_state(appdb, "Ethernet0", "active")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4"], dvs_acl)
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4", "Ethernet8"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

# Set last mux port to active, verify ACL rule is deleted
# Set one mux port to active, verify ACL rule with inport bitmap (1 port)
self.set_mux_state(appdb, "Ethernet4", "active")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet8"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

# Set last mux port to active, verify ACL rule is deleted
self.set_mux_state(appdb, "Ethernet8", "active")
dvs_acl.verify_no_acl_rules()

# Set unknown state and verify the behavior as standby
self.set_mux_state(appdb, "Ethernet0", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0"], dvs_acl)
self.set_mux_state(appdb, "Ethernet4", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

# Verify change while setting unknown from active
self.set_mux_state(appdb, "Ethernet4", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0", "Ethernet4"], dvs_acl)
self.set_mux_state(appdb, "Ethernet8", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4", "Ethernet8"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

self.set_mux_state(appdb, "Ethernet0", "active")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4"], dvs_acl)
self.set_mux_state(appdb, "Ethernet4", "active")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet8"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

self.set_mux_state(appdb, "Ethernet0", "standby")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0", "Ethernet4"], dvs_acl)
self.set_mux_state(appdb, "Ethernet4", "standby")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4", "Ethernet8"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

# Verify no change while setting unknown from standby
self.set_mux_state(appdb, "Ethernet0", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet0", "Ethernet4"], dvs_acl)
self.set_mux_state(appdb, "Ethernet4", "unknown")
sai_qualifier = self.get_expected_sai_qualifiers(["Ethernet4", "Ethernet8"], dvs_acl)
dvs_acl.verify_acl_rule(sai_qualifier, action="DROP", priority=self.ACL_PRIORITY)

def create_and_test_metrics(self, appdb, statedb):
Expand Down

0 comments on commit 5c172c6

Please sign in to comment.