avoid brctl on Linux, use ip instead

This commit is contained in:
Hannes Mehnert 2020-04-09 17:02:17 +02:00
parent be83686a22
commit 03c9948526

View file

@ -32,7 +32,7 @@ let check_commands () =
Bos.OS.Cmd.must_exist uname_cmd >>= fun _ -> Bos.OS.Cmd.must_exist uname_cmd >>= fun _ ->
let cmds = let cmds =
match Lazy.force uname with match Lazy.force uname with
| Linux -> [ "ip" ; "brctl" ; "taskset" ] | Linux -> [ "ip" ; "taskset" ]
| FreeBSD -> [ "ifconfig" ; "cpuset" ] | FreeBSD -> [ "ifconfig" ; "cpuset" ]
in in
List.fold_left List.fold_left
@ -146,9 +146,8 @@ let create_tap bridge =
in in
let tap = find_n 0 in let tap = find_n 0 in
Bos.OS.Cmd.run Bos.Cmd.(v "ip" % "tuntap" % "add" % tap % "mode" % "tap") >>= fun () -> Bos.OS.Cmd.run Bos.Cmd.(v "ip" % "tuntap" % "add" % tap % "mode" % "tap") >>= fun () ->
(* TODO maybe: ip link set $tap master $bridge -- no brctl *)
Bos.OS.Cmd.run Bos.Cmd.(v "ip" % "link" % "set" % "dev" % tap % "up") >>= fun () -> Bos.OS.Cmd.run Bos.Cmd.(v "ip" % "link" % "set" % "dev" % tap % "up") >>= fun () ->
Bos.OS.Cmd.run Bos.Cmd.(v "brctl" % "addif" % bridge % tap) >>= fun () -> Bos.OS.Cmd.run Bos.Cmd.(v "ip" % "link" % "set" % "dev" % tap % "master" % bridge) >>= fun () ->
Ok tap Ok tap
let destroy_tap tap = let destroy_tap tap =