Skip to content

Commit 1fcfeb2

Browse files
committed
[muxorch] Use direct link for SoC IPs for active-active ports
Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
1 parent a8e238a commit 1fcfeb2

File tree

3 files changed

+86
-7
lines changed

3 files changed

+86
-7
lines changed

orchagent/muxorch.cpp

+44-3
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,14 @@ static bool remove_nh_tunnel(sai_object_id_t nh_id, IpAddress& ipAddr)
351351
return true;
352352
}
353353

354-
MuxCable::MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip)
354+
MuxCable::MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip, std::set<IpAddress> ignored_neighbors)
355355
:mux_name_(name), srv_ip4_(srv_ip4), srv_ip6_(srv_ip6), peer_ip4_(peer_ip)
356356
{
357357
mux_orch_ = gDirectory.get<MuxOrch*>();
358358
mux_cb_orch_ = gDirectory.get<MuxCableOrch*>();
359359
mux_state_orch_ = gDirectory.get<MuxStateOrch*>();
360360

361-
nbr_handler_ = std::make_unique<MuxNbrHandler> (MuxNbrHandler());
361+
nbr_handler_ = std::make_unique<MuxNbrHandler> (MuxNbrHandler(ignored_neighbors));
362362

363363
state_machine_handlers_.insert(handler_pair(MUX_STATE_INIT_ACTIVE, &MuxCable::stateInitActive));
364364
state_machine_handlers_.insert(handler_pair(MUX_STATE_STANDBY_ACTIVE, &MuxCable::stateActive));
@@ -545,8 +545,21 @@ void MuxCable::updateNeighbor(NextHopKey nh, bool add)
545545
}
546546
}
547547

548+
MuxNbrHandler::MuxNbrHandler(std::set<IpAddress> ignored_neighbors) : ignored_neighbors_(ignored_neighbors)
549+
{
550+
}
551+
552+
bool MuxNbrHandler::isNeighborIgnored(IpAddress ip)
553+
{
554+
return ignored_neighbors_.count(ip) != 0;
555+
}
556+
548557
void MuxNbrHandler::update(NextHopKey nh, sai_object_id_t tunnelId, bool add, MuxState state)
549558
{
559+
if (isNeighborIgnored(nh.ip_address)) {
560+
SWSS_LOG_NOTICE("Skip neighbor %s on %s", nh.ip_address.to_string().c_str(), nh.alias.c_str());
561+
return;
562+
}
550563
SWSS_LOG_INFO("Neigh %s on %s, add %d, state %d",
551564
nh.ip_address.to_string().c_str(), nh.alias.c_str(), add, state);
552565

@@ -1208,9 +1221,37 @@ bool MuxOrch::handleMuxCfg(const Request& request)
12081221
auto srv_ip = request.getAttrIpPrefix("server_ipv4");
12091222
auto srv_ip6 = request.getAttrIpPrefix("server_ipv6");
12101223

1224+
std::set<IpAddress> ignored_neighbors;
1225+
std::string cable_type = "active-standby";
1226+
12111227
const auto& port_name = request.getKeyString(0);
12121228
auto op = request.getOperation();
12131229

1230+
for (const auto &name : request.getAttrFieldNames())
1231+
{
1232+
if (name == "soc_ipv4")
1233+
{
1234+
auto soc_ip = request.getAttrIpPrefix("soc_ipv4");
1235+
SWSS_LOG_NOTICE("%s: %s was added to ignored neighbor list", port_name.c_str(), soc_ip.getIp().to_string().c_str());
1236+
ignored_neighbors.insert(soc_ip.getIp());
1237+
}
1238+
else if (name == "soc_ipv6")
1239+
{
1240+
auto soc_ip6 = request.getAttrIpPrefix("soc_ipv6");
1241+
SWSS_LOG_NOTICE("%s: %s was added to ignored neighbor list", port_name.c_str(), soc_ip6.getIp().to_string().c_str());
1242+
ignored_neighbors.insert(soc_ip6.getIp());
1243+
}
1244+
else if (name == "cable_type")
1245+
{
1246+
cable_type = request.getAttrString("cable_type");
1247+
}
1248+
}
1249+
1250+
if (cable_type != "active-active")
1251+
{
1252+
ignored_neighbors.clear();
1253+
}
1254+
12141255
if (op == SET_COMMAND)
12151256
{
12161257
if(isMuxExists(port_name))
@@ -1226,7 +1267,7 @@ bool MuxOrch::handleMuxCfg(const Request& request)
12261267
}
12271268

12281269
mux_cable_tb_[port_name] = std::make_unique<MuxCable>
1229-
(MuxCable(port_name, srv_ip, srv_ip6, mux_peer_switch_));
1270+
(MuxCable(port_name, srv_ip, srv_ip6, mux_peer_switch_, ignored_neighbors));
12301271

12311272
SWSS_LOG_NOTICE("Mux entry for port '%s' was added", port_name.c_str());
12321273
}

