Posts tagged ‘802.1D’

Recompiling linux bridge kernel module

A few days ago I had to modify the linux bridge kernel module. The problem was that frames with a MAC destination address of 01-80-C2-00-00-03 didn’t pass through the bridge. According to the IEEE 802.1D standard this is the correct behavior. However I need to process those frames at another bridge, so the modification was necessary.

You can always apply your patch and recompile the whole kernel. However this is quite inefficient, since you can recompile just the affected module. Here is how.

  1. Download your kernel’s source code.
  2. Navigate to the bridge module directory (/usr/src/redhat/SOURCES/linux-2.6.18/net/bridge).
  3. Edit the following Makefile:
  4. #
    # Makefile for the IEEE 802.1d ethernet bridging layer.
    #
     
    KDIR    := /lib/modules/$(shell uname -r)/build
    PWD    := $(shell pwd)
     
    obj-m += bridge.o
     
    bridge-y        := br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o 
                            br_ioctl.o br_notify.o br_stp.o br_stp_bpdu.o 
                            br_stp_if.o br_stp_timer.o br_netlink.o
     
    bridge-y+= br_sysfs_if.o br_sysfs_br.o
     
    bridge-y += br_netfilter.o
     
    obj-m += netfilter/
     
    default:
            $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
  5. Compile the module with make.
  6. # make

As a result you get the bridge.ko module.

To use the newly created module follow these steps:

# rmmod bridge
# cp /lib/modules/2.6.18-128.el5/kernel/net/bridge/bridge.ko /lib/modules/2.6.18-128.el5/kernel/net/bridge/bridge.ko.old
# cp bridge.ko /lib/modules/2.6.18-128.el5/kernel/net/bridge/
# modprobe bridge

And that’s it. Your patched module is up and running.