Skip to content

Commit 3fe4e17

Browse files
merge main
2 parents 258d2be + b31ba90 commit 3fe4e17

File tree

15 files changed

+1225
-309
lines changed

15 files changed

+1225
-309
lines changed

common/src/illumos.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,54 @@ pub async fn vlan_create(over: &str, vlan_id: u16, vlan: &str) -> Result<()> {
177177
dladm_quiet(&["create-vlan", "-t", "-v", &vlan_id, "-l", over, vlan]).await
178178
}
179179

180+
/// What address family to use when enabling/disabling route exchange for an
181+
/// interface.
182+
#[derive(Debug, Clone, Copy)]
183+
pub enum AddressFamily {
184+
Ipv4,
185+
Ipv6,
186+
}
187+
188+
impl AddressFamily {
189+
fn as_str(&self) -> &'static str {
190+
match self {
191+
Self::Ipv4 => "ipv4",
192+
Self::Ipv6 => "ipv6",
193+
}
194+
}
195+
}
196+
197+
/// Enable or disable route exchange for a particular interface. Disabling
198+
/// has the following implications.
199+
///
200+
/// IPv6:
201+
/// - The host OS will ignore all NDP router solicitation (RS) and router
202+
/// advertisement (RA) messages.
203+
/// - The host OS will suppress RIPng send/receive
204+
///
205+
/// IPv4:
206+
/// - The host OS discards inbound RIP packets
207+
/// - The host OS suppresses ICMP router discovery
208+
pub async fn set_interface_exchange_routes(
209+
iface: &str,
210+
enabled: bool,
211+
address_family: AddressFamily,
212+
) -> Result<()> {
213+
let value =
214+
if enabled { "exchange_routes=on" } else { "exchange_routes=off" };
215+
216+
ipadm_quiet(&[
217+
"set-ifprop",
218+
"-t",
219+
"-p",
220+
value,
221+
"-m",
222+
address_family.as_str(),
223+
iface,
224+
])
225+
.await
226+
}
227+
180228
/// Remove a vlan link
181229
pub async fn vlan_delete(vlan: &str) -> Result<()> {
182230
dladm_quiet(&["delete-vlan", vlan]).await

0 commit comments

Comments
 (0)