62 lines
2.2 KiB
Diff
62 lines
2.2 KiB
Diff
From 7ef2df7e8849f7f674c14190fb997fc3f0e7ba67 Mon Sep 17 00:00:00 2001
|
|
From: Gris Ge <fge@redhat.com>
|
|
Date: Tue, 8 Jun 2021 16:59:31 +0800
|
|
Subject: [PATCH 3/3] loopback: Fix interface type of loopback
|
|
|
|
Using `IFF_LOOPBACK` interface flag to determine whether a interface is
|
|
loopback or not is incorrect as other type interface would also hold
|
|
this flag.
|
|
|
|
Fixed to use `ARPHRD_LOOPBACK` from link_layer_type.
|
|
|
|
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
---
|
|
src/lib/ifaces/iface.rs | 17 ++++++++---------
|
|
1 file changed, 8 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/lib/ifaces/iface.rs b/src/lib/ifaces/iface.rs
|
|
index 60afacd..25ba558 100644
|
|
--- a/src/lib/ifaces/iface.rs
|
|
+++ b/src/lib/ifaces/iface.rs
|
|
@@ -48,10 +48,10 @@ use crate::NisporError;
|
|
use netlink_packet_route::rtnl::link::nlas;
|
|
use netlink_packet_route::rtnl::LinkMessage;
|
|
use netlink_packet_route::rtnl::{
|
|
- ARPHRD_ETHER, IFF_ALLMULTI, IFF_AUTOMEDIA, IFF_BROADCAST, IFF_DEBUG,
|
|
- IFF_DORMANT, IFF_LOOPBACK, IFF_LOWER_UP, IFF_MASTER, IFF_MULTICAST,
|
|
- IFF_NOARP, IFF_POINTOPOINT, IFF_PORTSEL, IFF_PROMISC, IFF_RUNNING,
|
|
- IFF_SLAVE, IFF_UP,
|
|
+ ARPHRD_ETHER, ARPHRD_LOOPBACK, IFF_ALLMULTI, IFF_AUTOMEDIA, IFF_BROADCAST,
|
|
+ IFF_DEBUG, IFF_DORMANT, IFF_LOOPBACK, IFF_LOWER_UP, IFF_MASTER,
|
|
+ IFF_MULTICAST, IFF_NOARP, IFF_POINTOPOINT, IFF_PORTSEL, IFF_PROMISC,
|
|
+ IFF_RUNNING, IFF_SLAVE, IFF_UP,
|
|
};
|
|
use rtnetlink::new_connection;
|
|
|
|
@@ -247,8 +247,10 @@ pub(crate) fn parse_nl_msg_to_iface(
|
|
name: name.clone(),
|
|
..Default::default()
|
|
};
|
|
- if nl_msg.header.link_layer_type == ARPHRD_ETHER {
|
|
- iface_state.iface_type = IfaceType::Ethernet
|
|
+ match nl_msg.header.link_layer_type {
|
|
+ ARPHRD_ETHER => iface_state.iface_type = IfaceType::Ethernet,
|
|
+ ARPHRD_LOOPBACK => iface_state.iface_type = IfaceType::Loopback,
|
|
+ _ => (),
|
|
}
|
|
iface_state.index = nl_msg.header.index;
|
|
let mut link: Option<u32> = None;
|
|
@@ -392,9 +394,6 @@ pub(crate) fn parse_nl_msg_to_iface(
|
|
_ => (),
|
|
}
|
|
}
|
|
- if (nl_msg.header.flags & IFF_LOOPBACK) > 0 {
|
|
- iface_state.iface_type = IfaceType::Loopback;
|
|
- }
|
|
iface_state.flags = _parse_iface_flags(nl_msg.header.flags);
|
|
Ok(Some(iface_state))
|
|
}
|
|
--
|
|
2.32.0
|
|
|