Skip to content
Draft
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
46 changes: 46 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ nix = { version = "0.30.1", features = ["net", "sched", "signal", "socket", "use
rand = "0.9.2"
sha2 = "0.10.9"
netlink-packet-route = "0.25.1"
netlink-packet-netfilter = { git = "https://github.com/shivkr6/netlink-packet-netfilter.git", branch = "conntrack-new" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just so it is not overlooked, we cannot merge this while the upstream lib isn't merged so I mark as changes requested

netlink-packet-core = "0.8.1"
netlink-sys = "0.8.7"
nftables = "0.6.3"
Expand Down
24 changes: 23 additions & 1 deletion src/network/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
os::fd::BorrowedFd,
};

use crate::dns::aardvark::SafeString;
use crate::network::core_utils::get_default_route_interface;
use crate::network::dhcp::{dhcp_teardown, get_dhcp_lease};
use crate::network::netlink::Socket;
Expand All @@ -22,6 +21,7 @@ use crate::{
},
network::{constants, sysctl::disable_ipv6_autoconf, types},
};
use crate::{dns::aardvark::SafeString, network::netlink_netfilter::flush_udp_conntrack};
use ipnet::IpNet;
use log::{debug, error};
use netlink_packet_route::address::{AddressAttribute, AddressScope};
Expand Down Expand Up @@ -542,7 +542,18 @@ impl<'a> Bridge<'a> {

self.info.firewall.setup_network(sn, &system_dbus)?;

let port_mappings = spf.port_mappings;
let container_ip_v4 = spf.container_ip_v4;
let container_ip_v6 = spf.container_ip_v6;

self.info.firewall.setup_port_forward(spf, &system_dbus)?;

if let Some(port_mappings) = port_mappings {
// Flush stale UDP conntrack entries to prevent dropped packets.
// See the function's doc comment for more details.
flush_udp_conntrack(port_mappings, container_ip_v4, container_ip_v6)?;
}

Ok(())
}

Expand Down Expand Up @@ -639,7 +650,18 @@ impl<'a> Bridge<'a> {
complete_teardown,
};

let port_mappings = tpf.config.port_mappings;
let container_ip_v4 = tpf.config.container_ip_v4;
let container_ip_v6 = tpf.config.container_ip_v6;

self.info.firewall.teardown_port_forward(tpf)?;

if let Some(port_mappings) = port_mappings {
// Flush stale UDP conntrack entries to prevent dropped packets.
// See the function's doc comment for more details.
flush_udp_conntrack(port_mappings, container_ip_v4, container_ip_v6)?;
}

Ok(())
}
}
Expand Down
1 change: 1 addition & 0 deletions src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod driver;
pub mod internal_types;

pub mod netlink;
pub mod netlink_netfilter;
pub mod netlink_route;

pub mod plugin;
Expand Down
Loading