Skip to content

Commit 55059b3

Browse files
authored
Change monitor blacklist into whitelist (#90)
This way we have tighter control over what interfaces are monitored, which are essentially just PIFs (eth*) and VIFs (vifx.y). Recently, we have had to extend the blacklist several times, because devices with different names appeared, which we do not want to monitor. Signed-off-by: Rob Hoes <[email protected]>
1 parent 3f961f7 commit 55059b3

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

networkd/network_monitor_thread.ml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ open D
2525
(** Table for bonds status. *)
2626
let bonds_status : (string, (int * int)) Hashtbl.t = Hashtbl.create 10
2727

28-
let monitor_blacklist = ref [
29-
"dummy";
30-
"xenbr";
31-
"xapi";
32-
"ovs-system";
33-
"xenapi";
34-
"lo";
35-
"bond";
36-
"pvs";
28+
let monitor_whitelist = ref [
29+
"eth";
30+
"vif"; (* This includes "tap" owing to the use of standardise_name below *)
3731
]
3832

3933
let xapi_rpc request =
@@ -110,14 +104,21 @@ let get_link_stats () =
110104
let cache = Link.cache_alloc s in
111105
let links = Link.cache_to_list cache in
112106
let links =
107+
let is_whitelisted name =
108+
List.exists (fun s -> String.startswith s name) !monitor_whitelist
109+
in
110+
let is_vlan name =
111+
String.startswith "eth" name && String.contains name '.'
112+
in
113113
List.map (fun link ->
114114
(standardise_name (Link.get_name link)), link
115115
) links |>
116-
List.filter (fun (name,link) ->
117-
let is_monitor_blacklisted = List.exists (fun s -> String.startswith s name) !monitor_blacklist ||
118-
(String.startswith "eth" name && String.contains name '.') in
119-
not is_monitor_blacklisted
120-
) in
116+
(* Only keep interfaces with prefixes on the whitelist, and exclude VLAN
117+
devices (ethx.y). *)
118+
List.filter (fun (name, _) ->
119+
is_whitelisted name && not (is_vlan name)
120+
)
121+
in
121122

122123
let devs = List.map (fun (name,link) ->
123124
let convert x = Int64.of_int (Unsigned.UInt64.to_int x) in

networkd/networkd.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let resources = [
5151
]
5252

5353
let options = [
54-
"monitor_blacklist", Arg.String (fun x -> Network_monitor_thread.monitor_blacklist := String.split ',' x), (fun () -> String.concat "," !Network_monitor_thread.monitor_blacklist), "List of prefixes of interface names that are not to be monitored";
54+
"monitor_whitelist", Arg.String (fun x -> Network_monitor_thread.monitor_whitelist := String.split ',' x), (fun () -> String.concat "," !Network_monitor_thread.monitor_whitelist), "List of prefixes of interface names that are to be monitored";
5555
"mac-table-size", Arg.Set_int Network_utils.mac_table_size, (fun () -> string_of_int !Network_utils.mac_table_size), "Default value for the mac-table-size openvswitch parameter (see ovs-vswitchd.conf.db.5)";
5656
"enic-workaround-until-version", Arg.Set_string Network_server.enic_workaround_until_version, (fun () -> !Network_server.enic_workaround_until_version), "The version till enic driver workaround will be applied or the version set to an empty string for not applying the workaround.";
5757
"pvs-proxy-socket", Arg.Set_string Network_server.PVS_proxy.path, (fun () -> !Network_server.PVS_proxy.path), "Path to the Unix domain socket for the PVS-proxy daemon";

0 commit comments

Comments
 (0)