orchagent/muxorch.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ typedef std::map<IpAddress, sai_object_id_t> MuxNeighbor;
5959
class MuxNbrHandler
6060
{
6161
public:
62-
MuxNbrHandler() = default;
62+
MuxNbrHandler(std::set<IpAddress> ignored_neighbors = {});
6363

6464
bool enable(bool update_rt);
6565
bool disable(sai_object_id_t);
@@ -68,6 +68,10 @@ class MuxNbrHandler
6868
sai_object_id_t getNextHopId(const NextHopKey);
6969

7070
private:
71+
inline bool isNeighborIgnored(IpAddress ip);
72+
73+
private:
74+
std::set<IpAddress> ignored_neighbors_;
7175
MuxNeighbor neighbors_;
7276
string alias_;
7377
};
@@ -76,7 +80,7 @@ class MuxNbrHandler
7680
class MuxCable
7781
{
7882
public:
79-
MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip);
83+
MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress peer_ip, std::set<IpAddress> ignored_neighbors = {});
8084

8185
bool isActive() const
8286
{

tests/test_mux.py

+36-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class TestMuxTunnelBase(object):
2929
SERV1_IPV6 = "fc02:1000::100"
3030
SERV2_IPV4 = "192.168.0.101"
3131
SERV2_IPV6 = "fc02:1000::101"
32+
SERV3_IPV4 = "192.168.0.102"
33+
SERV3_IPV6 = "fc02:1000::102"
34+
SERV3_SOC_IPV4 = "192.168.0.103"
35+
SERV3_SOC_IPV6 = "fc02:1000::103"
3236
IPV4_MASK = "/32"
3337
IPV6_MASK = "/128"
3438
TUNNEL_NH_ID = 0
@@ -80,6 +84,14 @@ def create_mux_cable(self, confdb):
8084
fvs = { "server_ipv4":self.SERV2_IPV4+self.IPV4_MASK, "server_ipv6":self.SERV2_IPV6+self.IPV6_MASK }
8185
confdb.create_entry(self.CONFIG_MUX_CABLE, "Ethernet4", fvs)
8286

87+
fvs = {
88+
"server_ipv4": self.SERV3_IPV4 + self.IPV4_MASK,
89+
"server_ipv6": self.SERV3_IPV6 + self.IPV6_MASK,
90+
"soc_ipv4": self.SERV3_SOC_IPV4 + self.IPV4_MASK,
91+
"soc_ipv6": self.SERV3_SOC_IPV6 + self.IPV6_MASK,
92+
"cable_type": "active-active"
93+
}
94+
confdb.create_entry(self.CONFIG_MUX_CABLE, "Ethernet8", fvs)
8395

8496
def set_mux_state(self, appdb, ifname, state_change):
8597

@@ -193,6 +205,7 @@ def create_and_test_neighbor(self, confdb, appdb, asicdb, dvs, dvs_route):
193205

194206
self.set_mux_state(appdb, "Ethernet0", "active")
195207
self.set_mux_state(appdb, "Ethernet4", "standby")
208+
self.set_mux_state(appdb, "Ethernet8", "active")
196209

197210
self.add_neighbor(dvs, self.SERV1_IPV4, "00:00:00:00:00:01")
198211
# Broadcast neigh 192.168.0.255 is default added. Hence +1 for expected number
@@ -201,6 +214,18 @@ def create_and_test_neighbor(self, confdb, appdb, asicdb, dvs, dvs_route):
201214
self.add_neighbor(dvs, self.SERV1_IPV6, "00:00:00:00:00:01", True)
202215
srv1_v6 = self.check_neigh_in_asic_db(asicdb, self.SERV1_IPV6, 3)
203216

217+
self.add_neighbor(dvs, self.SERV3_IPV4, "00:00:00:00:00:03")
218+
srv3_v4 = self.check_neigh_in_asic_db(asicdb, self.SERV3_IPV4, 4)
219+
220+
self.add_neighbor(dvs, self.SERV3_IPV6, "00:00:00:00:00:03", True)
221+
srv3_v6 = self.check_neigh_in_asic_db(asicdb, self.SERV3_IPV6, 5)
222+
223+
self.add_neighbor(dvs, self.SERV3_SOC_IPV4, "00:00:00:00:00:04")
224+
self.check_neigh_in_asic_db(asicdb, self.SERV3_SOC_IPV4, 6)
225+
226+
self.add_neighbor(dvs, self.SERV3_SOC_IPV6, "00:00:00:00:00:04", True)
227+
self.check_neigh_in_asic_db(asicdb, self.SERV3_SOC_IPV6, 7)
228+
204229
existing_keys = asicdb.get_keys(self.ASIC_NEIGH_TABLE)
205230

206231
self.add_neighbor(dvs, self.SERV2_IPV4, "00:00:00:00:00:02")
@@ -225,9 +250,18 @@ def create_and_test_neighbor(self, confdb, appdb, asicdb, dvs, dvs_route):
225250
self.set_mux_state(appdb, "Ethernet4", "active")
226251

227252
dvs_route.check_asicdb_deleted_route_entries([self.SERV2_IPV4+self.IPV4_MASK, self.SERV2_IPV6+self.IPV6_MASK])
228-
self.check_neigh_in_asic_db(asicdb, self.SERV2_IPV4, 3)
229-
self.check_neigh_in_asic_db(asicdb, self.SERV2_IPV6, 3)
253+
self.check_neigh_in_asic_db(asicdb, self.SERV2_IPV4, 7)
254+
self.check_neigh_in_asic_db(asicdb, self.SERV2_IPV6, 7)
255+
256+
self.set_mux_state(appdb, "Ethernet8", "standby")
257+
258+
asicdb.wait_for_deleted_entry(self.ASIC_NEIGH_TABLE, srv3_v4)
259+
asicdb.wait_for_deleted_entry(self.ASIC_NEIGH_TABLE, srv3_v6)
260+
dvs_route.check_asicdb_route_entries([self.SERV3_IPV4+self.IPV4_MASK, self.SERV3_IPV6+self.IPV6_MASK])
230261

262+
self.check_neigh_in_asic_db(asicdb, self.SERV3_SOC_IPV4, 5)
263+
self.check_neigh_in_asic_db(asicdb, self.SERV3_SOC_IPV4, 5)
264+
dvs_route.check_asicdb_deleted_route_entries([self.SERV3_SOC_IPV4+self.IPV4_MASK, self.SERV3_SOC_IPV4+self.IPV6_MASK])
231265

232266
def create_and_test_fdb(self, appdb, asicdb, dvs, dvs_route):
233267

0 commit comments

Comments
 (0)