Skip to content

Commit 0e03c7c

Browse files
committed
Add suffix to Aardvark internal network filenames
Use the %int suffix for internal network files passed to AV so we can properly trigger DNS handling (or, more accurately, lack of DNS handling) over there. Also, to handle version migrations, if there is a previous file for the network named without the suffix, delete that. This will unblock [1]. [1] containers/aardvark-dns#447 Signed-off-by: Matt Heon <mheon@redhat.com>
1 parent 01da96c commit 0e03c7c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/commands/teardown.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ impl Teardown {
5757
container_ips_v6: Vec::new(),
5858
container_names: Vec::new(),
5959
container_dns_servers: &None,
60+
is_internal: network.internal,
6061
});
6162
}
6263
}

src/dns/aardvark.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub struct AardvarkEntry<'a> {
2929
pub container_ips_v6: Vec<Ipv6Addr>,
3030
pub container_names: Vec<String>,
3131
pub container_dns_servers: &'a Option<Vec<IpAddr>>,
32+
pub is_internal: bool,
3233
}
3334

3435
#[derive(Debug, Clone)]
@@ -220,7 +221,12 @@ impl Aardvark {
220221
}
221222

222223
for entry in &entries {
223-
let path = Path::new(&self.config).join(entry.network_name);
224+
let mut path = Path::new(&self.config).join(entry.network_name);
225+
if entry.is_internal {
226+
let new_path = Path::new(&self.config).join(entry.network_name.to_owned() + "%int");
227+
let _ = std::fs::rename(&path, &new_path);
228+
path = new_path;
229+
}
224230

225231
let file = match OpenOptions::new().write(true).create_new(true).open(&path) {
226232
Ok(mut f) => {
@@ -325,7 +331,11 @@ impl Aardvark {
325331
}
326332

327333
pub fn delete_entry(&self, container_id: &str, network_name: &str) -> Result<()> {
328-
let path = Path::new(&self.config).join(network_name);
334+
let mut path = Path::new(&self.config).join(network_name);
335+
if !path.exists() {
336+
path = Path::new(&self.config).join(network_name.to_owned() + "%int");
337+
}
338+
329339
let file_content = fs::read_to_string(&path)?;
330340
let lines: Vec<&str> = file_content.split_terminator('\n').collect();
331341

src/network/bridge.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ impl driver::NetworkDriver for Bridge<'_> {
203203
container_ips_v6: ipv6,
204204
container_names: names,
205205
container_dns_servers: self.info.container_dns_servers,
206+
is_internal: self.info.network.internal,
206207
})
207208
} else {
208209
// If --dns-enable=false and --dns was set then return following DNS servers

0 commit comments

Comments
 (0)