diff --git a/jepsen/src/jepsen/net.clj b/jepsen/src/jepsen/net.clj index f59484018..d53e7d2d4 100644 --- a/jepsen/src/jepsen/net.clj +++ b/jepsen/src/jepsen/net.clj @@ -172,8 +172,9 @@ (fast! [net test]) (shape! [net test nodes behavior]))) -(def iptables - "Default iptables (assumes we control everything)." +(defn iptables-with-dev + "Default iptables (assumes we control everything). Take network device as parameter." + [dev] (reify Net (drop! [net test src dest] (on-nodes test [dest] @@ -185,11 +186,12 @@ (with-test-nodes test (su (exec :iptables :-F :-w) - (exec :iptables :-X :-w)))) + ; (exec :iptables :-X :-w) + ))) (slow! [net test] (with-test-nodes test - (su (exec tc :qdisc :add :dev :eth0 :root :netem :delay :50ms + (su (exec tc :qdisc :add :dev dev :root :netem :delay :50ms :10ms :distribution :normal)))) (slow! [net test {:keys [mean variance distribution] @@ -197,20 +199,20 @@ variance 10 distribution :normal}}] (with-test-nodes test - (su (exec tc :qdisc :add :dev :eth0 :root :netem :delay + (su (exec tc :qdisc :add :dev dev :root :netem :delay (str mean "ms") (str variance "ms") :distribution distribution)))) (flaky! [net test] (with-test-nodes test - (su (exec tc :qdisc :add :dev :eth0 :root :netem :loss "20%" + (su (exec tc :qdisc :add :dev dev :root :netem :loss "20%" "75%")))) (fast! [net test] (with-test-nodes test (try - (su (exec tc :qdisc :del :dev :eth0 :root)) + (su (exec tc :qdisc :del :dev dev :root)) (catch RuntimeException e (if (re-find #"Error: Cannot delete qdisc with handle of zero." (.getMessage e)) @@ -232,6 +234,10 @@ (str/join ",")) :-j :DROP :-w)))))))) +(def iptables + "Default iptables. Use eth0 as network device." + (iptables-with-dev :eth0)) + (def ipfilter "IPFilter rules" (reify Net