Skip to content
Closed
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
20 changes: 17 additions & 3 deletions src/link/link_info/info_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use netlink_packet_utils::{

use super::super::{
InfoBond, InfoBridge, InfoGeneve, InfoGreTap, InfoGreTap6, InfoGreTun,
InfoGreTun6, InfoGtp, InfoHsr, InfoIpVlan, InfoIpVtap, InfoIpoib, InfoKind,
InfoMacSec, InfoMacVlan, InfoMacVtap, InfoSitTun, InfoTun, InfoVeth,
InfoVlan, InfoVrf, InfoVti, InfoVxlan, InfoXfrm,
InfoGreTun6, InfoGtp, InfoHsr, InfoIpTunnel, InfoIpVlan, InfoIpVtap,
InfoIpoib, InfoKind, InfoMacSec, InfoMacVlan, InfoMacVtap, InfoSitTun,
InfoTun, InfoVeth, InfoVlan, InfoVrf, InfoVti, InfoVxlan, InfoXfrm,
};

const IFLA_INFO_DATA: u16 = 2;
Expand Down Expand Up @@ -42,6 +42,7 @@ pub enum InfoData {
MacSec(Vec<InfoMacSec>),
Hsr(Vec<InfoHsr>),
Geneve(Vec<InfoGeneve>),
IpTunnel(Vec<InfoIpTunnel>),
Other(Vec<u8>),
}

Expand Down Expand Up @@ -71,6 +72,7 @@ impl Nla for InfoData {
Self::Vti(nlas) => nlas.as_slice().buffer_len(),
Self::Gtp(nlas) => nlas.as_slice().buffer_len(),
Self::Geneve(nlas) => nlas.as_slice().buffer_len(),
Self::IpTunnel(nlas) => nlas.as_slice().buffer_len(),
Self::Other(v) => v.len(),
}
}
Expand Down Expand Up @@ -100,6 +102,7 @@ impl Nla for InfoData {
Self::Vti(nlas) => nlas.as_slice().emit(buffer),
Self::Gtp(nlas) => nlas.as_slice().emit(buffer),
Self::Geneve(nlas) => nlas.as_slice().emit(buffer),
Self::IpTunnel(nlas) => nlas.as_slice().emit(buffer),
Self::Other(v) => buffer.copy_from_slice(v.as_slice()),
}
}
Expand Down Expand Up @@ -353,6 +356,17 @@ impl InfoData {
}
InfoData::Hsr(v)
}
InfoKind::IpIp | InfoKind::Ip6Tnl => {
let mut v = Vec::new();
for nla in NlasIterator::new(payload) {
let nla = &nla.context(format!(
"invalid IFLA_INFO_DATA for {kind} {payload:?}"
))?;
let parsed = InfoIpTunnel::parse(nla)?;
v.push(parsed);
}
InfoData::IpTunnel(v)
}
InfoKind::Geneve => {
let mut v = Vec::new();
for nla in NlasIterator::new(payload) {
Expand Down
13 changes: 9 additions & 4 deletions src/link/link_info/infos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const MACVTAP: &str = "macvtap";
const GRETAP: &str = "gretap";
const IP6GRETAP: &str = "ip6gretap";
const IPIP: &str = "ipip";
const IP6TNL: &str = "ip6tnl";
const SIT: &str = "sit";
const GRE: &str = "gre";
const IP6GRE: &str = "ip6gre";
Expand Down Expand Up @@ -189,7 +190,8 @@ pub enum InfoKind {
MacVtap,
GreTap,
GreTap6,
IpTun,
IpIp,
Ip6Tnl,
SitTun,
GreTun,
GreTun6,
Expand Down Expand Up @@ -226,7 +228,8 @@ impl std::fmt::Display for InfoKind {
Self::MacVtap => MACVTAP,
Self::GreTap => GRETAP,
Self::GreTap6 => IP6GRETAP,
Self::IpTun => IPIP,
Self::IpIp => IPIP,
Self::Ip6Tnl => IP6TNL,
Self::SitTun => SIT,
Self::GreTun => GRE,
Self::GreTun6 => IP6GRE,
Expand Down Expand Up @@ -263,7 +266,8 @@ impl Nla for InfoKind {
Self::MacVtap => MACVTAP.len(),
Self::GreTap => GRETAP.len(),
Self::GreTap6 => IP6GRETAP.len(),
Self::IpTun => IPIP.len(),
Self::IpIp => IPIP.len(),
Self::Ip6Tnl => IP6TNL.len(),
Self::SitTun => SIT.len(),
Self::GreTun => GRE.len(),
Self::GreTun6 => IP6GRE.len(),
Expand Down Expand Up @@ -320,7 +324,8 @@ impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>> for InfoKind {
MACVTAP => Self::MacVtap,
GRETAP => Self::GreTap,
IP6GRETAP => Self::GreTap6,
IPIP => Self::IpTun,
IPIP => Self::IpIp,
IP6TNL => Self::Ip6Tnl,
SIT => Self::SitTun,
GRE => Self::GreTun,
IP6GRE => Self::GreTun6,
Expand Down
Loading
Loading