Network device alias for ethernet bonding

Ethernet bonding is sweet to have when you want failover and/or increase throughput. In Linux, there are a few different setups that you can choose from to suit your requirements. But the switch or router must support link aggregation!

Using ifenslave, you can bond two ethernets together. When two network devices are bonded, both of them will take on the master’s MAC address (or you can predefine it in /etc/network/interfaces). Now, this is not interesting when your server reboots for some reason. The secondary NIC will not be able to be bonded again because it won’t be called eth1 when rebooted but rather aliased with a different name due to how the udev rules are generated.

In Debian Lenny, /etc/udev/rules.d/75-persistent-net-generator.rules will generate the necessary ruleset, depending on your network hardware configuration, to /etc/udev/rules.d/70-persistent-net.rules. By default, the following exists in 70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:19:db:f7:00:b7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:19:db:f6:7a:d5", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

75-persistent-net-generator.rules will generate the above rule to add a network device based on its MAC address. This is definitely not interesting for us.

We can start writing udev rules after finding out the info we need using udevinfo -a -p /sys/class/net/[device name]. Instead of using MAC address to determine our NIC alias, we’ll use the driver, vendor and device id to be 100% sure. With those info, we can create the following udev rules…

SUBSYSTEM=="pci", ACTION=="add", DRIVERS=="r8169", ATTR{vendor}=="0x10ec", ATTR{device}="0x8168", NAME=="eth0"
SUBSYSTEM=="pci", ACTION=="add", DRIVERS=="r8169", ATTR{vendor}=="0x10ec", ATTR{device}="0x8167", NAME=="eth1"

We can be pretty certain that both these NICs will be bonded regardless of the MAC changes.

Am sure we can also change the way 75-persistent-net-generator.rules generates the ruleset. But it’s pretty pointless to do it when you already know which devices you have.

This method would be a good direct solution. :)

Foswiki security release 1.0.5

Foswiki has just released 1.0.5. It has very important security fixes.

If you’re still using TWiki, best to migrate to Foswiki ASAP since all core developers have moved, and the unfix security exploits is not interesting in TWiki. :/

Autocomplete parent topic in NatEdit

What I really miss in Foswiki 1.0.4 with NatSkin was the ability to view all the existing topics within the web and choose which topic is my parent topic. Currently, NatEdit wants you to know the exact name of the parent topic – not quite interesting.

So, I’ve made a simple tweak that allows me to search all the existing topics in the web as I type. Result? I’m able to search for a parent topic by its name. Not exactly perfect, but it fits well so far.

There are 3 parts to achieve this.

1. Create SEARCH term to list all the topics in the web

%SEARCH{ ".*" type="regex" web="%WEB%" scope="topic" nonoise="on" nototal="on" multiple="off" separator=", " format="'$topic'" }%

2. Integrate the above with JQueryPlugin
We’ll be using jquery.autocomplete for the completion of the input field.

<script>
  $(function(){
    $("#topicparent").autocomplete(
      [ %SEARCH{ ".*" type="regex" web="%WEB%" scope="topic" nonoise="on" nototal="on" multiple="off" separator=", " format="'$topic'" }% ]
    );
  });
</script>

3. Modify edit.natedit.tmpl
We need to modify /<path_to_foswiki>/templates/edit.natedit.tmpl to include all the above. So it should look like this…

  <div class="twikiFormStep foswikiFormStep twikiFormLast">
    <h3>%MAKETEXT{"Parent topic"}%:</h3>
%JQSCRIPT{"jquery.autocomplete"}%
%JQSTYLE{"jquery.autocomplete"}%
<script>
    $(function(){
        $("#topicparent").autocomplete(
            [ %SEARCH{ ".*" type="regex" web="%WEB%" scope="topic" nonoise="on" nototal="on" multiple="off" separator=", " format="'$topic'" }% ]
        );
    });
</script>
    <input class="twikiInputField" id="topicparent" type="text" name="topicparent" size="40" value="%TOPICPARENT%" />
  </div>