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
18 changes: 18 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
Please make sure you have read and understood the contribution guildlines:
https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md

1. Make sure your commit includes a signature generted with `git commit -s`
2. Make sure your commit title follows the correct format: [component]: description
3. Make sure your commit message contains enough details about the change and related tests
4. Make sure your pull request adds related reviewers, asignees, labels

Please also provide the following information in this pull request:
-->
**What I did**

**Why I did it**

**How I verified it**

**Details if related**
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 39 additions & 3 deletions crates/hamgrd/src/actors/dpu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::actors::{spawn_consumer_bridge_for_actor, ActorCreator};
use crate::db_structs::{
BfdSessionTable, DashBfdProbeState, DashHaGlobalConfig, Dpu, DpuPmonStateType, DpuState, RemoteDpu,
BfdSessionTable, DashBfdProbeState, DashHaGlobalConfig, Dpu, DpuPmonStateType, DpuState, NeighResolveTable,
RemoteDpu,
};
use crate::ha_actor_messages::{ActorRegistration, DpuActorState, RegistrationType};
use crate::ServicePath;
Expand Down Expand Up @@ -169,6 +170,10 @@ impl DpuActor {

if is_managed {
if first_time {
if let Err(e) = self.set_neigh_resolve(outgoing) {
error!("Failed to set NEIGH_RESOLVE_TABLE: {}", e);
}

// DASH_HA_GLOBAL_CONFIG from common-bridge sent to this actor instance only.
// Key is DASH_HA_GLOBAL_CONFIG
self.bridges.push(
Expand Down Expand Up @@ -463,6 +468,30 @@ impl DpuActor {
}
false
}

fn set_neigh_resolve(&self, outgoing: &mut Outgoing) -> Result<()> {
let Some(DpuData::LocalDpu { ref dpu, .. }) = self.dpu else {
debug!("DPU is not managed by this HA instance, do not set NEIGH_RESOLVE_TABLE");
return Ok(());
};

let swss_key = format!("{}:{}", "", dpu.pa_ipv4.clone());
let entry = NeighResolveTable {
mac: "00:00:00:00:00:00".to_string(),
};

let fv = swss_serde::to_field_values(&entry)?;
let kfv = KeyOpFieldValues {
key: swss_key,
operation: KeyOperation::Set,
field_values: fv,
};

let msg = ActorMessage::new(self.id.clone(), &kfv)?;
outgoing.send(outgoing.common_bridge_sp::<NeighResolveTable>(), msg);

Ok(())
}
}

impl Actor for DpuActor {
Expand Down Expand Up @@ -504,8 +533,9 @@ mod test {
dpu::DpuActor,
test::{self, *},
};
use crate::db_structs::{BfdSessionTable, DashBfdProbeState, DashHaGlobalConfig, Dpu, DpuState, RemoteDpu};

use crate::db_structs::{
BfdSessionTable, DashBfdProbeState, DashHaGlobalConfig, Dpu, DpuState, NeighResolveTable, RemoteDpu,
};
use crate::ha_actor_messages::DpuActorState;
use sonic_common::SonicDbTable;
use std::time::Duration;
Expand All @@ -514,6 +544,9 @@ mod test {

#[tokio::test]
async fn dpu_actor() {
// To enable trace, set ENABLE_TRACE=1 to run test
sonic_common::log::init_logger_for_test();

let _ = Redis::start_config_db();
let runtime = test::create_actor_runtime(0, "10.0.0.0", "10::").await;
// prepare test data
Expand Down Expand Up @@ -566,6 +599,9 @@ mod test {
// Receiving DPU config-db object from swss-common bridge
send! { key: Dpu::table_name(), data: { "key": "switch0_dpu0", "operation": "Set", "field_values": dpu_fvs},
addr: crate::common_bridge_sp::<Dpu>(&runtime.get_swbus_edge()) },
// Check for NeighResolveTable message
recv! { key: "switch0_dpu0", data: {"key": format!("{}:{}", "".to_string(), dpu_actor_state_wo_bfd.pa_ipv4.clone()), "operation": "Set", "field_values": {"mac":"00:00:00:00:00:00"}},
addr: crate::common_bridge_sp::<NeighResolveTable>(&runtime.get_swbus_edge()) },
send! { key: "REMOTE_DPU|switch1_dpu0", data: { "key": "REMOTE_DPU|switch1_dpu0", "operation": "Set", "field_values": serde_json::to_value(&remote_dpu1_fvs).unwrap() }},
send! { key: DashHaGlobalConfig::table_name(), data: { "key": DashHaGlobalConfig::table_name(), "operation": "Set", "field_values": dash_global_cfg_fvs} },
recv! { key: "switch0_dpu0", data: {"key": "default:default:10.0.0.0", "operation": "Set", "field_values": bfd_fvs},
Expand Down
12 changes: 6 additions & 6 deletions crates/hamgrd/src/actors/ha_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@ impl HaSetActor {

for vdpu_ext in vdpus {
if !vdpu_ext.vdpu.dpu.remote_dpu {
// if it is locally managed dpu, use local nexthop as endpoint
endpoint.push(vdpu_ext.vdpu.dpu.local_nexthop_ip.clone());
// if it is locally managed dpu, use PA address as endpoint
endpoint.push(vdpu_ext.vdpu.dpu.pa_ipv4.clone());
} else {
endpoint.push(vdpu_ext.vdpu.dpu.npu_ipv4.clone());
}

endpoint_monitor.push(vdpu_ext.vdpu.dpu.pa_ipv4.clone());
if vdpu_ext.is_primary {
if !vdpu_ext.vdpu.dpu.remote_dpu {
primary.push(vdpu_ext.vdpu.dpu.local_nexthop_ip.clone());
primary.push(vdpu_ext.vdpu.dpu.pa_ipv4.clone());
} else {
primary.push(vdpu_ext.vdpu.dpu.npu_ipv4.clone());
}
Expand All @@ -228,7 +228,7 @@ impl HaSetActor {
let vnet_route = VnetRouteTunnelTable {
endpoint,
endpoint_monitor: Some(endpoint_monitor),
monitoring: None,
monitoring: Some("custom_bfd".into()),
primary: Some(primary),
rx_monitor_timer: global_cfg.dpu_bfd_probe_interval_in_ms,
tx_monitor_timer: global_cfg.dpu_bfd_probe_interval_in_ms,
Expand Down Expand Up @@ -564,7 +564,7 @@ mod test {
vdpu0_state_obj.dpu.pa_ipv4.clone(),
vdpu1_state_obj.dpu.pa_ipv4.clone(),
]),
monitoring: None,
monitoring: Some("custom_bfd".into()),
primary: Some(vec![vdpu0_state_obj.dpu.pa_ipv4.clone()]),
rx_monitor_timer: global_cfg.dpu_bfd_probe_interval_in_ms,
tx_monitor_timer: global_cfg.dpu_bfd_probe_interval_in_ms,
Expand Down Expand Up @@ -657,7 +657,7 @@ mod test {
vdpu0_state_obj.dpu.pa_ipv4.clone(),
vdpu1_state_obj.dpu.pa_ipv4.clone(),
]),
monitoring: None,
monitoring: Some("custom_bfd".into()),
primary: Some(vec![vdpu0_state_obj.dpu.npu_ipv4.clone()]),
rx_monitor_timer: global_cfg.dpu_bfd_probe_interval_in_ms,
tx_monitor_timer: global_cfg.dpu_bfd_probe_interval_in_ms,
Expand Down
2 changes: 0 additions & 2 deletions crates/hamgrd/src/actors/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ pub fn make_dpu_object(switch: u16, dpu: u32) -> Dpu {
vip_ipv6: Some(normalize_ipv6(&format!("3:2:{switch_pair_id}::{dpu}"))),
pa_ipv4: format!("18.0.{switch}.{dpu}"),
pa_ipv6: Some(normalize_ipv6(&format!("18:0:{switch}::{dpu}"))),
local_nexthop_ip: format!("18.0.{switch}.{dpu}"),
dpu_id: dpu,
vdpu_id: Some(format!("vdpu{}", switch * 8 + dpu as u16)),
orchagent_zmq_port: 8100,
Expand Down Expand Up @@ -453,7 +452,6 @@ pub fn to_local_dpu(dpu_actor_state: &DpuActorState) -> Dpu {
vip_ipv6: dpu_actor_state.vip_ipv6.clone(),
pa_ipv4: dpu_actor_state.pa_ipv4.clone(),
pa_ipv6: dpu_actor_state.pa_ipv6.clone(),
local_nexthop_ip: dpu_actor_state.local_nexthop_ip.clone(),
dpu_id: dpu_actor_state.dpu_id,
vdpu_id: dpu_actor_state.vdpu_id.clone(),
orchagent_zmq_port: dpu_actor_state.orchagent_zmq_port,
Expand Down
12 changes: 8 additions & 4 deletions crates/hamgrd/src/db_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pub struct Dpu {
pub vip_ipv6: Option<String>,
pub pa_ipv4: String,
pub pa_ipv6: Option<String>,
pub local_nexthop_ip: String,
pub dpu_id: u32,
pub vdpu_id: Option<String>,
pub orchagent_zmq_port: u16,
Expand Down Expand Up @@ -486,6 +485,14 @@ pub fn get_dpu_config_from_db(dpu_id: u32) -> Result<Dpu> {
Err(anyhow::anyhow!("DPU entry not found for slot {}", dpu_id))
}

#[skip_serializing_none]
#[serde_as]
#[derive(Default, Debug, Deserialize, Serialize, PartialEq, SonicDb)]
#[sonicdb(table_name = "NEIGH_RESOLVE_TABLE", key_separator = ":", db_name = "APPL_DB")]
pub struct NeighResolveTable {
pub mac: String,
}

#[cfg(test)]
mod test {
use super::*;
Expand All @@ -500,7 +507,6 @@ mod test {
"operation": "Set",
"field_values": {
"pa_ipv4": "1.2.3.4",
"local_nexthop_ip": "2.2.2.5",
"dpu_id": "1",
"orchagent_zmq_port": "8100",
"swbus_port": "23606",
Expand Down Expand Up @@ -552,7 +558,6 @@ mod test {
pa_ipv4: "1.2.3.6".to_string(),
vip_ipv4: Some("4.5.6.6".to_string()),
pa_ipv6: None,
local_nexthop_ip: "2.2.2.5".to_string(),
dpu_id: 6,
orchagent_zmq_port: 8100,
swbus_port: 23612,
Expand All @@ -571,7 +576,6 @@ mod test {
for d in 6..8 {
let dpu_fvs = vec![
("pa_ipv4".to_string(), Ipv4Addr::new(1, 2, 3, d).to_string()),
("local_nexthop_ip".to_string(), Ipv4Addr::new(2, 2, 2, 5).to_string()),
("vip_ipv4".to_string(), Ipv4Addr::new(4, 5, 6, d).to_string()),
("dpu_id".to_string(), d.to_string()),
("orchagent_zmq_port".to_string(), "8100".to_string()),
Expand Down
3 changes: 0 additions & 3 deletions crates/hamgrd/src/ha_actor_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub struct DpuActorState {
pub vip_ipv6: Option<String>,
pub pa_ipv4: String,
pub pa_ipv6: Option<String>,
pub local_nexthop_ip: String,
pub dpu_id: u32,
pub vdpu_id: Option<String>,
pub orchagent_zmq_port: u16,
Expand Down Expand Up @@ -57,7 +56,6 @@ impl DpuActorState {
vip_ipv6: dpu.vip_ipv6.clone(),
pa_ipv4: dpu.pa_ipv4.clone(),
pa_ipv6: dpu.pa_ipv6.clone(),
local_nexthop_ip: dpu.local_nexthop_ip.clone(),
dpu_id: dpu.dpu_id,
vdpu_id: dpu.vdpu_id.clone(),
orchagent_zmq_port: dpu.orchagent_zmq_port,
Expand All @@ -81,7 +79,6 @@ impl DpuActorState {
vip_ipv6: None,
pa_ipv4: rdpu.pa_ipv4.clone(),
pa_ipv6: rdpu.pa_ipv6.clone(),
local_nexthop_ip: "".to_string(),
dpu_id: rdpu.dpu_id,
vdpu_id: None,
orchagent_zmq_port: 0,
Expand Down
8 changes: 7 additions & 1 deletion crates/hamgrd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ mod ha_actor_messages;
use actors::{dpu::DpuActor, ha_scope::HaScopeActor, ha_set::HaSetActor, vdpu::VDpuActor, DbBasedActor};
use actors::{spawn_vanilla_producer_bridge, spawn_zmq_producer_bridge};
use anyhow::Result;
use db_structs::{BfdSessionTable, DashHaScopeTable, DashHaSetTable, Dpu, VDpu, VnetRouteTunnelTable};
use db_structs::{
BfdSessionTable, DashHaScopeTable, DashHaSetTable, Dpu, NeighResolveTable, VDpu, VnetRouteTunnelTable,
};
use lazy_static::lazy_static;
use sonic_dash_api_proto::{ha_scope_config::HaScopeConfig, ha_set_config::HaSetConfig};
use std::any::Any;
Expand Down Expand Up @@ -154,6 +156,10 @@ async fn spawn_producer_bridges(edge_runtime: Arc<SwbusEdgeRuntime>, dpu: &Dpu)

let handle = spawn_vanilla_producer_bridge::<VnetRouteTunnelTable>(edge_runtime.clone()).await?;
handles.push(handle);

let handle = spawn_vanilla_producer_bridge::<NeighResolveTable>(edge_runtime.clone()).await?;
handles.push(handle);

Ok(handles)
}

Expand Down
11 changes: 1 addition & 10 deletions crates/swbus-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ mod tests {
#[test]
fn test_get_swbus_config() {
let slot = 1;
let npu_ipv4 = "10.0.1.0";
let _ = Redis::start_config_db();

// Mock the config database with a sample configuration
Expand All @@ -271,15 +270,7 @@ mod tests {
std::env::set_var("DEV", format!("dpu{slot}"));
let config = get_swbus_config(None).unwrap();
assert_eq!(config.endpoint.to_string(), format!("{}:{}", "10.0.1.0", 23606 + slot));
let expected_sp = ServicePath::with_node(
"region-a",
"cluster-a",
&format!("{npu_ipv4}-dpu{slot}"),
"",
"",
"",
"",
);
let expected_sp = ServicePath::with_node("region-a", "cluster-a", &format!("host1-dpu{slot}"), "", "", "", "");
assert!(config
.routes
.iter()
Expand Down
Loading