Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fail on unknown option of bond and vlan #73

Merged
merged 3 commits into from
Dec 4, 2023
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
340 changes: 170 additions & 170 deletions src/link/link_info/bond.rs

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions src/link/link_info/gre.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer},
DecodeError, Parseable,
};

#[derive(Debug, PartialEq, Eq, Clone)]

Check warning on line 9 in src/link/link_info/gre.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre.rs#L9

Added line #L9 was not covered by tests
#[non_exhaustive]
pub enum InfoGreTun {
Other(DefaultNla),
}

impl Nla for InfoGreTun {
fn value_len(&self) -> usize {
match self {
Self::Other(nla) => nla.value_len(),
}
}

Check warning on line 20 in src/link/link_info/gre.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre.rs#L16-L20

Added lines #L16 - L20 were not covered by tests

fn emit_value(&self, buffer: &mut [u8]) {
match self {
Self::Other(nla) => nla.emit_value(buffer),
}
}

Check warning on line 26 in src/link/link_info/gre.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre.rs#L22-L26

Added lines #L22 - L26 were not covered by tests

fn kind(&self) -> u16 {
match self {
Self::Other(nla) => nla.kind(),
}
}

Check warning on line 32 in src/link/link_info/gre.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre.rs#L28-L32

Added lines #L28 - L32 were not covered by tests
}

impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoGreTun {
fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
#[allow(clippy::match_single_binding)]
Ok(match buf.kind() {
kind => Self::Other(
DefaultNla::parse(buf)
.context(format!("unknown NLA type {kind} for gre"))?,

Check warning on line 41 in src/link/link_info/gre.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre.rs#L36-L41

Added lines #L36 - L41 were not covered by tests
),
})
}

Check warning on line 44 in src/link/link_info/gre.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre.rs#L44

Added line #L44 was not covered by tests
}
45 changes: 45 additions & 0 deletions src/link/link_info/gre6.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer},
DecodeError, Parseable,
};

#[derive(Debug, PartialEq, Eq, Clone)]

Check warning on line 9 in src/link/link_info/gre6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre6.rs#L9

Added line #L9 was not covered by tests
#[non_exhaustive]
pub enum InfoGreTun6 {
Other(DefaultNla),
}

impl Nla for InfoGreTun6 {
fn value_len(&self) -> usize {
match self {
Self::Other(nla) => nla.value_len(),
}
}

Check warning on line 20 in src/link/link_info/gre6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre6.rs#L16-L20

Added lines #L16 - L20 were not covered by tests

fn emit_value(&self, buffer: &mut [u8]) {
match self {
Self::Other(nla) => nla.emit_value(buffer),
}
}

Check warning on line 26 in src/link/link_info/gre6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre6.rs#L22-L26

Added lines #L22 - L26 were not covered by tests

fn kind(&self) -> u16 {
match self {
Self::Other(nla) => nla.kind(),
}
}

Check warning on line 32 in src/link/link_info/gre6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre6.rs#L28-L32

Added lines #L28 - L32 were not covered by tests
}

impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoGreTun6 {
fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
#[allow(clippy::match_single_binding)]
Ok(match buf.kind() {
kind => Self::Other(
DefaultNla::parse(buf)
.context(format!("unknown NLA type {kind} for ip6gre"))?,

Check warning on line 41 in src/link/link_info/gre6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre6.rs#L36-L41

Added lines #L36 - L41 were not covered by tests
),
})
}

Check warning on line 44 in src/link/link_info/gre6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre6.rs#L44

Added line #L44 was not covered by tests
}
45 changes: 45 additions & 0 deletions src/link/link_info/gre_tap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer},
DecodeError, Parseable,
};

#[derive(Debug, PartialEq, Eq, Clone)]

Check warning on line 9 in src/link/link_info/gre_tap.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap.rs#L9

Added line #L9 was not covered by tests
#[non_exhaustive]
pub enum InfoGreTap {
Other(DefaultNla),
}

impl Nla for InfoGreTap {
fn value_len(&self) -> usize {
match self {
Self::Other(nla) => nla.value_len(),
}
}

Check warning on line 20 in src/link/link_info/gre_tap.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap.rs#L16-L20

Added lines #L16 - L20 were not covered by tests

fn emit_value(&self, buffer: &mut [u8]) {
match self {
Self::Other(nla) => nla.emit_value(buffer),
}
}

Check warning on line 26 in src/link/link_info/gre_tap.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap.rs#L22-L26

Added lines #L22 - L26 were not covered by tests

fn kind(&self) -> u16 {
match self {
Self::Other(nla) => nla.kind(),
}
}

Check warning on line 32 in src/link/link_info/gre_tap.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap.rs#L28-L32

Added lines #L28 - L32 were not covered by tests
}

impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoGreTap {
fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
#[allow(clippy::match_single_binding)]
Ok(match buf.kind() {
kind => Self::Other(
DefaultNla::parse(buf)
.context(format!("unknown NLA type {kind} for gretap"))?,

Check warning on line 41 in src/link/link_info/gre_tap.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap.rs#L36-L41

Added lines #L36 - L41 were not covered by tests
),
})
}

Check warning on line 44 in src/link/link_info/gre_tap.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap.rs#L44

Added line #L44 was not covered by tests
}
45 changes: 45 additions & 0 deletions src/link/link_info/gre_tap6.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer},
DecodeError, Parseable,
};

#[derive(Debug, PartialEq, Eq, Clone)]

Check warning on line 9 in src/link/link_info/gre_tap6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap6.rs#L9

Added line #L9 was not covered by tests
#[non_exhaustive]
pub enum InfoGreTap6 {
Other(DefaultNla),
}

impl Nla for InfoGreTap6 {
fn value_len(&self) -> usize {
match self {
Self::Other(nla) => nla.value_len(),
}
}

Check warning on line 20 in src/link/link_info/gre_tap6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap6.rs#L16-L20

Added lines #L16 - L20 were not covered by tests

fn emit_value(&self, buffer: &mut [u8]) {
match self {
Self::Other(nla) => nla.emit_value(buffer),
}
}

Check warning on line 26 in src/link/link_info/gre_tap6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap6.rs#L22-L26

Added lines #L22 - L26 were not covered by tests

fn kind(&self) -> u16 {
match self {
Self::Other(nla) => nla.kind(),
}
}

Check warning on line 32 in src/link/link_info/gre_tap6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap6.rs#L28-L32

Added lines #L28 - L32 were not covered by tests
}

impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoGreTap6 {
fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
#[allow(clippy::match_single_binding)]
Ok(match buf.kind() {
kind => Self::Other(
DefaultNla::parse(buf)
.context(format!("unknown NLA type {kind} for gretap6"))?,

Check warning on line 41 in src/link/link_info/gre_tap6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap6.rs#L36-L41

Added lines #L36 - L41 were not covered by tests
),
})
}

Check warning on line 44 in src/link/link_info/gre_tap6.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gre_tap6.rs#L44

Added line #L44 was not covered by tests
}
45 changes: 45 additions & 0 deletions src/link/link_info/gtp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT

use anyhow::Context;
use netlink_packet_utils::{
nla::{DefaultNla, Nla, NlaBuffer},
DecodeError, Parseable,
};

#[derive(Debug, PartialEq, Eq, Clone)]

Check warning on line 9 in src/link/link_info/gtp.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gtp.rs#L9

Added line #L9 was not covered by tests
#[non_exhaustive]
pub enum InfoGtp {
Other(DefaultNla),
}

impl Nla for InfoGtp {
fn value_len(&self) -> usize {
match self {
Self::Other(nla) => nla.value_len(),
}
}

Check warning on line 20 in src/link/link_info/gtp.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gtp.rs#L16-L20

Added lines #L16 - L20 were not covered by tests

fn emit_value(&self, buffer: &mut [u8]) {
match self {
Self::Other(nla) => nla.emit_value(buffer),
}
}

Check warning on line 26 in src/link/link_info/gtp.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gtp.rs#L22-L26

Added lines #L22 - L26 were not covered by tests

fn kind(&self) -> u16 {
match self {
Self::Other(nla) => nla.kind(),
}
}

Check warning on line 32 in src/link/link_info/gtp.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gtp.rs#L28-L32

Added lines #L28 - L32 were not covered by tests
}

impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoGtp {
fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
#[allow(clippy::match_single_binding)]
Ok(match buf.kind() {
kind => Self::Other(
DefaultNla::parse(buf)
.context(format!("unknown NLA type {kind} for gtp"))?,

Check warning on line 41 in src/link/link_info/gtp.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gtp.rs#L36-L41

Added lines #L36 - L41 were not covered by tests
),
})
}

Check warning on line 44 in src/link/link_info/gtp.rs

View check run for this annotation

Codecov / codecov/patch

src/link/link_info/gtp.rs#L44

Added line #L44 was not covered by tests
}
Loading