Skip to content

Commit d8c305a

Browse files
authored
Move underlay config from static conf to ioctl (#93)
Fixes #87 This PR moves getting underlay devices from static driver configuration in the driver attach routine to an ioctl that allows the driver to be initially loaded without an underlay config and then configured with underlay devices later. In addition to the ioctl plumbing, the XdeState data structure is updated to include an Option<UnderlayState> to force users of XdeState to deal with the fact that the underlay may not be configured yet.
1 parent b37ad00 commit d8c305a

File tree

5 files changed

+168
-76
lines changed

5 files changed

+168
-76
lines changed

illumos-ddi-dki/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ pub const EAGAIN: c_int = 11;
533533
pub const ENOMEM: c_int = 12;
534534
pub const EFAULT: c_int = 14;
535535
pub const EBUSY: c_int = 16;
536+
pub const EEXIST: c_int = 17;
536537
pub const EINVAL: c_int = 22;
537538
pub const EPIPE: c_int = 32;
538539
pub const ENOMSG: c_int = 35;

opte-core/src/ioctl.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub enum OpteCmd {
6262
AddRouterEntryIpv4 = 60, // add a router entry for IPv4 dest
6363
CreateXde = 70, // create a new xde device
6464
DeleteXde = 71, // delete an xde device
65+
SetXdeUnderlay = 72, // set xde underlay devices
6566
}
6667

6768
impl TryFrom<c_int> for OpteCmd {
@@ -82,6 +83,7 @@ impl TryFrom<c_int> for OpteCmd {
8283
60 => Ok(Self::AddRouterEntryIpv4),
8384
70 => Ok(Self::CreateXde),
8485
71 => Ok(Self::DeleteXde),
86+
72 => Ok(Self::SetXdeUnderlay),
8587
_ => Err(()),
8688
}
8789
}
@@ -357,6 +359,13 @@ pub struct DeleteXdeReq {
357359
pub xde_devname: String,
358360
}
359361

362+
/// Set the underlay devices used by the xde kernel module
363+
#[derive(Clone, Debug, Serialize, Deserialize)]
364+
pub struct SetXdeUnderlayReq {
365+
pub u1: String,
366+
pub u2: String,
367+
}
368+
360369
#[derive(Debug, Default, Deserialize, Serialize)]
361370
pub struct NoResp {
362371
pub unused: u64,

opteadm/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use opte_core::ether::EtherAddr;
1313
use opte_core::geneve::Vni;
1414
use opte_core::ioctl::{
1515
self as api, CmdOk, CreateXdeReq, DeleteXdeReq, NoResp, OpteCmd,
16+
SetXdeUnderlayReq,
1617
};
1718
use opte_core::ip4::Ipv4Addr;
1819
use opte_core::ip6::Ipv6Addr;
@@ -146,6 +147,17 @@ impl OpteAdm {
146147
Ok(resp)
147148
}
148149

150+
/// Set xde underlay devices
151+
pub fn set_xde_underlay(
152+
&self,
153+
u1: &str,
154+
u2: &str,
155+
) -> Result<NoResp, Error> {
156+
let req = SetXdeUnderlayReq { u1: u1.into(), u2: u2.into() };
157+
let cmd = OpteCmd::SetXdeUnderlay;
158+
run_cmd_ioctl(self.device.as_raw_fd(), cmd, &req)
159+
}
160+
149161
/// Add a firewall rule
150162
pub fn add_firewall_rule(
151163
&self,

opteadm/src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ enum Command {
110110
/// Delete an xde device
111111
DeleteXde { name: String },
112112

113+
/// Set up xde underlay devices
114+
SetXdeUnderlay { u1: String, u2: String },
115+
113116
/// Set a virtual-to-physical mapping
114117
SetV2P {
115118
vpc_ip4: Ipv4Addr,
@@ -641,6 +644,11 @@ fn main() {
641644
let _ = hdl.delete_xde(&name).unwrap_or_die();
642645
}
643646

647+
Command::SetXdeUnderlay { u1, u2 } => {
648+
let hdl = opteadm::OpteAdm::open(OpteAdm::DLD_CTL).unwrap_or_die();
649+
let _ = hdl.set_xde_underlay(&u1, &u2).unwrap_or_die();
650+
}
651+
644652
Command::RmFwRule { port, direction, id } => {
645653
let hdl = opteadm::OpteAdm::open(OpteAdm::DLD_CTL).unwrap_or_die();
646654
let request = RemFwRuleReq { port_name: port, dir: direction, id };

0 commit comments

Comments
 (0)