From 2e7316b3537c8bef9cc08ba579753896c3c9401f Mon Sep 17 00:00:00 2001 From: Ruijing Guo Date: Fri, 5 Feb 2016 07:02:46 +0800 Subject: [PATCH] Bug 5072: Fail to create ACL Change-Id: Ib002e91ae3e074f6bbfbeda816078498914203a6 Signed-off-by: Ruijing Guo --- .gitignore | 1 + sfc-demo/sfc103/README.md | 42 ++++++++++++++++ sfc-demo/sfc103/Vagrantfile | 12 +++-- sfc-demo/sfc103/cleanup.py | 2 +- sfc-demo/sfc103/demo.sh | 48 +++++++++++++++---- sfc-demo/sfc103/setup.py | 10 +++- sfc-demo/sfc103/setup_classifier.sh | 2 +- sfc-demo/sfc103/setup_odl.sh | 14 ++++-- sfc-demo/sfc103/setup_sf.sh | 11 ++--- .../sfc/scfofrenderer/SfcScfMatch.java | 6 ++- 10 files changed, 118 insertions(+), 30 deletions(-) create mode 100644 sfc-demo/sfc103/README.md diff --git a/.gitignore b/.gitignore index ba7d2dc10..da627e351 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ node_modules/ node/ coverage/ .checkstyle +.vagrant diff --git a/sfc-demo/sfc103/README.md b/sfc-demo/sfc103/README.md new file mode 100644 index 000000000..5edd7d19f --- /dev/null +++ b/sfc-demo/sfc103/README.md @@ -0,0 +1,42 @@ +SFC103 Demo +=========== + +Overview +-------- + +SFC103 demo is to show standalone SFC classifier. + +Topology +------- + + +-----------------+ + | SFC | + | 192.168.1.5 | + +-----------------+ + / | | \ + / | | \ + / | | \ ++---------------+ +--------------+ +--------------+ +---------------+ +| Classifier1 | | SFF1 | | SFF2 | | Classifier2 | +| 192.168.1.10 | | 192.168.1.20 | | 192.168.1.50 | | 192.168.1.60 | ++---------------+ +--------------+ +--------------+ +---------------+ + | | + | | + +---------------+ +--------------+ + | DPI-1 | | FW-1 | + | 192.168.1.30 | | 192.168.1.40 | + +---------------+ +--------------+ + +Setup Demo +---------- +1. Install virtualbox & vagrant in ubuntu 14.04.03 +2. ./demo.sh + + +Cleanup Demo +------------ +1. vagrant destroy -f + + +Trouble Shooting(TBD) +-------------------- diff --git a/sfc-demo/sfc103/Vagrantfile b/sfc-demo/sfc103/Vagrantfile index c2a809caf..348db9807 100644 --- a/sfc-demo/sfc103/Vagrantfile +++ b/sfc-demo/sfc103/Vagrantfile @@ -12,7 +12,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| v.customize ["modifyvm", :id, "--memory", 1024] v.customize ["modifyvm", :id, "--cpus", 4] end - + + config.vm.synced_folder "../..", "/sfc" + config.vm.define "odl" do | h | h.vm.host_name = "odl" h.vm.network :private_network, ip: "192.168.1.5" @@ -21,22 +23,22 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| v.customize ["modifyvm", :id, "--cpus", 4] end end - + config.vm.define "classifier1" do | h | h.vm.host_name = "classifier1" h.vm.network :private_network, ip: "192.168.1.10" end - + config.vm.define "sff1" do | h | h.vm.host_name = "sff1" h.vm.network :private_network, ip: "192.168.1.20" end - + config.vm.define "sf1" do | h | h.vm.host_name = "sf1" h.vm.network :private_network, ip: "192.168.1.30" end - + config.vm.define "sf2" do | h | h.vm.host_name = "sf2" h.vm.network :private_network, ip: "192.168.1.40" diff --git a/sfc-demo/sfc103/cleanup.py b/sfc-demo/sfc103/cleanup.py index 0452fd376..2448c607d 100755 --- a/sfc-demo/sfc103/cleanup.py +++ b/sfc-demo/sfc103/cleanup.py @@ -24,7 +24,7 @@ def get_service_nodes_uri(): def get_service_functions_uri(): return "/restconf/config/service-function:service-functions" - + def get_service_function_forwarders_uri(): return "/restconf/config/service-function-forwarder:service-function-forwarders" diff --git a/sfc-demo/sfc103/demo.sh b/sfc-demo/sfc103/demo.sh index 65acbc88f..00b5f7d48 100755 --- a/sfc-demo/sfc103/demo.sh +++ b/sfc-demo/sfc103/demo.sh @@ -1,11 +1,41 @@ #!/bin/bash -#vagrant up -#vagrant ssh odl -c "/vagrant/setup_odl.sh" -vagrant ssh classifier1 -c "sudo /vagrant/setup_classifier.sh" -vagrant ssh classifier2 -c "sudo /vagrant/setup_classifier.sh" -vagrant ssh sf1 -c "sudo /vagrant/setup_sf.sh" -vagrant ssh sf2 -c "sudo /vagrant/setup_sf.sh" -vagrant ssh sff1 -c "sudo /vagrant/setup_sff.sh" -vagrant ssh sff2 -c "sudo /vagrant/setup_sff.sh" -vagrant ssh odl -c "/vagrant/setup.sh" +vagrant destroy -f +vagrant up +vagrant ssh odl -c "nohup /vagrant/setup_odl.sh & sleep 1" +vagrant ssh classifier1 -c "nohup sudo /vagrant/setup_classifier.sh & sleep 1" +vagrant ssh classifier2 -c "nohup sudo /vagrant/setup_classifier.sh & sleep 1" +vagrant ssh sf1 -c "nohup sudo /vagrant/setup_sf.sh & sleep 1" +vagrant ssh sf2 -c "nohup sudo /vagrant/setup_sf.sh & sleep 1" +vagrant ssh sff1 -c "nohup sudo /vagrant/setup_sff.sh & sleep 1" +vagrant ssh sff2 -c "nohup sudo /vagrant/setup_sff.sh & sleep 1" + +inprog=1 + +while [ $inprog -ne 0 ] +do + echo "check system is ready" + inprog=0 + vagrant ssh odl -c "sfc/sfc-karaf/target/assembly/bin/client -u karaf 'log:display' 2>/dev/null | grep 'Initialized RSP listener'" + inprog+=$? + vagrant ssh classifier1 -c "sudo ovs-vsctl show" + inprog+=$? + vagrant ssh classifier2 -c "sudo ovs-vsctl show" + inprog+=$? + vagrant ssh sff1 -c "sudo ovs-vsctl show" + inprog+=$? + vagrant ssh sff2 -c "sudo ovs-vsctl show" + inprog+=$? + vagrant ssh sf1 -c "ps -ef |grep sfc_agent.py" + inprog+=$? + vagrant ssh sf2 -c "ps -ef |grep sfc_agent.py" + inprog+=$? + sleep 30 +done + +vagrant ssh odl -c "/vagrant/setup.py" +sleep 60 +vagrant ssh classifier1 -c "sudo ovs-ofctl dump-flows -OOpenflow13 br-sfc" +vagrant ssh classifier2 -c "sudo ovs-ofctl dump-flows -OOpenflow13 br-sfc" +vagrant ssh sff1 -c "sudo ovs-ofctl dump-flows -OOpenflow13 br-sfc" +vagrant ssh sff2 -c "sudo ovs-ofctl dump-flows -OOpenflow13 br-sfc" vagrant ssh classifier1 -c "sudo ip netns exec app wget http://192.168.2.2" diff --git a/sfc-demo/sfc103/setup.py b/sfc-demo/sfc103/setup.py index 061584451..b7976941d 100755 --- a/sfc-demo/sfc103/setup.py +++ b/sfc-demo/sfc103/setup.py @@ -34,6 +34,7 @@ def put(host, port, uri, data, debug=False): if debug == True: print r.text r.raise_for_status() + time.sleep(5) def post(host, port, uri, data, debug=False): '''Perform a POST rest operation, using the URL and data provided''' @@ -48,6 +49,7 @@ def post(host, port, uri, data, debug=False): if debug == True: print r.text r.raise_for_status() + time.sleep(5) def get_service_nodes_uri(): return "/restconf/config/service-node:service-nodes" @@ -100,7 +102,7 @@ def get_service_nodes_data(): def get_service_functions_uri(): return "/restconf/config/service-function:service-functions" - + def get_service_functions_data(): return { "service-functions": { @@ -394,6 +396,9 @@ def get_service_function_acl_data(): "destination-ipv4-network": "192.168.2.0/24", "source-ipv4-network": "192.168.2.0/24", "protocol": "6", + "source-port-range": { + "lower-port": 0 + }, "destination-port-range": { "lower-port": 80 } @@ -417,6 +422,9 @@ def get_service_function_acl_data(): "protocol": "6", "source-port-range": { "lower-port": 80 + }, + "destination-port-range": { + "lower-port": 0 } } } diff --git a/sfc-demo/sfc103/setup_classifier.sh b/sfc-demo/sfc103/setup_classifier.sh index 9c10b36dd..586653a1c 100755 --- a/sfc-demo/sfc103/setup_classifier.sh +++ b/sfc-demo/sfc103/setup_classifier.sh @@ -39,6 +39,6 @@ else ip netns exec app ip link set dev veth-app up ip netns exec app ip link set dev lo up ip netns exec app ifconfig veth-app mtu 1400 - ip netns exec app python -m SimpleHTTPServer 80 & + ip netns exec app python -m SimpleHTTPServer 80 fi ovs-vsctl show diff --git a/sfc-demo/sfc103/setup_odl.sh b/sfc-demo/sfc103/setup_odl.sh index c899ec33d..706ccaf03 100755 --- a/sfc-demo/sfc103/setup_odl.sh +++ b/sfc-demo/sfc103/setup_odl.sh @@ -1,7 +1,12 @@ #!/bin/bash +echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections +sudo add-apt-repository ppa:webupd8team/java -y sudo apt-get update -y -sudo apt-get install openjdk-7-jdk mininet -y +sudo apt-get install oracle-java8-installer -y +sudo update-java-alternatives -s java-8-oracle +sudo apt-get install oracle-java8-set-default -y +sudo apt-get install mininet -y sudo mkdir -p /usr/local/apache-maven sudo wget http://ftp.wayne.edu/apache/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz sudo mv apache-maven-3.3.3-bin.tar.gz /usr/local/apache-maven @@ -14,12 +19,13 @@ sudo apt-get install npm vim git git-review diffstat -y cat << EOF >> /home/vagrant/.bashrc export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.3 export MAVEN_OPTS="-Xms256m -Xmx512m" # Very important to put the "m" on the end -export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 # This matches sudo update-alternatives --config java +export JAVA_HOME=/usr/lib/jvm/java-8-oracle # This matches sudo update-alternatives --config java EOF source /home/vagrant/.bashrc mkdir /home/vagrant/.m2 wget -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > /home/vagrant/.m2/settings.xml -cd /home/vagrant; git clone https://github.com/opendaylight/sfc.git -cd /home/vagrant/sfc; mvn clean install -nsu -DskipTests; sfc-karaf/target/assembly/bin/karaf & +rm -rf /home/vagrant/sfc; cp -r /sfc /home/vagrant +cd /home/vagrant/sfc; mvn clean install -nsu -DskipTests; +cd /home/vagrant/sfc/sfc-karaf/target/assembly; echo "log4j.logger.org.opendaylight.sfc = DEBUG,stdout" >> etc/org.ops4j.pax.logging.cfg; rm -rf journal snapshots; bin/karaf clean diff --git a/sfc-demo/sfc103/setup_sf.sh b/sfc-demo/sfc103/setup_sf.sh index ce30b3b4a..f938f16d5 100755 --- a/sfc-demo/sfc103/setup_sf.sh +++ b/sfc-demo/sfc103/setup_sf.sh @@ -7,12 +7,9 @@ apt-get install git -y apt-get install python3-flask requests netifaces -y apt-get install libssl-dev openssl -y apt-get install libnetfilter-queue-dev -y -apt-get install python3-pip -y -pip3 install sfc +apt-get install python3-pip python3-flask -y +pip3 install sfc paramiko flask apt-get install curl -y -cd /home/vagrant/ -git clone http://github.com/opendaylight/sfc - -cd /home/vagrant/sfc/sfc-py -sudo python3.4 sfc/sfc_agent.py --rest --odl-ip-port 192.168.1.5:8181 & +rm -rf /home/vagrant/sfc; cp -r /sfc /home/vagrant +cd /home/vagrant/sfc/sfc-py; python3.4 sfc/sfc_agent.py --rest --odl-ip-port 192.168.1.5:8181 diff --git a/sfc-scf-openflow/src/main/java/org/opendaylight/sfc/scfofrenderer/SfcScfMatch.java b/sfc-scf-openflow/src/main/java/org/opendaylight/sfc/scfofrenderer/SfcScfMatch.java index 97e9384f7..e82c03f2c 100644 --- a/sfc-scf-openflow/src/main/java/org/opendaylight/sfc/scfofrenderer/SfcScfMatch.java +++ b/sfc-scf-openflow/src/main/java/org/opendaylight/sfc/scfofrenderer/SfcScfMatch.java @@ -81,12 +81,14 @@ public class SfcScfMatch { if (aceip.getSourcePortRange() != null && aceip.getSourcePortRange().getLowerPort() != null && - aceip.getSourcePortRange().getLowerPort().getValue() != null) { + aceip.getSourcePortRange().getLowerPort().getValue() != null && + aceip.getSourcePortRange().getLowerPort().getValue().intValue() != 0) { srcPort = aceip.getSourcePortRange().getLowerPort().getValue(); } if (aceip.getDestinationPortRange() != null && aceip.getDestinationPortRange().getLowerPort() != null && - aceip.getDestinationPortRange().getLowerPort().getValue() != null) { + aceip.getDestinationPortRange().getLowerPort().getValue() != null && + aceip.getDestinationPortRange().getLowerPort().getValue().intValue() != 0) { dstPort = aceip.getDestinationPortRange().getLowerPort().getValue(); } -- 2.36.6