lxc and openvswtich

Intended to use ovs with lxc before, but lxc only support linux bridge:

int lxc_bridge_attach(const char *bridge, const char *ifname)
{
int fd, index, err;
struct ifreq ifr;

if (strlen(ifname) >= IFNAMSIZ)
return -EINVAL;

index = if_nametoindex(ifname);
if (!index)
return -EINVAL;

process_lock();
fd = socket(AF_INET, SOCK_STREAM, 0);
process_unlock();
if (fd < 0)
return -errno;

strncpy(ifr.ifr_name, bridge, IFNAMSIZ);
ifr.ifr_ifindex = index;
err = ioctl(fd, SIOCBRADDIF, &ifr);
process_lock();
close(fd);
process_unlock();
if (err)
err = -errno;

return err;
}

here we can see only linux bridg supported, if you try to attach to ovs, it fails.
with help from a friend, had some changes here:


--- lxc-1.0.0~alpha1.orig/src/lxc/network.c 2013-09-11 06:22:00.000000000 +0800
+++ lxc-1.0.0~alpha1/src/lxc/network.c 2013-10-12 22:01:28.926679880 +0800
@@ -986,6 +986,9 @@
{
int fd, index, err;
struct ifreq ifr;
+ struct stat sb;
+ char brdirname[22 + IFNAMSIZ + 1] = {0};
+ char ovscmd[20 + IFNAMSIZ * 2 + 1] = {0};

if (strlen(ifname) >= IFNAMSIZ)
return -EINVAL;
@@ -993,6 +996,15 @@
index = if_nametoindex(ifname);
if (!index)
return -EINVAL;
+ snprintf(brdirname, 22 +IFNAMSIZ + 1, "/sys/class/net/%s/bridge", bridge);
+ if (stat(brdirname, &sb) == -1) {
+ if (errno == ENOENT) {
+ snprintf(ovscmd, 20 + IFNAMSIZ * 2 + 1, "ovs-vsctl add-port %s %s", bridge, ifname);
+ err = system(ovscmd);
+ } else {
+ err = -EINVAL;
+ }
+ } else if (S_ISDIR(sb.st_mode)) {

fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
@@ -1004,7 +1016,9 @@
close(fd);
if (err)
err = -errno;
-
+ } else {
+ err = -EINVAL;
+ }
return err;
}

This patch was made for lxc in ubuntu 13.10, I have it build in my ppa. binary package can be found from my ppa
ppa:zhengpeng-hou/dev.
So now, I have all my containers bridged to my home network directly.
https://docs.google.com/file/d/0BwNEP6aM800AMUhHcDdQb3B1NEU/edit?usp=sharing

openvswitch on openwrt router

To set up a lab at home, I need a openflow compatible swtich, was thinking about buy a netfpga, seems its not cost effective. Then turn to find a router which can be flashed with openwrt, this approach make more sense for me. Searched from taobao, I got a buffalo’s wzr-hp-300np, which has a decent specs.
4 x 1GHz lan port
32M flash and 64M RAM.
Its supported since openwrt’s 10.03 release, so latest release can be flashed too, even the trunk release, if you want to try with 3.10.1 version of kernel.
It comes with buffalo’s stock rom, the one I got is actually a Japanese release, which means you can’t flash openwrt directly, because of the bootloaded has been locked to refuse flash non-japanese firmware, tricky here is you can flash dd-wrt by using buffalo’s web flash tool, then you can flash openwrt from within dd-wrt. Not too bad.
To use openwrt, you may choose a release from their website or you may build it from trunk, no matter which one you choose, you need set up a openwrt build environment. Because there is no such a openvswitch binary package, so I’d build by myself.

Checkout from my branch, which was upgraded to build openvswitch-1.10.0 version.
https://github.com/zhengpenghou/openvswitch

And then follow instructions on openwrt to flash the image and install openvswitch’s package onto your router, your openflow compatible switch is ready. After boot up the switch, ssh into it, edit the network config accordingly.

Here is mine for your reference, each switch’s configuration differs from others.

config interface ‘loopback’
option ifname ‘lo’
option proto ‘static’
option ipaddr ‘127.0.0.1’
option netmask ‘255.0.0.0’

