Skip to contentSkip to conversation

tunneled packets

DISCUSSION Nikolaos Fideropoulos 2 participants 2 messages Nov 26, 2002 – Dec 5, 2002 netfilter

lore
Share & tools
lore
#0 lore raw

Hello,

i have 2 questions:

1) i want to monitor tunneled packets, but i'm not sure how they pass the hooks. is following right?:

(incoming packets):
incoming_device->PRE_ROUTING->FORWARD->POST_ROUTING->tun-device(decapsulatio n)->PRE_ROUTING->LOCAL_IN

(outgoing packets):
LOCAL_OUT->POST_ROUTING->tun-device(encapsualtion)->PRE_ROUTING->FORWARD->PO ST_ROUTING->outgoing_device

2) I wanna write a small module which does some checks on packets in NF_IP_LOCAL_IN, NF_IP_LOCAL_OUT and maintains a connection-table. I would like to know if it's ok to do that in 1 Module (and 1 function), or should that be done for any reason in seperate modules?

(example-code)

static int __init init(void)      {
            return nf_register_hook(&first);
            return nf_register_hook(&second);
      }

static struct nf_hook_ops first
= { { NULL, NULL }, example_hook, PF_INET, NF_IP_LOCAL_IN,
NF_IP_PRI_FILTER-1 };
static struct nf_hook_ops second
= { { NULL, NULL }, example_hook, PF_INET, NF_IP_LOCAL_OUT,
NF_IP_PRI_FILTER-1 };

example_hook(unsigned int hook, struct sk_buff **skb,
const struct net_device *indev, const struct net_device *outdev, int (*okfn)(struct sk_buff *))
{
..}

Regards,
Nikos

#1 lore raw
Quoted 9 lines · Nikolaos Fideropoulos

1) i want to monitor tunneled packets, but i'm not sure how they pass the hooks. is following right?:

(incoming packets):
incoming_device->PRE_ROUTING->FORWARD->POST_ROUTING->tun-device(decapsulatio n)->PRE_ROUTING->LOCAL_IN
(outgoing packets):
LOCAL_OUT->POST_ROUTING->tun-device(encapsualtion)->PRE_ROUTING->FORWARD->PO ST_ROUTING->outgoing_device

seems correct to me.

Quoted 4 lines

2) I wanna write a small module which does some checks on packets in NF_IP_LOCAL_IN, NF_IP_LOCAL_OUT and maintains a connection-table. I would like to know if it's ok to do that in 1 Module (and 1 function), or should that be done for any reason in seperate modules?

Mh. A connection table. Don't we already have one in ip_conntrack? Maybe it's a good idea to describe what you really want to achieve, maybe there's a different solution to the problem.

And yes, of course you can attach a single function to multiple hooks, if this anwers your question :)

Quoted 2 lines

Regards,
Nikos

Signature · 5 lines
Live long and prosper
- Harald Welte / [email protected]               http://www.gnumonks.org/
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M- 
V-- PS+ PE-- Y+ PGP++ t++ 5-- !X !R tv-- b+++ DI? !D G+ e* h+ r% y+(*)