Skip to content

Commit 4458d9b

Browse files
authored
Merge pull request #1376 from Luap99/mozim-netlink
mozim: do not use netlink feature
2 parents 681cf7d + f2c5265 commit 4458d9b

File tree

3 files changed

+18
-85
lines changed

3 files changed

+18
-85
lines changed

Cargo.lock

Lines changed: 5 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ tokio-stream = { version = "0.1.18", features = ["net"] }
5555
tonic = "0.14.2"
5656
tonic-prost = "0.14.2"
5757
prost = "0.14.1"
58-
mozim = "0.3.1"
58+
mozim = { version = "0.3.1", default-features = false }
5959
futures-channel = "0.3.31"
6060
futures-core = "0.3.31"
6161
futures-util = "0.3.31"

src/dhcp_proxy/dhcp_service.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::{net::Ipv4Addr, sync::Arc};
22

3-
use crate::network::netlink_route::{LinkID, Route};
3+
use crate::network::{
4+
netlink,
5+
netlink_route::{LinkID, NetlinkRoute, Route},
6+
};
47
use log::debug;
58
use mozim::{DhcpV4Client, DhcpV4Config, DhcpV4Lease as MozimV4Lease, DhcpV4State};
69
use tokio::sync::Mutex;
@@ -54,6 +57,14 @@ impl DhcpV4Service {
5457
.map_err(|e| DhcpServiceError::new(InvalidArgument, e.to_string()))?;
5558
config.set_timeout_sec(timeout);
5659

60+
let mut socket = netlink::Socket::<NetlinkRoute>::new()
61+
.map_err(|e| DhcpServiceError::new(InvalidArgument, e.to_string()))?;
62+
let link = socket
63+
.get_link(LinkID::Name(nc.host_iface.clone()))
64+
.map_err(|e| DhcpServiceError::new(InvalidArgument, e.to_string()))?;
65+
66+
config.set_iface_index(link.header.index);
67+
5768
// Sending the hostname to the DHCP server is optional but it can be
5869
// useful in environments where DDNS is used to create or update
5970
// DNS records.

0 commit comments

Comments
 (0)