Implementing and adding a custom filter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I need to test the behavior of a kernel module when it is probed for
data while some of its expected packets have arrived and some have
not. Normally, this module expects to be polled when all packets are
sure to have arrived. The network is a deterministic one (called
EtherCAT). The solution that came to me was to put a bridge in between
the network and introduce a delay between the packets being forwarded.
This way, I can deterministically poll the kernel module in question
when some of its packets have arrived while the rest not.

If you are interested in knowing more, you can read these two
questions that I asked elsewhere:

http://serverfault.com/questions/360466/how-to-write-a-netfilter-kernel-module-and-use-it
http://stackoverflow.com/questions/9313088/how-to-write-custom-module-for-ebtables

Unfortunately, I could not find an answer to my problem anywhere, nor
could anyone answer them.

What I am trying to do is basically this:

- Put a bridge in the middle of the network (successfully done using blctr)
- Write a kernel module, checking all the packets that pass through the bridge.
  * In this phase, stall inside one of the functions to make sure
there is a certain delay between packets being forward.
- Make ebtables use my filter

I took a code from linux-source/net/bridge/netfilter/ebt_ip.c, made
the match and check functions simply return true (so they match all
the packets) and use xt_register_match in init_module as was done in
ebt_ip.c

This is the registration data I am using:

static struct xt_match reg __read_mostly = {
    .name        = "any",  // I tried "ip" also, but that didn't change anything
    .revision     = 0,
    .family       = NFPROTO_BRIDGE,
    .match       = match,
    .checkentry = check,
    .matchsize  = XT_ALIGN(4),  // I have no idea what this is! I just
gave it 4 as if its an int
    .me            = THIS_MODULE
};

By the way, I'm talking about Linux 2.6.32

Now I put some log inside match and check functions to make sure they
are called, but they are not. I have no clue how to make it work and I
can't find anything useful on the net.

My question is, how can I make ebtables call my match and check
functions before forwarding the messages? That is, how can I put my
filter in effect?

Thank you,
Shahbaz
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux