1 . Compiling openvswitch for android a) The different version that we used: Android version: 4.2.2 (jelly bean) Android source git: https://android.googlesource.com/device/lge/mako-kernel Android Kernel source git: https://android.googlesource.com/kernel/msm.git Kernel version: 3.4 Android Build: full_mako-usedebug 4.2.2 JDQ39 Openvswitch Kernel Module version: Open vSwitch switching datapath 1.11.90 Openvswitch version: (Open vSwitch) 1.11.90 OpenFlow versions 0x1:0x4 OpenvSwitch source git: git clone git://openvswitch.org/openvswitch OpenvSwitch git commit: c985ec94a2fe051f083a55d67311e643a432a7ae b) Directory Structure of different source code (in Mac OS C version 10.6.8) ANDROID_KERNEL: /Volumes/androidnew/kernel/msm Android source code Path: /Volumes/androidnew ANDROID_NDK_ROOT: /Volumes/androidnew/prebuils/ndk/8 Openvswitch source code Path: /Volumes/androidnew/openvswitch Android sdk path (dab tool path): /Users/umamaahmed/android-sdk-mac_86/tools c) export variables $ export ANDROID_NDK_ROOT=/Volumes/androidnew/prebuils/ndk/8 $ export PATH=$PATH:/Volumes/androidnew/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin $ export ANDROID_KERNEL=/Volumes/androidnew/kernel/msm $ export ANDROID_SOURCE=/Volumes/androidnew $ export PATH=$PATH:/Users/umamaahmed/android-sdk-mac_86/tools $ export OVS_DIR=/Volumes/androidnew/openvswitch d) Environment setup $ cd /Volumes/androidnew/openvswitch/ $./envsetup.sh $ git apply -v ovs_android.patch $./boot.sh f) Run following config command $ ./configure --prefix=/data/local/tmp --localstatedir=/data/local/tmp --host=arm-linux-androideabi CC=arm-linux-androideabi-gcc CPPFLAGS="-I$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/include/ -I$ANDROID_SOURCE/bionic/libc/include/" CFLAGS="-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0" LDFLAGS="-Bdynamic -Wl,-T,$ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,--entry=main,-dynamic-linker=/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,-rpath-link=$ANDROID_NDK_ROOT/platforms/android-8/arch-arm -L$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib -L$ANDROID_SOURCE/out/target/product/mako/obj/lib -nostdlib $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_android.o $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o" LIBS="-lc $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/lib/gcc/arm-linux-androideabi/4.6.x-google/libgcc.a -lm -llog -lgcc -lcrypto -lssl" after config command: Add the following line at the end of file: /Volumes/androidnew/openvswitch/config.h #define ANDROID_BUILD 1 (For Mac user only: Find the "STRESS_OPTION" in /Volumes/androidnew/openvswitch/Makefile file change the following as follows old line: sed -n '/^STRESS_OPTION(/,/);$$/{s/);$$/)/;p}' $(all_sources) > $@ new line: sed -n -e '/^STRESS_OPTION(/,/);$$/{s/);$$/)/' -e 'p' -e '}' $(all_sources) > $@) g) Run make command ARCH=arm CROSS_COMPILE=arm-linux-androideabi- make h) Successful run creates the library file libopenvswitch.a libovsdb.a libsflow.a Also It will create the kernel module in /Volumes/androidnew/openvswitch/datapath/linux/openvswitch.ko i) Now we use following gcc commands to build the different user space program of openvswitch $ cd utilities $ $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc -o ovs-dpctl -I/$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/include -I. -I../ -I../include/ -I../ofproto/ -I../lib/ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 ovs-dpctl.c -Bdynamic -Wl,-T,$ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,-rpath-link=$ANDROID_NDK_ROOT/platforms/android-8/arch-arm -L$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib -L$ANDROID_SOURCE/out/target/product/mako/obj/lib/ -nostdlib $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_android.o $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o -lc $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/lib/gcc/arm-linux-androideabi/4.6.x-google/libgcc.a $OVS_DIR/ofproto/libofproto.a $OVS_DIR/lib/libopenvswitch.a $OVS_DIR/lib/libsflow.a -lm -ldl -lgcc -lcrypto -lssl *above command create ovs-dpctl $ $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc -o ovs-ofctl -I/$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/include -I. -I../ -I../include/ -I../ofproto/ -I../lib/ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 ovs-ofctl.c -Bdynamic -Wl,-T,$ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,-rpath-link=$ANDROID_NDK_ROOT/platforms/android-8/arch-arm -L$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib -L$ANDROID_SOURCE/out/target/product/mako/obj/lib/ -nostdlib $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_android.o $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o -lc $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/lib/gcc/arm-linux-androideabi/4.6.x-google/libgcc.a $OVS_DIR/ofproto/libofproto.a $OVS_DIR/lib/libopenvswitch.a $OVS_DIR/lib/libsflow.a -lm -ldl -lgcc -lcrypto -lssl * above command create ovs-ofctl $ $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc -o ovs-vsctl -I$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/include -I. -I../ -I../include/ -I../ofproto/ -I../lib/ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 ovs-vsctl.c -Bdynamic -Wl,-T,$ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,-rpath-link=$ANDROID_SOURCE/prebuilts/ndk/8/platforms/android-8/arch-arm -L/Volumes/androidnew/prebuilts/ndk/8/platforms/android-8/arch-arm/usr/lib -L/Volumes/androidnew/out/target/product/mako/obj/lib/ -nostdlib $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_android.o $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o -lc /Volumes/androidnew/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/lib/gcc/arm-linux-androideabi/4.6.x-google/libgcc.a $OVS_DIR/ofproto/libofproto.a $OVS_DIR/lib/libopenvswitch.a $OVS_DIR/lib/libsflow.a -lm -ldl -lgcc -lcrypto -lssl *above command create ovs-vsctl $ cd ../vswitchd $ $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc ovs-vswitchd.c bridge.c system-stats.c xenserver.c -o ovs-vswitchd -I/Volumes/androidnew/prebuilts/ndk/8/platforms/android-8/arch-arm/usr/include -I. -I../ -I../include -I../ofproto -I../lib -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -Bdynamic -Wl,-T,$ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,-rpath-link=$ANDROID_NDK_ROOT/platforms/android-8/arch-arm -L$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib -L$ANDROID_SOURCE/out/target/product/mako/obj/lib/ -nostdlib $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_android.o $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o -lc $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/lib/gcc/arm-linux-androideabi/4.6.x-google/libgcc.a $OVS_DIR/ofproto/libofproto.a $OVS_DIR/lib/libopenvswitch.a $OVS_DIR/lib/libsflow.a -lm -ldl -lgcc -lcrypto -lssl * above command create ovs-vswitchd $ cd ../ovsdb $ $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc -o ovsdb-server -I$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/include -I. -I../ -I../include/ -I../ofproto/ -I../lib/ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 ovsdb-server.c -Bdynamic -Wl,-T,$ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,-rpath-link=$ANDROID_NDK_ROOT/platforms/android-8/arch-arm -L$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib -L$ANDROID_SOURCE/out/target/product/mako/obj/lib/ -nostdlib $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_android.o $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o -lc $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/lib/gcc/arm-linux-androideabi/4.6.x-google/libgcc.a $OVS_DIR/ovsdb/libovsdb.a $OVS_DIR/ofproto/libofproto.a $OVS_DIR/lib/libopenvswitch.a $OVS_DIR/lib/libsflow.a -lm -ldl -lgcc -lcrypto -lssl * above command create ovsdb-server $ $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/arm-linux-androideabi-gcc -o ovsdb-tool -I$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/include -I. -I../ -I../include/ -I../ofproto/ -I../lib/ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DSK_RELEASE -DNDEBUG -UDEBUG -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork -fpic -fno-exceptions -ffunction-sections -funwind-tables -fmessage-length=0 ovsdb-tool.c -Bdynamic -Wl,-T,$ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -Wl,--no-undefined -Wl,-rpath-link=$ANDROID_NDK_ROOT/platforms/android-8/arch-arm -L$ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib -L$ANDROID_SOURCE/out/target/product/mako/obj/lib/ -nostdlib $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_android.o $ANDROID_NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o -lc $ANDROID_SOURCE/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/lib/gcc/arm-linux-androideabi/4.6.x-google/libgcc.a $OVS_DIR/ovsdb/libovsdb.a $OVS_DIR/ofproto/libofproto.a $OVS_DIR/lib/libopenvswitch.a $OVS_DIR/lib/libsflow.a -lm -ldl -lgcc -lcrypto -lssl * above command create ovsdb-tool 2. Installing openvswitch in android a) create directory structure as follows in the Android device /data/loca/tmp/bin /data/local/tmp/etc/openvswitch /data/local/tmp/log/openvswitch /data/local/tmp/run/openvswitch /data/local/tmp/share/openvswitch b) Run following command to loathe files into Android device $ adb push /Volumes/androidnew/kernel/openvswitch/ovsdb/ovsdb-tool /data/local/tmp/bin/ $ adb push /Volumes/androidnew/kernel/openvswitch/ovsdb/ovsdb-server /data/local/tmp/bin/ $ adb push /Volumes/androidnew/kernel/openvswitch/utilities/ovs-ofctl /data/local/tmp/bin/ $ adb push /Volumes/androidnew/kernel/openvswitch/utilities/ovs-dpctl /data/local/tmp/bin/ $ adb push /Volumes/androidnew/kernel/openvswitch/vswitchd/ovs-vswitchd /data/local/tmp/bin/ $ adb push /Volumes/androidnew/kernel/openvswitch/utilities/ovs-vsctl /data/local/tmp/bin/ $ adb push /Volumes/androidnew/kernel/openvswitch/datapath/linux/openvswitch.ko /data/local/tmp/ $ adb push /Volumes/androidnew/kernel/openvswitch/vswitchd/vswitch.ovsschema /data/local/tmp/ c) install the kernel module $ adb shell shell@android:/ $ su shell@android:/ # insmod /data/local/tmp/openvswitch.ko Check whether it is installed shell@android:/ # dmesg d) Create db and start ovs-vswitchd daemon shell@android:/ # cd /data/local/tmp/bin shell@android:/data/local/tmp/bin # ./ovsdb-tool create /data/local/tmp/etc/openvswitch/conf.db ../vswitch.ovsschema shell@android:/data/local/tmp/bin # ./ovsdb-server --remote=punix:/data/local/tmp/run/openvswitch/db.sock \ --remote=db:Open_vSwitch,manager_options \ --pidfile --detach shell@android:/data/local/tmp/bin # ./ovs-vsctl --no-wait init shell@android:/data/local/tmp/bin # ./ovs-vswitchd --pidfile --detach 2013-06-12T19:54:16Z|00001|reconnect|INFO|unix:/data/local/tmp/run/openvswitch/db.sock: connecting... 2013-06-12T19:54:16Z|00002|reconnect|INFO|unix:/data/local/tmp/run/openvswitch/db.sock: connected