From: Michael Cambria Date: Thu, 2 Mar 2017 19:43:56 +0000 (-0500) Subject: tc rules changed to use grop 0xd0; added thing2 specific test scripts X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=e4b4e34dce34b770009e4e8b0e9f9f2a75d0e1ef;p=cni.git tc rules changed to use grop 0xd0; added thing2 specific test scripts --- diff --git a/20-thing2-macvlan0.conf b/20-thing2-macvlan0.conf new file mode 100644 index 0000000..64377b9 --- /dev/null +++ b/20-thing2-macvlan0.conf @@ -0,0 +1,50 @@ +{ + "cniVersion": "0.2.0", + "name": "macvlan0", + "type": "macvlan", + "master": "em1", + "args" : { + "org.apache.mesos" : { + "network_info" : { + "name" : "mynet", + "labels" : { + "labels" : [ + { "key" : "app", "value" : "myapp" }, + { "key" : "mccKey1", "value" : "mccVal1" }, + { "key" : "bs", "value" : "bsVal" }, + { "key" : "StaticIP", "value" : "172.19.0.209" }, + { "key" : "Uplink", "value" : "eth1p0" }, + { "key" : "viaIP", "value" : "172.19.0.1" }, + { "key" : "mccKey2", "value" : "mccVal2" }, + { "key" : "env", "value" : "prod" } + ] + } + } + }, + "org.verizon" : { + "network_info" : { + "name" : "mynet", + "labels" : { + "labels" : [ + { "key" : "app", "value" : "myapp" }, + { "key" : "mccKey1", "value" : "mccVal1" }, + { "key" : "bs", "value" : "bsVal" }, + { "key" : "StaticIP", "value" : "172.19.0.209" }, + { "key" : "mccKey2", "value" : "mccVal2" }, + { "key" : "env", "value" : "prod" } + ] + } + } + } + }, + "ipam": { + "type": "vz-local", + "subnet": "172.19.0.0/16", + "gateway": "172.19.0.1", + "routes": [ + { "dst": "0.0.0.0/0" }, + { "dst": "10.6.7.0/24", "gw": "172.19.0.199" } + ] + } +} + diff --git a/21-macvlan0.conf b/21-macvlan0.conf new file mode 100644 index 0000000..e287a73 --- /dev/null +++ b/21-macvlan0.conf @@ -0,0 +1,16 @@ +{ + "cniVersion": "0.2.0", + "name": "macvlan0", + "type": "macvlan", + "master": "eth1p0", + "ipam": { + "type": "vz-local", + "subnet": "172.19.0.0/16", + "gateway": "172.19.0.1", + "routes": [ + { "dst": "0.0.0.0/0" }, + { "dst": "10.6.7.0/24", "gw": "172.19.0.199" } + ] + } +} + diff --git a/21-thing2-macvlan0.conf b/21-thing2-macvlan0.conf new file mode 100644 index 0000000..324485c --- /dev/null +++ b/21-thing2-macvlan0.conf @@ -0,0 +1,16 @@ +{ + "cniVersion": "0.2.0", + "name": "macvlan0", + "type": "macvlan", + "master": "em1", + "ipam": { + "type": "vz-local", + "subnet": "172.19.0.0/16", + "gateway": "172.19.0.1", + "routes": [ + { "dst": "0.0.0.0/0" }, + { "dst": "10.6.7.0/24", "gw": "172.19.0.199" } + ] + } +} + diff --git a/22-macvlan0.conf b/22-macvlan0.conf new file mode 100644 index 0000000..0a69d31 --- /dev/null +++ b/22-macvlan0.conf @@ -0,0 +1,50 @@ +{ + "cniVersion": "0.2.0", + "name": "macvlan0", + "type": "macvlan", + "master": "eth1p0", + "args" : { + "org.apache.mesos" : { + "network_info" : { + "name" : "mynet", + "labels" : { + "labels" : [ + { "key" : "app", "value" : "myapp" }, + { "key" : "mccKey1", "value" : "mccVal1" }, + { "key" : "bs", "value" : "bsVal" }, + { "key" : "StaticIP", "value" : "172.19.0.109" }, + { "key" : "Uplink", "value" : "eth1p0" }, + { "key" : "viaIP", "value" : "172.19.0.1" }, + { "key" : "mccKey2", "value" : "mccVal2" }, + { "key" : "env", "value" : "prod" } + ] + } + } + }, + "org.verizon" : { + "network_info" : { + "name" : "mynet", + "labels" : { + "labels" : [ + { "key" : "app", "value" : "myapp" }, + { "key" : "mccKey1", "value" : "mccVal1" }, + { "key" : "bs", "value" : "bsVal" }, + { "key" : "StaticIP", "value" : "172.19.0.209" }, + { "key" : "mccKey2", "value" : "mccVal2" }, + { "key" : "env", "value" : "prod" } + ] + } + } + } + }, + "ipam": { + "type": "vz-local", + "subnet": "172.19.0.0/16", + "gateway": "172.19.0.1", + "routes": [ + { "dst": "0.0.0.0/0" }, + { "dst": "10.6.7.0/24", "gw": "172.19.0.199" } + ] + } +} + diff --git a/22-thing2-macvlan0.conf b/22-thing2-macvlan0.conf new file mode 100644 index 0000000..f52e7ed --- /dev/null +++ b/22-thing2-macvlan0.conf @@ -0,0 +1,50 @@ +{ + "cniVersion": "0.2.0", + "name": "macvlan0", + "type": "macvlan", + "master": "em1", + "args" : { + "org.apache.mesos" : { + "network_info" : { + "name" : "mynet", + "labels" : { + "labels" : [ + { "key" : "app", "value" : "myapp" }, + { "key" : "mccKey1", "value" : "mccVal1" }, + { "key" : "bs", "value" : "bsVal" }, + { "key" : "StaticIP", "value" : "172.19.0.109" }, + { "key" : "Uplink", "value" : "eth1p0" }, + { "key" : "viaIP", "value" : "172.19.0.1" }, + { "key" : "mccKey2", "value" : "mccVal2" }, + { "key" : "env", "value" : "prod" } + ] + } + } + }, + "org.verizon" : { + "network_info" : { + "name" : "mynet", + "labels" : { + "labels" : [ + { "key" : "app", "value" : "myapp" }, + { "key" : "mccKey1", "value" : "mccVal1" }, + { "key" : "bs", "value" : "bsVal" }, + { "key" : "StaticIP", "value" : "172.19.0.209" }, + { "key" : "mccKey2", "value" : "mccVal2" }, + { "key" : "env", "value" : "prod" } + ] + } + } + } + }, + "ipam": { + "type": "vz-local", + "subnet": "172.19.0.0/16", + "gateway": "172.19.0.1", + "routes": [ + { "dst": "0.0.0.0/0" }, + { "dst": "10.6.7.0/24", "gw": "172.19.0.199" } + ] + } +} + diff --git a/mcc-manual-add-static-env-109.sh b/mcc-manual-add-static-env-109.sh new file mode 100755 index 0000000..87ae54d --- /dev/null +++ b/mcc-manual-add-static-env-109.sh @@ -0,0 +1,23 @@ +#/bin/bash +export DEBUG=1 +export NETCONFPATH=/etc/cni/net.d/ +#export CNI_PATH=/home/mcambria/go/src/github.com/containernetworking/cni/bin/ +export CNI_PATH=/home/mcambria/go2/src/stash.verizon.com/cni/bin +export NETCONFPATH=${NETCONFPATH-/etc/cni/net.d} +export CNI_COMMAND=ADD +export CNI_NETNS=/var/run/netns/mcc-cni-test2 +export CNI_CONTAINERID=mcc-cni-test2 + +export PATH=$CNI_PATH:$PATH +export CNI_IFNAME=eth1 + +export MCCVAL="Jamal Env Value" + +# sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 + +echo $CNI_ARGS + +#macvlan < /etc/cni/net.d/20-macvlan0.conf +macvlan < 22-macvlan0.conf + + diff --git a/mcc-manual-add.sh b/mcc-manual-add.sh index 21f4710..b74ddfe 100755 --- a/mcc-manual-add.sh +++ b/mcc-manual-add.sh @@ -15,6 +15,6 @@ export MCCVAL="Jamal Env Value" # sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 -macvlan < 20-macvlan0.conf +macvlan < 21-macvlan0.conf diff --git a/mcc-manual-del-static-env-109.sh b/mcc-manual-del-static-env-109.sh new file mode 100755 index 0000000..5d6fe71 --- /dev/null +++ b/mcc-manual-del-static-env-109.sh @@ -0,0 +1,23 @@ +#/bin/bash +export DEBUG=1 +export NETCONFPATH=/etc/cni/net.d/ +#export CNI_PATH=/home/mcambria/go/src/github.com/containernetworking/cni/bin/ +export CNI_PATH=/home/mcambria/go2/src/stash.verizon.com/cni/bin +export NETCONFPATH=${NETCONFPATH-/etc/cni/net.d} +export CNI_COMMAND=DEL +export CNI_NETNS=/var/run/netns/mcc-cni-test2 +export CNI_CONTAINERID=mcc-cni-test2 + +export PATH=$CNI_PATH:$PATH +export CNI_IFNAME=eth1 + +export MCCVAL="Jamal Env Value" + +# sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 + +echo $CNI_ARGS + +#macvlan < /etc/cni/net.d/20-macvlan0.conf +macvlan < 22-macvlan0.conf + + diff --git a/mcc-manual-del.sh b/mcc-manual-del.sh index 584732f..d3a8080 100755 --- a/mcc-manual-del.sh +++ b/mcc-manual-del.sh @@ -15,6 +15,6 @@ export MCCVAL="Jamal Env Value" # sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 -macvlan < 20-macvlan0.conf +macvlan < 21-macvlan0.conf diff --git a/pkg/ipam/ipam.go b/pkg/ipam/ipam.go index f2853d1..457fe5b 100644 --- a/pkg/ipam/ipam.go +++ b/pkg/ipam/ipam.go @@ -100,19 +100,19 @@ func ConfigureIface(ifName string, res *current.Result) error { */ // cmdName = "tc" - cmdArgs = []string{"filter", "add", "dev", ifName, "parent", "ffff:", "protocol", "ip", "prio", "2", "u32", "match", "u8", "0xc0", "0xf0", "at", "15", "flowid", ":10", "action", "pass" } + cmdArgs = []string{"filter", "add", "dev", ifName, "parent", "ffff:", "protocol", "ip", "prio", "2", "u32", "match", "u8", "0xd0", "0xf0", "at", "15", "flowid", ":10", "action", "pass" } if cmdOut, err = exec.Command(cmdName, cmdArgs...).Output(); err != nil { return fmt.Errorf("There was an error adding tc filter to %q: %v", ifName, err) } // cmdName = "tc" - cmdArgs = []string{"filter", "add", "dev", ifName, "parent", "ffff:", "protocol", "ip", "prio", "2", "u32", "match", "ip", "src", "10.37.2.1/32", "flowid", ":10", "action", "pass" } + cmdArgs = []string{"filter", "add", "dev", ifName, "parent", "ffff:", "protocol", "ip", "prio", "2", "u32", "match", "ip", "src", "172.19.0.1/32", "flowid", ":10", "action", "pass" } if cmdOut, err = exec.Command(cmdName, cmdArgs...).Output(); err != nil { return fmt.Errorf("There was an error adding tc filter to %q: %v", ifName, err) } // cmdName = "tc" - cmdArgs = []string{"filter", "add", "dev", ifName, "parent", "ffff:", "protocol", "ip", "prio", "2", "u32", "match", "ip", "src", "10.37.3.1/32", "flowid", ":10", "action", "drop" } + cmdArgs = []string{"filter", "add", "dev", ifName, "parent", "ffff:", "protocol", "ip", "prio", "2", "u32", "match", "ip", "src", "0.0.0.0/0", "flowid", ":10", "action", "drop" } if cmdOut, err = exec.Command(cmdName, cmdArgs...).Output(); err != nil { return fmt.Errorf("There was an error adding tc filter to %q: %v", ifName, err) } diff --git a/thing2-manual-add-static-env-109.sh b/thing2-manual-add-static-env-109.sh new file mode 100755 index 0000000..08499eb --- /dev/null +++ b/thing2-manual-add-static-env-109.sh @@ -0,0 +1,23 @@ +#/bin/bash +export DEBUG=1 +export NETCONFPATH=/etc/cni/net.d/ +#export CNI_PATH=/home/mcambria/go/src/github.com/containernetworking/cni/bin/ +export CNI_PATH=/home/mcambria/go2/src/stash.verizon.com/cni/bin +export NETCONFPATH=${NETCONFPATH-/etc/cni/net.d} +export CNI_COMMAND=ADD +export CNI_NETNS=/var/run/netns/mcc-cni-test2 +export CNI_CONTAINERID=mcc-cni-test2 + +export PATH=$CNI_PATH:$PATH +export CNI_IFNAME=eth1 + +export MCCVAL="Jamal Env Value" + +# sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 + +echo $CNI_ARGS + +#macvlan < /etc/cni/net.d/20-macvlan0.conf +macvlan < 22-thing2-macvlan0.conf + + diff --git a/thing2-manual-add-static-env.sh b/thing2-manual-add-static-env.sh new file mode 100755 index 0000000..5d290c5 --- /dev/null +++ b/thing2-manual-add-static-env.sh @@ -0,0 +1,27 @@ +#/bin/bash +export DEBUG=1 +export NETCONFPATH=/etc/cni/net.d/ +#export CNI_PATH=/home/mcambria/go/src/github.com/containernetworking/cni/bin/ +export CNI_PATH=/home/mcambria/go2/src/stash.verizon.com/cni/bin +export NETCONFPATH=${NETCONFPATH-/etc/cni/net.d} +export CNI_COMMAND=ADD +export CNI_NETNS=/var/run/netns/mcc-cni-test0 +export CNI_CONTAINERID=mcc-cni-test0 + +##export CNI_ARGS="IP=172.19.99.99;UPLINK=eth1p0" +#export CNI_ARGS="IP=172.19.99.99" +#export CNI_ARGS+=";UPLINK=cbr0" + +export PATH=$CNI_PATH:$PATH +export CNI_IFNAME=eth1 + +export MCCVAL="Jamal Env Value" + +# sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 + +echo $CNI_ARGS + +#macvlan < /etc/cni/net.d/20-macvlan0.conf +macvlan < 20-thing2-macvlan0.conf + + diff --git a/thing2-manual-add.sh b/thing2-manual-add.sh new file mode 100755 index 0000000..b74ddfe --- /dev/null +++ b/thing2-manual-add.sh @@ -0,0 +1,20 @@ +#/bin/bash +export DEBUG=1 +export NETCONFPATH=/etc/cni/net.d/ +#export CNI_PATH=/home/mcambria/go/src/github.com/containernetworking/cni/bin/ +export CNI_PATH=/home/mcambria/go2/src/stash.verizon.com/cni/bin +export NETCONFPATH=${NETCONFPATH-/etc/cni/net.d} +export CNI_COMMAND=ADD +export CNI_NETNS=/var/run/netns/mcc-cni-test1 +export CNI_CONTAINERID=mcc-cni-test1 + +export PATH=$CNI_PATH:$PATH +export CNI_IFNAME=eth1 + +export MCCVAL="Jamal Env Value" + +# sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 + +macvlan < 21-macvlan0.conf + + diff --git a/thing2-manual-del-static-env-109.sh b/thing2-manual-del-static-env-109.sh new file mode 100755 index 0000000..132b612 --- /dev/null +++ b/thing2-manual-del-static-env-109.sh @@ -0,0 +1,23 @@ +#/bin/bash +export DEBUG=1 +export NETCONFPATH=/etc/cni/net.d/ +#export CNI_PATH=/home/mcambria/go/src/github.com/containernetworking/cni/bin/ +export CNI_PATH=/home/mcambria/go2/src/stash.verizon.com/cni/bin +export NETCONFPATH=${NETCONFPATH-/etc/cni/net.d} +export CNI_COMMAND=DEL +export CNI_NETNS=/var/run/netns/mcc-cni-test2 +export CNI_CONTAINERID=mcc-cni-test2 + +export PATH=$CNI_PATH:$PATH +export CNI_IFNAME=eth1 + +export MCCVAL="Jamal Env Value" + +# sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 + +echo $CNI_ARGS + +#macvlan < /etc/cni/net.d/20-macvlan0.conf +macvlan < 22-thing2-macvlan0.conf + + diff --git a/thing2-manual-del-static-env.sh b/thing2-manual-del-static-env.sh new file mode 100755 index 0000000..c0e40ed --- /dev/null +++ b/thing2-manual-del-static-env.sh @@ -0,0 +1,27 @@ +#/bin/bash +export DEBUG=1 +export NETCONFPATH=/etc/cni/net.d/ +#export CNI_PATH=/home/mcambria/go/src/github.com/containernetworking/cni/bin/ +export CNI_PATH=/home/mcambria/go2/src/stash.verizon.com/cni/bin +export NETCONFPATH=${NETCONFPATH-/etc/cni/net.d} +export CNI_COMMAND=DEL +export CNI_NETNS=/var/run/netns/mcc-cni-test0 +export CNI_CONTAINERID=mcc-cni-test0 + +##export CNI_ARGS="IP=172.19.99.99;UPLINK=eth1p0" +#export CNI_ARGS="IP=172.19.99.99" +#export CNI_ARGS+=";UPLINK=cbr0" + +export PATH=$CNI_PATH:$PATH +export CNI_IFNAME=eth1 + +export MCCVAL="Jamal Env Value" + +# sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 + +echo $CNI_ARGS + +#macvlan < /etc/cni/net.d/20-macvlan0.conf +macvlan < 20-thing2-macvlan0.conf + + diff --git a/thing2-manual-del.sh b/thing2-manual-del.sh new file mode 100755 index 0000000..d3a8080 --- /dev/null +++ b/thing2-manual-del.sh @@ -0,0 +1,20 @@ +#/bin/bash +export DEBUG=1 +export NETCONFPATH=/etc/cni/net.d/ +#export CNI_PATH=/home/mcambria/go/src/github.com/containernetworking/cni/bin/ +export CNI_PATH=/home/mcambria/go2/src/stash.verizon.com/cni/bin +export NETCONFPATH=${NETCONFPATH-/etc/cni/net.d} +export CNI_COMMAND=DEL +export CNI_NETNS=/var/run/netns/mcc-cni-test1 +export CNI_CONTAINERID=mcc-cni-test1 + +export PATH=$CNI_PATH:$PATH +export CNI_IFNAME=eth1 + +export MCCVAL="Jamal Env Value" + +# sudo -E /home/mcambria/github/cni-master/scripts/exec-plugins.sh add mcc-cni-test0 /var/run/netns/mcc-cni-test0 + +macvlan < 21-macvlan0.conf + +