Skip to content

Commit aab6d91

Browse files
committed
FreeBSD workflow support
1 parent fb180c1 commit aab6d91

File tree

3 files changed

+50
-9
lines changed

3 files changed

+50
-9
lines changed

.github/workflows/freebsd.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: TestFreeBSD
2+
3+
on:
4+
[push, pull_request]
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
toolchain: ["stable"] # ["nightly", "beta", "stable"] #
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Test in FreeBSD
19+
id: test
20+
uses: vmactions/freebsd-vm@v1
21+
with:
22+
usesh: true
23+
sync: rsync
24+
copyback: false
25+
prepare: |
26+
pkg install -y curl pkgconf glib
27+
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf > install.sh
28+
chmod +x install.sh
29+
./install.sh -y --default-toolchain ${{ matrix.toolchain }}
30+
run: |
31+
. "$HOME/.cargo/env"
32+
set -ex
33+
34+
# Add feature "nightly" if toolchain is nightly
35+
if [ "${{ matrix.toolchain }}" = "nightly" ]; then
36+
ARGS="$ARGS --features nightly"
37+
fi
38+
39+
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} fmt --all -- --check
40+
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} clippy --all-features -- -D warnings
41+
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} build --all-features

src/platform/freebsd/device.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl Device {
109109
}
110110
use std::io::ErrorKind::AlreadyExists;
111111
let info = "no avaiable file descriptor";
112-
return Err(Error::Io(std::io::Error::new(AlreadyExists, info).into()));
112+
return Err(Error::Io(std::io::Error::new(AlreadyExists, info)));
113113
};
114114
(tun, device_name)
115115
}
@@ -173,7 +173,7 @@ impl Device {
173173
let route = Route {
174174
addr,
175175
netmask: mask,
176-
dest: dest,
176+
dest,
177177
};
178178
if let Err(e) = self.set_route(route) {
179179
log::warn!("{e:?}");
@@ -344,8 +344,8 @@ impl AbstractDevice for Device {
344344

345345
fn set_address(&mut self, value: IpAddr) -> Result<()> {
346346
unsafe {
347-
let mut req = self.request();
348-
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &mut req) {
347+
let req = self.request();
348+
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &req) {
349349
return Err(std::io::Error::from(err).into());
350350
}
351351
let previous = self.route.as_ref().ok_or(Error::InvalidConfig)?;
@@ -371,8 +371,8 @@ impl AbstractDevice for Device {
371371

372372
fn set_destination(&mut self, value: IpAddr) -> Result<()> {
373373
unsafe {
374-
let mut req = self.request();
375-
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &mut req) {
374+
let req = self.request();
375+
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &req) {
376376
return Err(std::io::Error::from(err).into());
377377
}
378378
let previous = self.route.as_ref().ok_or(Error::InvalidConfig)?;
@@ -414,8 +414,8 @@ impl AbstractDevice for Device {
414414

415415
fn set_netmask(&mut self, value: IpAddr) -> Result<()> {
416416
unsafe {
417-
let mut req = self.request();
418-
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &mut req) {
417+
let req = self.request();
418+
if let Err(err) = siocdifaddr(self.ctl.as_raw_fd(), &req) {
419419
return Err(std::io::Error::from(err).into());
420420
}
421421
let previous = self.route.as_ref().ok_or(Error::InvalidConfig)?;

src/platform/freebsd/sys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use libc::{c_char, c_int, c_uint, ifreq, sockaddr, IFNAMSIZ};
1818
use nix::{ioctl_readwrite, ioctl_write_ptr};
1919

20-
#[allow(non_camel_case_types)]
20+
#[allow(non_camel_case_types, dead_code)]
2121
#[repr(C)]
2222
#[derive(Copy, Clone)]
2323
pub struct ctl_info {

0 commit comments

Comments
 (0)