Skip to contentSkip to conversation

To send a skb cloned in netfilter HOOK out

DISCUSSION Archills Zhao 2 participants 3 messages Feb 25, 2005 – Mar 9, 2005 2 messages not in the archive netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

for example, to register a module in NF_IP_POST_ROUTING, in which skb was cloned and stored in my_skb, If i want this cloned packet to follow the routine to finally be sent out,
where should i inject this "myskb"?how to realise this in network satck?

i have run into netfilter for just one or two week and found it really nice!

Brgds,
Archills

#3 lore raw
In reply to a message not in the archive

Hi,

You can't send a 'cloned' skb, you need to send a copy to each destination,

ie,

new_skb = skb_copy(old, GFP_ATOMIC);

A clone will share the same data with the original but different values in head.

A copy will have a copy of the data and relavant head pointers.

to send the copy out of another interface you need to also tell netfilter that it is not the same packet that went in.

http://www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-6.html

Ian

Quoted 51 lines · Archills Zhao

Hi,
How are things going on with you?
If u copy the skb more than once and send to different destination, just as I am doing here,I guess u have some change to the netfilter itself! I am supposing to do the same thing next stage.

but now I have met a problem here ,and hope i can reach ur help.

Here I cloned the skb for more than once at POSTROUTING chain,chaged the destIP respectively,and then send them using dev_queue_xmit(skb). but it turns out to have the same destination MAC address,
even if i called ether.c:eth_rebuild_header();
the destMAC remains the same.
do u have any suggestion ,how can i change destMAC under my circumstance?

thanks in advance!

Brgds,
Archills

----- Original Message -----
From: Ian Norton
To: Archills Zhao
Sent: Friday, February 25, 2005 5:48 PM
Subject: Re: To send a skb cloned in netfilter HOOK out

Quoted 7 lines · Archills Zhao

Hi,

for example, to register a module in NF_IP_POST_ROUTING, in which skb was cloned and stored in my_skb, If i want this cloned packet to follow the routine to finally be sent out,
where should i inject this "myskb"?how to realise this in network satck?

i have run into netfilter for just one or two week and found it really nice!

Hi there,

I've been looking to do almost exactly the same thing here, You can create a whole new packet (you need to add link layer headers) and send that using dev_queue_xmit(skb).

At the moment I've not been able to send a _new_ skb back to the netfilter hook that called my module.
--
Ian

Signature · 1 line
Ian Norton-Badrul
#4 lore raw

Hi,
I do used skb_copy();
Anyway,Thanks!

Brgds,
Archills

----- Original Message -----
From: Ian Norton
To: Archills Zhao
Cc: [email protected]
Sent: Wednesday, March 09, 2005 5:47 PM
Subject: Re: To send a skb cloned in netfilter HOOK out

Hi,

You can't send a 'cloned' skb, you need to send a copy to each destination,

ie,

  new_skb = skb_copy(old, GFP_ATOMIC);

A clone will share the same data with the original but different values in head.

A copy will have a copy of the data and relavant head pointers.

to send the copy out of another interface you need to also tell netfilter that it is not the same packet that went in.

http://www.netfilter.org/documentation/HOWTO/netfilter-hacking-HOWTO-6.html

Ian