前言


本篇記錄如何編譯OpenWrt 和把 OpenvSwitch 植入在 TL-1043ND 上

環境


Linux Mint 16 64-bit

Cross-Compiling


  1. 相關套件

    1
    2
    3
    $ sudo apt-get install build-essential binutils flex \
    bison autoconf gettext texinfo sharutils subversion \
    libncurses5-dev ncurses-term zlib1g-dev gawk git-core
  2. openwrt source code

    1
    $ git clone http://git.openwrt.org/12.09/openwrt.git
  3. change directory

    1
    $ cd openwrt
  4. change default feed.conf name

    1
    $ mv feeds.conf.default feeds.conf
  5. update & install all package

    1
    2
    $ ./scripts/feeds update -a
    $ ./scripts/feeds install -a
  6. Install LUCI

    1
    $ ./scripts/feeds install -a luci
  7. Adding Openvswitch feed, update & install

    1
    2
    3
    $ echo 'src-git openvswitch git://github.com/ttsubo/openvswitch.git' >> feeds.conf
    $ ./scripts/feeds update openvswitch
    $ ./scripts/feeds install -a -p openvswitch
  8. menuconfig

    1
    $ make menuconfig
    • Target System: Atheros AR7xxx/AR9xxx
    • Target Profile: TP-LINK TL-WR1043N/ND
    • LuCI -> Collections -> luci
    • Network -> openvswitchswitch-common, openvswitch-ipsec, openvswitch-switch
  9. Make

    1
    make V=s

OVS 設置

1
2
3
4
5
$ ovs-vsctl set bridge ovsbr0 protocols=OpenFlow10,OpenFlow13
$ ovs-vsctl set-fail-mode ovsbr0 standalone
# 當沒連上 Controller 時作為一般的switch
$ ovs-vsctl setcontroller ovsbr0 tcp:192.168.8.126:6633
# Setting Controller IP:192.168.8.126 Port:6633

OVS 常用指令

1
2
3
4
5
6
7
8
$ ovs-vsctl set controller ovsbr0 tcp:192.168.8.126:6633
# Setting Controller IP:192.168.8.126 Port:6633
$ ovs-vsctl show
# Show virtual switch status
$ ovs-ofctl dump-flows ovsbr0 -O openflow13
# Dump flow table
$ ovs-ofctl del-flows ovsbr0 -O openflow13
# Delete flow table

時間


一小時左右

參考資料