Skip to content

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

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

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)]
#[non_exhaustive]
pub enum InfoGreTun {
Other(DefaultNla),
}

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

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

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

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"))?,
),
})
}
}
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)]
#[non_exhaustive]
pub enum InfoGreTun6 {
Other(DefaultNla),
}

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

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

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

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"))?,
),
})
}
}
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)]
#[non_exhaustive]
pub enum InfoGreTap {
Other(DefaultNla),
}

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

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

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

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"))?,
),
})
}
}
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)]
#[non_exhaustive]
pub enum InfoGreTap6 {
Other(DefaultNla),
}

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

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

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

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"))?,
),
})
}
}
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)]
#[non_exhaustive]
pub enum InfoGtp {
Other(DefaultNla),
}

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

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

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

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"))?,
),
})
}
}
Loading