Archive for October, 2006

Multicast and Threading

Sunday, October 29th, 2006

I have two gateways at home, both running different operating systems. There are quite a few alternatives for router failover. However most opensource VRRP inplementations suck (keepalived, vrrpd, freevrrpd) as does CARP on linux (ucarp). Which is why I decided to scratch this itch by writing my own failover daemon in perl.

I quickly settled on multicast and a somewhat vrrp-like packet format with hmac to secure the messages. The send and receive tasks are handled by separate threads, which allows the main loop to just be a simple state machine. Installation is quite simple (if you have daemontools):


mkdir -p failoverd/bin
mkdir -p failoverd/env
mkdir -p failoverd/log/main

cat <failoverd/run
#!/bin/sh

exec 2>&1
exec envdir ./env ./bin/failoverd
EOF

cat <failoverd/log/run
#!/bin/sh
exec setuidgid nobody multilog t ./main
EOF

chmod +x failoverd/run failoverd/log/run
chown nobody failoverd/log/main

echo MYINTERFACE > failoverd/env/INTERFACE
echo MYPASSWORD > failoverd/env/SECRET
echo 100 > failoverd/env/PRIO
echo ./bin/backup > failoverd/env/BACKUP
echo ./bin/master > failoverd/env/MASTER

Download the daemon and put it in failoverd/bin, and write your own custom backup/master scripts.

Ubuntu Dapper & IPv6

Sunday, October 29th, 2006

If ipv6 doesn’t work as expected on dapper, aka routing doesn’t work, just add ipv6 to /etc/initramfs-tools/modules.

echo ipv6 >> /etc/initramfs-tools/modules

After mkinitramfs and a reboot IPv6 should be functional again.

Daemontools with upstart

Sunday, October 29th, 2006

Ubuntu Edgy includes upstart, a replacement for the regular SysV init. This also obsoletes /etc/inittab, which is replaced by the new /etc/event.d directory. Unfortunately the daemontools-installer package in universe doesn’t quite understand upstart just yet. Starting daemontools via upstart is quite easy. Just add the following to /etc/event.d/svscan:


# svscan - daemontools
#
# This service starts daemontools from the point the system is
# started until it is shut down again.

start on runlevel-2
start on runlevel-3
start on runlevel-4
start on runlevel-5

stop on shutdown

respawn /usr/bin/svscanboot

Then start daemontools with ‘start svscan’

named vlan interfaces

Sunday, October 29th, 2006

This simple snippet allows creating vlan interfaces with custom names
on debian/ubuntu. Add the following to /etc/network/if-pre-up.d/blink:


#!/bin/sh

if [ -n "$IF_VLAN_RAW_DEVICE" ] && [ -n "IF_VLAN_ID" ]; then
        vconfig set_name_type VLAN_PLUS_VID_NO_PAD
        vconfig add $IF_VLAN_RAW_DEVICE $IF_VLAN_ID
        ip link set vlan$IF_VLAN_ID name $IFACE
fi

This will allow entries like this in /etc/network/interfaces:


iface management inet static
        address 192.168.3.2
        netmask 255.255.255.0
        vlan-raw-device intern
        vlan-id 3

intern is a network interface which is renamed using the regular /etc/iftab.

Red Cabbage

Saturday, October 14th, 2006

Ingredients:

  • 1 Red Cabbage
  • 3 Sweet Apples
  • Cloves
  • Sugar

Chop the cabbage and the apples into rough chunks. Put the chunks into a pan together with the cloves and some water. Let the cabbage cook on a low fire until the apples have dissolved and the cabbage is soft. Then add sugar to soften the flavour. If there is a lot of cooking liquid left then it’s advisable to reduce it down in a separate pan, doing so will enhance the flavour.

Garlic Butter

Saturday, October 7th, 2006

Ingredients:

  • Butter
  • Garlic cloves
  • Lovage (Lavas)
  • Salt

Grab a bowl large enough to hold all the ingredients. Soften the butter using a fork. Crush the garlic with a garlic press. Finely slice the lovage leaves. Mix everything together. Finally add salt to taste, quite a lot is needed for a really intense flavour. The lovage adds another dimension to the regular garlic butter flavour which should make this version quite a lot more interesting.

Chinese Tomato Soup

Wednesday, October 4th, 2006

Ingredients:

  • canned tomatoes
  • ginger
  • ketjap manis or ketjap boemboe
  • brown sugar or syrup
  • vinegar
  • paprika powder
  • flour
  • salt

The trick with this soup is to get a solid base together, and after that just chuck stuff in to make it more entertaining to eat. Start by opening the canned tomatoes into a pan, and mixing them with a blender, double the volume by adding water. Bring the tomtatoes to a slow simmer. Then add flavour; ketjap, sugar, vinegar, salt, paprika, you can add quite a lot. Also add some flour to thicken the soup, mix well. When you’ve added everything take some time to test the flavour. Add salt/sugar/vinegar/pepper if needed, the soup needs quite a lot of salt/sweet/sour. Leave the mixture for 1-2 hours, to let the flavours develop. Start adding ingredients about 30 minutes before serving. Good choices are:

  • canned bamboo strips (needs 60 minutes to lose the horrible canned flavour)
  • small meatballs
  • omlet strips
  • sliced mushrooms
  • sliced paprika
  • taugé (add last)

Greek Meatballs

Sunday, October 1st, 2006

Ingredients:

  • 300 grams ground beef
  • garlic
  • fresh thime
  • fresh mint
  • 1/2 lemon
  • 1 egg
  • breadcrumbs (beschuit is best)

Chop the thyme and mint leaves, it will take some effort to seperate the thyme leaves from the stems. Mix everything together in a big bowl, starting with the ground beef,  adding the chopped herbs. Crush the garlic using a garlic press. Then add the lemon and the egg. Finaly use the breadcrumbs to counteract the wetness introduced by the lemon.
The meatballs will fall apart if they’re too wet. Create golfball sized meatballs from the mixture and bake until brown. I usually serve them with rice.

Spring Roll

Sunday, October 1st, 2006

Ingredients:

  • spring roll wrappers
  • chicken breast
  • 2 eggs
  • 5 carrots
  • thai wok vegetables
  • taugé
  • fresh ginger
  • sesame seeds
  • chopped peanuts
  • chopped spring onions
  • spring roll sauce (sweet-sour versions work best)

Bake omlets using the eggs and cut them into strips. Cut the chicken into small chunks and bake until brown. Cut the carrots into short small strips, cut the ginger into even smaller chunks. Stir fry the carrots, taugé, wok vegatables and ginger, add the sauce. The preparations are now done. Take two wrappers for each roll and fill them with the vegetables, chicken and omlet strips. Sprinkle the mixture with the sesame seeds, peanuts and spring onions. Deep fry the rolls in hot oil until brown.