Linux Advanced Routing and Traffic Control list
 help / color / mirror / Atom feed
* [LARTC] Is negative offset possible in u32 ?
@ 2003-01-14 12:40 Eric Leblond
  2003-01-14 13:22 ` Stephane Ouellette
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Leblond @ 2003-01-14 12:40 UTC (permalink / raw)
  To: lartc

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

Has somebody realyy manage to use the examples given when using negative
offset in u32 ?

I look at the kernel code, I'm almost a real beginner here so I could
wrote stupid things :

I saw that in the file cls_u32.c we work with skb and use only 
skb->nh.raw. That's the network header, so we don't have any information
about Ethernet header (it's in skb->mac.raw that we have the ethernet
header and that the protocol is given).
Furthermore (maybe i'm wrong cause of inverted stockage in memory) in
the skbuf struct the ethernet header union follow the network header
union so we should read something else.
Thus we can at least say that negative offset in u32 are really "tricky"
and really non clean and as seems to show experiment that they don't
work (?)

-- 
Éric Leblond
courriel : eric@regit.org

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LARTC] Is negative offset possible in u32 ?
  2003-01-14 12:40 [LARTC] Is negative offset possible in u32 ? Eric Leblond
@ 2003-01-14 13:22 ` Stephane Ouellette
  2003-01-14 13:28 ` Eric Leblond
  2003-01-14 23:34 ` Julian Anastasov
  2 siblings, 0 replies; 4+ messages in thread
From: Stephane Ouellette @ 2003-01-14 13:22 UTC (permalink / raw)
  To: lartc

Eric Leblond wrote:

>Has somebody realyy manage to use the examples given when using negative
>offset in u32 ?
>
>I look at the kernel code, I'm almost a real beginner here so I could
>wrote stupid things :
>
>I saw that in the file cls_u32.c we work with skb and use only 
>skb->nh.raw. That's the network header, so we don't have any information
>about Ethernet header (it's in skb->mac.raw that we have the ethernet
>header and that the protocol is given).
>Furthermore (maybe i'm wrong cause of inverted stockage in memory) in
>the skbuf struct the ethernet header union follow the network header
>union so we should read something else.
>Thus we can at least say that negative offset in u32 are really "tricky"
>and really non clean and as seems to show experiment that they don't
>work (?)
>
>  
>
Eric,

  the following offsets are from a mail previously posted on this list.
I hope it helps.

Stephane Ouellette.


Decimal Ofs	Description
-----------------------------------
-14:		DST MAC, 6 bytes
-8:		SRC MAC, 6 bytes
-2:		Eth PROTO, 2 bytes, eg. ETH_P_IP
0:		Protocol header (IP Header)





_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LARTC] Is negative offset possible in u32 ?
  2003-01-14 12:40 [LARTC] Is negative offset possible in u32 ? Eric Leblond
  2003-01-14 13:22 ` Stephane Ouellette
@ 2003-01-14 13:28 ` Eric Leblond
  2003-01-14 23:34 ` Julian Anastasov
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Leblond @ 2003-01-14 13:28 UTC (permalink / raw)
  To: lartc


> Eric Leblond wrote:
>
>>Has somebody realyy manage to use the examples given when using negative
>>offset in u32 ?
>
>
> Decimal Ofs	Description
> -----------------------------------
> -14:		DST MAC, 6 bytes
> -8:		SRC MAC, 6 bytes
> -2:		Eth PROTO, 2 bytes, eg. ETH_P_IP
> 0:		Protocol header (IP Header)

Yes I try these one. But I was unable to get them working.
So I look at the kernel code and find that's it is (for me) impossible to
access these fields

BR
-- 
Eric Leblond
courriel : eric@regit.org
Computer are like air conditionners, they don't work when windows are open.

_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LARTC] Is negative offset possible in u32 ?
  2003-01-14 12:40 [LARTC] Is negative offset possible in u32 ? Eric Leblond
  2003-01-14 13:22 ` Stephane Ouellette
  2003-01-14 13:28 ` Eric Leblond
@ 2003-01-14 23:34 ` Julian Anastasov
  2 siblings, 0 replies; 4+ messages in thread
From: Julian Anastasov @ 2003-01-14 23:34 UTC (permalink / raw)
  To: lartc


	Hello,

On 14 Jan 2003, Eric Leblond wrote:

> I look at the kernel code, I'm almost a real beginner here so I could
> wrote stupid things :
>
> I saw that in the file cls_u32.c we work with skb and use only
> skb->nh.raw. That's the network header, so we don't have any information
> about Ethernet header (it's in skb->mac.raw that we have the ethernet
> header and that the protocol is given).

	Everything starts from the net drivers (drivers/net/*.c):

- dev_alloc_skb() is used to reserve skb head space for the eth hdr
and data space for the packet

- NIC stores ethhdr and packet there

- eth_type_trans() is called to set skb->mac.raw and to skip
the eth header by incrementing skb->data with skb_pull()

- net/core/dev.c sets skb->nh.raw = skb->data and packet is
passed to upper layers where tc ingress works

> Furthermore (maybe i'm wrong cause of inverted stockage in memory) in
> the skbuf struct the ethernet header union follow the network header
> union so we should read something else.

tc sees:

skb:
+-------+	head
|	|		before ofs=-14: more reserved bytes
|	|		ofs=-14: dst mac
|	|		ofs=-8: src mac
|ethhdr	|		ofs=-2: eth proto
+-------+	data	ofs=+0, same as nh.raw
|packet	|
|	|
+-------+	tail
|	|
+-------+	end

As for u32_classify, nh.ptr is used as base offset, later the 'ptr'
is adjusted by signed int offsets, so it can touch lower addresses.

> Thus we can at least say that negative offset in u32 are really "tricky"
> and really non clean and as seems to show experiment that they don't
> work (?)

	This is a hack, of course (may be designed so). But
it works for me (tm)

Regards

--
Julian Anastasov <ja@ssi.bg>

_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-14 23:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-14 12:40 [LARTC] Is negative offset possible in u32 ? Eric Leblond
2003-01-14 13:22 ` Stephane Ouellette
2003-01-14 13:28 ` Eric Leblond
2003-01-14 23:34 ` Julian Anastasov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox