Skip to content

CA-412146 Filter out VF when scan #6528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
25 changes: 18 additions & 7 deletions ocaml/networkd/lib/network_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,29 @@ module Sysfs = struct
close_out outchan ;
raise (Network_error (Write_error file))

let is_physical name =
exception Unable_to_read_driver_link

let is_vif name =
let devpath = getpath name "device" in
try
let devpath = getpath name "device" in
let driver_link = Unix.readlink (devpath ^ "/driver") in
(* filter out symlinks under device/driver which look like
/../../../devices/xen-backend/vif- *)
not
(List.mem "xen-backend"
(Astring.String.cuts ~empty:false ~sep:"/" driver_link)
)
List.mem "xen-backend"
(Astring.String.cuts ~empty:false ~sep:"/" driver_link)
with _ -> raise Unable_to_read_driver_link

let is_vf name =
let devpath = getpath name "device" in
try
ignore @@ Unix.readlink (devpath ^ "/physfn") ;
true
with _ -> false

let is_physical name =
try not (is_vif name || is_vf name)
with Unable_to_read_driver_link -> false

(* device types are defined in linux/if_arp.h *)
let is_ether_device name =
match int_of_string (read_one_line (getpath name "type")) with
Expand Down Expand Up @@ -1547,7 +1558,7 @@ module Ovs = struct
let vif_arg =
let existing_vifs =
List.filter
(fun iface -> not (Sysfs.is_physical iface))
(fun iface -> try Sysfs.is_vif iface with _ -> false)
(bridge_to_interfaces name)
in
let ifaces_with_type =
Expand Down
Loading