[转]Part1 – OPENVSWICH – Creating and Submitting Openvswitch Extension To Tinycore Upstream

In May 2011, I read a request for installation Openvswitch on Qemu image. I started to play with Openvswitch and finally became fan of this project. I realized how powerful can be Openvswitch, offering many features listed here.  Spending my time playing with Microcore and Openvswitch after several days I was able to create Microcore Qemu image with 8021q support  and install Openvswitch on the top of it.

In the tutorial I would like to show how to create Openvswitch extension and make it ready for submit to the Tinycore upstream.  I chose Core Linux, because I am familiar with this minimal Linux distribution and the Core is incredibly small.

The following steps describe installation Openvswitch on Qemu image with pre-installed Microcore Linux.

I also created three labs using Openvswitch. I tested how can Openvswitch works with VLANs, 802.1q trunk ports,  if it was capable of creating L3 VLAN interfaces and Inter VLAN routing was working.  Labs are available here:

1. Start Qemu Microcore image

Assuming your Microcore Qemu image with console support has been created and supports 8021q VLAN tagging, start the image:

qemu-kvm /home/brezular/linux-microcore-4.7.7.img -m 512

2. Download Openvswitch and Extract it

wget http://openvswitch.org/releases/openvswitch-1.11.0.tar.gz

tar zxvf ./openvswitch-1.11.0.tar.gz

cd ./openvswitch-1.1.0

3. Install Necessary Dependences for Openvswitch Compilation

tce-load -w -i compiletc.tcz python.tcz perl5.tcz openssl-1.0.0-dev.tcz tunctl.tcz bridge-utils.tcz linux-headers-3.0.21-tinycore.tcz

To compile openvswitch with  the ovsdmonitor tool, the machine must also have the following installed software:

tce-load -w -i python_twisted-2.7.tcz python-simplejson.tcz python_zope.interface-2.7 pyqt.tcz

Note:  The kernel source will be saved in /lib/modules/`uname -r`/build

It is recommended to check the list of necessary applications here:

4. Openvswitch Installation

It is recommended to start here and continue here :-) After that you can type following:

export CFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export CXXFLAGS="-march=i486 -mtune=i686 -Os -pipe"
export LDFLAGS="-Wl,-O1"

cd ./openvswitch-1.11.0

./configure --prefix=/usr/local --with-linux=/lib/modules/`uname -r`/build

make -j2

sudo su

cd /home/tc/openvswitch-1.11.0/

make  DESTDIR=/tmp/openvswitch install

5. BACKUP and LOAD Module openvswitch.ko

a) BACKUP module openvswitch.ko

After building, a kernel module “openvswitch.ko” will be saved in a ./datapath/linux/ directory. We’ve built both userspace and kernel module as well.  The performance is better when a kernel module is used. Create a directory in a structure of the openvswitch extension where the kernel module openvswitch.ko will be saved.

sudo mkdir -p /tmp/openvswitch/usr/local/lib/modules/3.0.21-tinycore/kernel/openvswitch/

Copy the kernel module to the directory.

sudo cp /home/tc/openvswitch-1.11.0/datapath/linux/openvswitch.ko  /tmp/openvswitch/usr/local/lib/modules/3.0.21-tinycore/kernel/openvswitch/

b) Check if module can be loaded correctly

sudo mkdir -p /usr/local/lib/modules/3.0.21-tinycore/kernel/openvswitch/

sudo cp /home/tc/openvswitch-1.11.0/datapath/linux/openvswitch.ko  /usr/local/lib/modules/3.0.21-tinycore/kernel/openvswitch/

depmod -a

sudo modprobe openvswitch

Check if module openvswitch_mod.ko is loaded to the kernel with lsmod command.

lsmod | grep openvswitch
openvswitch 49152 0

6. Backup /home/tc/openvswitch-1.11.0/vswitchd/vswitch.ovsschema

In order to initialize the configuration database using ovsdb-tool later, the file /home/tc/openvswitch-1.11.0/vswitchd/vswitch.ovsschema is needed. You need to copy it to /tmp/openvswitch/usr/local/etc/openvswitch/vswitchd/ to become part of the extension.

sudo mkdir -p /tmp/openvswitch/usr/local/etc/openvswitch/vswitchd/

sudo cp /home/tc/openvswitch-1.11.0/vswitchd/vswitch.ovsschema /tmp/openvswitch/usr/local/etc/openvswitch/vswitchd/

7. Create Openvswitch Extension

a) Remove unneccessary files

sudo rm -rf /tmp/openvswitch/usr/local/share/man/

b) Install squashfs and create openvswitch-3.0.21-tinycore.tcz extension

tce-load -w -i squashfs-tools-4.x

sudo su
cd /tmp/
mksquashfs openvswitch/ openvswitch-3.0.21-tinycore.tcz

c) Create a list of files presented in extension

sudo su
cd /tmp/openvswitch/
find usr -not -type d > ../openvswitch-3.0.21-tinycore.tcz.list
cd ..

d) Create md5 check sum of openvswitch-3.0.21-tinycore.tcz

md5sum openvswitch-3.0.21-tinycore.tcz > openvswitch-3.0.21-tinycore.tcz.md5.txt

e) Create openvswitch-3.0.21-tinycore.tcz.info

An info file describing its contents (.tcz.info) – this content is standardized. Check repository for examples.

f) Create openvswitch-3.0.21-tinycore.tcz.build-dep file

Additional build instructions in a plain text file for future reference, mentioning such things as which extensions are required to build the package and what compile flags were used.

g) Create the dependency list openvswitch-3.0.21-tinycore.tcz.dep

List of the extensions that have to be presented to run openvswitch extension correctly.

h) Install  openssh.tcz an extension and copy all openvswitch-3.0.21-tinycore.tcz.*  files and a source file to the guest system

tce-load -wi openssh

cp -rv /home/tc/openvswitch-1.11.0.tar.gz /tmp

scp -rv /tmp/openvswitch-3.0.21-tinycore.* [email protected]:/home/brezular/
scp -rv /tmp/openvswitch-1.11.0.tar.gz [email protected]:/home/brezular/

8. Test and Submit Openvswitch Extension

a) Create the new  clean Microcore Qemu image without any extensions installed

Assuming the image is ready to start, run it:

qemu-kvm /home/brezular/linux-microcore-4.7.7-clean.img -m 512

b) Install submitqc.tcz and openssh.tcz

tce-load -wi submitqc4.tcz openssh.tcz

c) Copy the openvswitch files you have created in steps 1 – 7

(.tcz, .list, .md5.txt, .info, .dep, build-dep) from old Qemu image to the clean Qemu image, to the directory  /tmp/All.

mkdir /tmp/All
cd /tmp/All

