You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bridge: bind ip for aardvark-dns in unmanaged mode if gateway ip is not on the host
Find all the IPv4 and IPv6 addresses except link local IPv6 addressses of the bridge with the modified dump_addresses() function.
If the dns is enabled and the bridge mode is unmanaged, then the bind IP of aardvark-dns is changed to the IP addresses of the bridge instead of the gateway. If there are no IP address on the bridge then we just fail with a clear error that the user must disable dns (--disable-dns) when creating the network.
Fixes: #1177
Signed-off-by: Shivang K Raghuvanshi <[email protected]>
@@ -252,18 +267,49 @@ impl driver::NetworkDriver for Bridge<'_> {
252
267
}
253
268
}
254
269
255
-
let gw = data
256
-
.ipam
257
-
.gateway_addresses
258
-
.iter()
259
-
.map(|ipnet| ipnet.addr())
260
-
.collect();
270
+
// Fixes #1177: In unmanaged mode, the gateway IP may not be on the host.
271
+
// We need to find an IP on the bridge itself for aardvark-dns to bind to.
272
+
let bind_addr:Vec<IpAddr> = if data.mode == BridgeMode::Unmanaged{
273
+
let addr_msgs = host_sock.dump_addresses(Some(bridge_index))?;
274
+
275
+
let addresses:Vec<IpAddr> = addr_msgs
276
+
.into_iter()
277
+
.filter_map(|addr_msg| {
278
+
// address is either a IPv4 address, or it's an IPv6 address that is not a link-local address.
279
+
if(addr_msg.header.family == AddressFamily::Inet6
280
+
&& addr_msg.header.scope != AddressScope::Link)
281
+
|| addr_msg.header.family == AddressFamily::Inet
282
+
{
283
+
addr_msg.attributes.into_iter().find_map(|attr| {
284
+
ifletAddressAttribute::Address(ip) = attr {
285
+
Some(ip)
286
+
}else{
287
+
None
288
+
}
289
+
})
290
+
}else{
291
+
None
292
+
}
293
+
})
294
+
.collect();
295
+
if addresses.is_empty(){
296
+
returnErr(NetavarkError::msg(format!("bridge '{}' in unmanaged mode has no universe scope IP addresses, but aardvark-dns requires at least one universe scope address to bind to. Please add an universe scope IP address or disable DNS for this network (--disable-dns).", data.bridge_interface_name)));
// If filtering options are supplied, then only the ip addresses satisfying the filter are returned. Otherwise all ip addresses of all interfaces are returned
assert_json ".error""bridge 'brtest0' in unmanaged mode has no universe scope IP addresses, but aardvark-dns requires at least one universe scope address to bind to. Please add an universe scope IP address or disable DNS for this network (--disable-dns)."
57
+
}
58
+
59
+
@test bridge - unmanaged mode with aardvark-dns bridge ip {
0 commit comments