config globals ‘globals’
option ula_prefix ‘fdcc:c956:e56e::/48’

config interface ‘lan’
option ifname ‘eth0.1’
option type ‘bridge’
option proto ‘static’
option netmask ‘255.255.255.0’
option ip6assign ’60’
option ipaddr ‘192.168.1.251’
option gateway ‘192.168.1.1’
option broadcast ‘192.168.1.255’
option dns ‘192.168.1.1’

config interface ‘wan’
option ifname ‘eth1’
option _orig_ifname ‘eth1’
option _orig_bridge ‘false’
option proto ‘static’

config switch
option name ‘switch0’
option reset ‘1’
option enable_vlan ‘1’
option enable_vlan4k ‘1’

config switch_vlan
option device ‘switch0’
option vlan ‘1’
option ports ‘0 5t’

config interface
option ifname ‘eth0.2’
option proto ‘static’

config interface
option ifname ‘eth0.3’
option proto ‘static’

config interface
option ifname ‘eth0.4’
option proto ‘static’

config switch_vlan
option device ‘switch0’
option vlan ‘2’
option ports ‘1 5t’

config switch_vlan
option device ‘switch0’
option vlan ‘3’
option ports ‘2 5t’

config switch_vlan
option device ‘switch0’
option vlan ‘4’
option ports ‘3 5t’

and then add a bridge, add port into the bridge

ovs-vsctl add-br ovsbr0
ovs-vsctl add-port ovsbr0 eth0.1 — set Interface eth0.1 ofport_request=1
ovs-vsctl add-port ovsbr0 eth0.2 — set Interface eth0.2 ofport_request=2
ovs-vsctl add-port ovsbr0 eth0.3 — set Interface eth0.3 ofport_request=3
ovs-vsctl add-port ovsbr0 eth0.4 — set Interface eth0.4 ofport_request=4

ovs is up to be used now. if you mess it up, reset the router.

What are you doing, mozilla china?

Gnome asia summit finished, I were at beijing lug booth in the past two days. the worst thing I’d encountered was the mozilla china, I really can not understand what are they doing in china. the day before the event opened, I met a guy from mozilla china who was preparing the upcoming event for their own booth, this guy tried to install mplay onto a machine installed with ubuntu, but he didn’t know how to do it, then I asked him which kind of video format he would use, he told me its mov from apple, hehe, they’re using mov.

At the sencond day, I met another marketing gilr from mozilla china, I talked with her, I found she even didn’t know how many projects mozilla foundation had, even worse is she can not give any other more projects name from mozilla foundation.

I’m finding another music manager

After talked with a developer of amarok in IRC, he told me amarok2 will drop out the support of python, and they will only support qtscript and ruby. Its really sorry for amarok team, we will not use those plugin writen in python now. So I will switch to use other music manager.

One meaningless discuss

Why shall we involve into such a meaningless discussion ([zeuux-universe] 从专有软件到自由软件的挣扎(NeedHelp)), too much similiar thread on this list ;).

What’s the meaning of free/freedom? lets have a look:
1 the right to do what you want without being controlled or restricted by anyone:
2 the state of being free and allowed to do what you want
3 freedom
and we can list many many.

come back to the FLOSS, all we should do is make others know that they have one more choice, only this is enough, you can not force others to use FLOSS, you can not persude others to fight against something company with you. That’s not free/freedom. But we can try our best to make others know what kind of decision they wanna. So just do it, don’t talk too much. As 胡适 has said:
我自己決不想牽著誰的鼻子走。我只希望盡我的微薄的能力,教我的少年朋友們學一點防身的本領,努力做一個不受人惑的人。」

I’m looking for a tool for nntp reader

I’ve used the gnus and knode, gnus was written in Lisp, but lisp dosen’t multi-thread, so its too slow when you start to fetch the list from nntp server, sometime its like freeze, I can not bear the snowness. Then back to use knode? Its not a good idea, for I’m still using a aged ibook, the right one I prefer shall be a cli one.
I’ve tried slrn, it need a valid hostname, annoying.