scp -rv [email protected]:/home/brezular/linux-core-nemaz/extensions/openvswitch/* .

Run an extension testing script:

sudo submitqc4

The script checks all openvswitch files in /tmp/All and creates the directory /tmp/submitqc/ with log files.

d) Send extension

sudo mv /tmp/submitqc /tmp/All
cd /tmp/All

sudo tar zcvf openvswitch-1.11.0-extension.tar.gz *

Send openvswitch-1.11.0-extension.tar.gz  to  [email protected]

e) Copy new created files to the guest

sudo scp -rv submitqc/ [email protected]:/home/brezular/
sudo scp -rv openvswitch-3.0.21-tinycore.tcz.zsync [email protected]:/home/brezular/
sudo scp -rv openvswitch-1.11.0-extension.tar.gz [email protected]:/home/brezular/

9. Openvswitch After-Install Configuration

a) Make openvswitch, 8021q, ipv6 modules to be loaded to a kernel during boot of Microcore

echo "modprobe openvswitch" >> /opt/bootlocal.sh
echo "modprobe 8021q" >> /opt/bootlocal.sh
echo "modprobe ipv6" >> /opt/bootlocal.sh

sudo modprobe openvswitch_mod
sudo modprobe 8021q
sudo modprobe ipv6

b) Initialize the configuration database using ovsdb-tool

Check if a directory /usr/local/etc/openvswitch/ exists, if not create it.

sudo mkdir -p /usr/local/etc/openvswitch/

Create conf.db configuration file.

sudo ovsdb-tool create /usr/local/etc/openvswitch/conf.db /usr/local/etc/openvswitch/vswitchd/vswitch.ovsschema

Add /usr/local/etc/openvswitch/ to the list of after restart kept files.

echo "/usr/local/etc/openvswitch/" >> /opt/.filetool.lst

c) Make ovsdb-server to be started after start of the Microcore

vi /opt/bootlocal.sh

/usr/local/sbin/ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock
                             --remote=db:Open_vSwitch,Open_vSwitch,manager_options
                             --private-key=db:Open_vSwitch,SSL,private_key
                             --certificate=db:Open_vSwitch,SSL,certificate
                             --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert
                             --pidfile --detach

:wq!

Note:  If you are not familiar with vi editor, use the reference below, please:

http://nemesis.lonestar.org/reference/docs/vi.html

d) Make the database initialialization using ovs-vsctl

This is only necessary the first time after you create the database with ovsdb-tool (but running it at any time is harmless).

echo "/usr/local/bin/ovs-vsctl --no-wait init" >> /opt/bootlocal.sh

e) Make the main Open vSwitch daemon being started, telling it to connect to the same Unix domain socket

echo "/usr/local/sbin/ovs-vswitchd --pidfile --detach" >> /opt/bootlocal.sh

f) Enable IPv4 and IPV6 packets forwarding between interfaces

Although not directly connected with Openvswitch configuration we need to enable ipv4 and ipv6 packets forwarding between interfaces for Microcore.  This option  is disabled in kernel by default.

sudo sysctl -w net.ipv4.ip_forward=1

sudo sysctl -w net.ipv6.conf.all.forwarding=1

echo "sysctl -w net.ipv4.ip_forward=1" >> /opt/bootlocal.sh

echo "sysctl -w net.ipv6.conf.all.forwarding=1" >> /opt/bootlocal.sh

g) Run commands you have entered into  /opt/bootlocal.sh and make them persistent after restart of the Microcore

sudo /opt/bootlocal.sh

Optionally: It is recommended to delete the history of used commands.

echo "" > /home/tc/.ash_history

Save changes made for files and directories which are listed in  /opt/.filetool.lst

/usr/bin/filetool.sh -b

10. Configuration example

Now you may use ovs-vsctl to set up bridges and other Open vSwitch features.  For example, to create a bridge named br0 and add ports eth0, eth1  and eth2 to it:

sudo ovs-vsctl add-br br0

sudo ovs-vsctl add-port br0 eth0

sudo ovs-vsctl add-port br0 eth1

sudo ovs-vsctl add-port br0 eth2

Before shutdown you always force Core to save configuration changes in the openvswitch database file –  /usr/local/etc/openvswitch/conf.db. Use the command:

/usr/bin/filetool.sh -b

Reference

http://openvswitch.org/

http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.userspace;hb=HEAD

http://openvswitch.org/?page_id=14

http://openvswitch.org/cgi-bin/gitweb.cgi?p=openvswitch;a=blob_plain;f=INSTALL.Linux;hb=HEAD

[转]Part1 – OPENVSWICH – Creating and Submitting Openvswitch Extension To Tinycore Upstream,布布扣,bubuko.com

时间: 2024-10-21 20:49:03

[转]Part1 – OPENVSWICH – Creating and Submitting Openvswitch Extension To Tinycore Upstream的相关文章

Part1 – OPENVSWICH – Creating and Submitting Openvswitch Extension To Tinycore Upstream

In May 2011, I read a request for installation Openvswitch on Qemu image. I started to play with Openvswitch and finally became fan of this project. I realized how powerful can be Openvswitch, offering many features listed here.  Spending my time pla

Part3 – OPENVSWICH – Campus Model with Layer2 Access built with Open-Source Applications

In part one we showed how to create Openvswitch extension and submit it to Microcore repository. There were also presented after-install steps for Openvswitch adapted for specific Core needs. http://brezular.com/2011/09/03/part1-openvswich-creating-a

Part2 – OPENVSWICH – VLANs, Trunks, L3 VLAN interface, InterVLAN Routing – Configuration And Testing

In a previous tutorial we showed how to install Openvswitch on Qemu image with Microcore Linux. At the end of tutorial we created Openvswitch extension and submitted it to Microcore upstream. Assuming that Openvswitch is configured and functional, we

米扑科技的开源项目:sitemap-php 自动生成网站地图

米扑科技旗下的产品,近期正在做SEO网站优化,其中子需求之一是调研实现了网站地图(sitemap.xml) 封装简化了许多功能模块,现在分享出来,源代码可在Github上下载,有简单的示例. Github 开源网址: sitemap-php What is sitemap-php ? sitemap-php 是一个轻量级.简单快速生成网站地图的开源项目,由北京米扑科技有限公司(mimvp.com)开发分享. 通过简单的配置定义,一个函数createSitemap(),可自动生成sitemap.x

Amazon - removed your selling privileges and placed a temporary hold on any funds - 1

Hello, We are writing to let you know that we have removed your selling privileges and placed a temporary hold on any funds in your Marketplace Payments account. We took this action because you may have violated our policies by adding images to produ

python windows打包

接触过的工具有pyinstaller,或者py2exe.感觉pyinstaller更简单易用. 真正将依赖的dll打包称一个安装包还需要借助windows打包工具 Inno Setup 或 NSIS 1.pyinstaller 官网:www.pyinstaller.org 两大步 (1)Install PyInstaller from PyPI: pip install pyinstaller (2)Go to your program's directory and run: pyinstal

创建过滤扩展方法 Creating Filtering Extension Methods 精通ASP-NET-MVC-5-弗瑞曼 Listing 4-17

Creating SSL keys, CSRs, self-signed certificates, and .pem files.

What is the whole darned process? Well that’s a good question. For my purposes, this is what I need to know: Create a Private Key. These usually end in the file extension “key” If you already have one, don’t worry - it’s cool, we’ll be using that one

Java Secure Socket Extension (JSSE) Reference Guide

Skip to Content Oracle Technology Network Software Downloads Documentation Search Java Secure Socket Extension (JSSE) Reference Guide This guide covers the following topics: Skip Navigation Links Introduction Features and Benefits JSSE Standard API S