Add EnvLogger and start of trait fn for dumping routes
Some checks are pending
Rust / build (push) Waiting to run
Some checks are pending
Rust / build (push) Waiting to run
This commit is contained in:
@ -12,10 +12,12 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
byteorder = "1.4.3"
|
||||
bytes.workspace = true
|
||||
eyre.workspace = true
|
||||
nom = "7.1"
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
tokio-util = { version = "0.7.10", features = ["codec"] }
|
||||
byteorder = "1.4.3"
|
||||
bytes.workspace = true
|
||||
eyre.workspace = true
|
||||
netlink-packet-route.workspace = true
|
||||
nom = "7.1"
|
||||
rtnetlink.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
tokio-util = { version = "0.7.10", features = ["codec"] }
|
||||
|
||||
@ -59,6 +59,25 @@ impl Into<Vec<u8>> for AddressFamilyIdentifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// Convenience functions to convert AddressFamilyIdentifier into those used by netlink.
|
||||
impl Into<netlink_packet_route::AddressFamily> for AddressFamilyIdentifier {
|
||||
fn into(self) -> netlink_packet_route::AddressFamily {
|
||||
match self {
|
||||
AddressFamilyIdentifier::Ipv4 => netlink_packet_route::AddressFamily::Inet,
|
||||
AddressFamilyIdentifier::Ipv6 => netlink_packet_route::AddressFamily::Inet6,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<rtnetlink::IpVersion> for AddressFamilyIdentifier {
|
||||
fn into(self) -> rtnetlink::IpVersion {
|
||||
match self {
|
||||
AddressFamilyIdentifier::Ipv4 => rtnetlink::IpVersion::V4,
|
||||
AddressFamilyIdentifier::Ipv6 => rtnetlink::IpVersion::V6,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This parser for AFI makes it easier to write the other message parsers.
|
||||
impl ReadablePacket for AddressFamilyIdentifier {
|
||||
fn from_wire<'a>(
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use futures::lock::Mutex;
|
||||
use eyre::Result;
|
||||
use ip_network_table_deps_treebitmap::address::Address;
|
||||
use ip_network_table_deps_treebitmap::IpLookupTable;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
@ -20,6 +20,7 @@ use std::fmt::Formatter;
|
||||
use std::net::Ipv6Addr;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::{trace, warn};
|
||||
|
||||
use bgp_packet::constants::AddressFamilyIdentifier;
|
||||
@ -80,6 +81,10 @@ impl<
|
||||
where
|
||||
String: From<<A as TryFrom<NLRI>>::Error>,
|
||||
{
|
||||
pub async fn get_routing_table(&mut self) -> Result<()> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
/// route_add requests updating the nexthop to a particular path if it is not already
|
||||
/// the best path.
|
||||
pub async fn route_add(&mut self, nlri: &NLRI, nexthop: IpAddr) -> Result<(), String> {
|
||||
@ -151,6 +156,7 @@ where
|
||||
let addr: A = nlri.clone().try_into()?;
|
||||
self.fib
|
||||
.insert(addr, nlri.prefixlen.into(), Arc::new(Mutex::new(entry)));
|
||||
trace!(nlri = %nlri, "Added to kernel");
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
|
||||
@ -19,19 +19,18 @@ pub mod southbound_interface;
|
||||
use std::convert::TryInto;
|
||||
use std::net::IpAddr;
|
||||
use std::net::Ipv4Addr;
|
||||
|
||||
use std::net::Ipv6Addr;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
|
||||
use bgp_packet::constants::AddressFamilyIdentifier;
|
||||
use bgp_packet::nlri::NLRI;
|
||||
|
||||
use eyre::{anyhow, Result};
|
||||
use eyre::Result;
|
||||
use ip_network_table_deps_treebitmap::IpLookupTable;
|
||||
use tonic::transport::Endpoint;
|
||||
use tonic::transport::Uri;
|
||||
use tracing::{info, trace, warn};
|
||||
use tracing::{trace, warn};
|
||||
|
||||
use bgp_packet::constants::AddressFamilyIdentifier;
|
||||
use bgp_packet::nlri::NLRI;
|
||||
|
||||
use crate::fib_state::FibState;
|
||||
use crate::proto::route_service_client::RouteServiceClient;
|
||||
@ -147,7 +146,6 @@ pub async fn run_connector_v6<S: SouthboundInterface>(
|
||||
let request = proto::StreamPathsRequest {
|
||||
address_family: proto::AddressFamily::IPv6.into(),
|
||||
};
|
||||
info!("Request: {:?}", request);
|
||||
|
||||
let mut stream = client.stream_paths(request).await?.into_inner();
|
||||
let mut msg_ctr: u64 = 0;
|
||||
|
||||
@ -25,6 +25,18 @@ pub struct NetlinkConnector {
|
||||
|
||||
#[async_trait]
|
||||
impl SouthboundInterface for NetlinkConnector {
|
||||
async fn get_all_routes(
|
||||
&mut self,
|
||||
address_family: AddressFamilyIdentifier,
|
||||
) -> Result<Vec<(NLRI, IpAddr)>> {
|
||||
let route = self.handle.route();
|
||||
|
||||
let mut get_request = route.get(address_family.into());
|
||||
get_request.message_mut().header.table = 201;
|
||||
|
||||
todo!();
|
||||
}
|
||||
|
||||
async fn route_add(
|
||||
&mut self,
|
||||
address_family: AddressFamilyIdentifier,
|
||||
|
||||
@ -34,6 +34,11 @@ pub trait SouthboundInterface {
|
||||
) -> Result<()>;
|
||||
/// route_del removes the route towards a particular prefix via a given nexthop.
|
||||
async fn route_del(&mut self, prefix: NLRI, nexthop: IpAddr) -> Result<()>;
|
||||
/// get_all_routes returns all the routes for the given address family.
|
||||
async fn get_all_routes(
|
||||
&mut self,
|
||||
address_family: AddressFamilyIdentifier,
|
||||
) -> Result<Vec<(NLRI, IpAddr)>>;
|
||||
}
|
||||
|
||||
/// DummyVerifier is a SouthboundInterface that checks that routes are not added more than
|
||||
@ -53,6 +58,13 @@ impl std::default::Default for DummyVerifier {
|
||||
|
||||
#[async_trait]
|
||||
impl SouthboundInterface for DummyVerifier {
|
||||
async fn get_all_routes(
|
||||
&mut self,
|
||||
address_family: AddressFamilyIdentifier,
|
||||
) -> Result<Vec<(NLRI, IpAddr)>> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
async fn route_add(
|
||||
&mut self,
|
||||
_: AddressFamilyIdentifier,
|
||||
|
||||
Reference in New Issue
Block a user