netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [iproute2]  tc pedit   modify  ethhdr ?
@ 2010-03-24 12:31 Xiaofei Wu
  2010-03-24 13:50 ` jamal
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaofei Wu @ 2010-03-24 12:31 UTC (permalink / raw)
  To: stephen.hemminger; +Cc: hadi, linux netdev

Hi all,

I want to modify  a packet's   h_dest and h_source in  structethhdr { } .

in   tc / m_pedit.c
------

36 explain(void)
37 {
38         fprintf(stderr, "Usage: ... pedit munge <MUNGE>\n");
39         fprintf(stderr,
40                 "Where: MUNGE := <RAW>|<LAYERED>\n"
41                 "\t<RAW>:= <OFFSETC>[ATC]<CMD>\n "
42                 "\t\tOFFSETC:= offset <offval> <u8|u16|u32>\n "
43                 "\t\tATC:= at <atval> offmask <maskval> shift <shiftval>\n "
44                 "\t\tNOTE: offval is byte offset, must be multiple of 4\n "
45                 "\t\tNOTE: maskval is a 32 bit hex number\n "
46                 "\t\tNOTE: shiftval is a is a shift value\n "
47                 "\t\tCMD:= clear | invert | set <setval>| retain\n "
48                 "\t<LAYERED>:= ip <ipdata> | ip6 <ip6data> \n "
49                 " \t\t| udp <udpdata> | tcp <tcpdata> | icmp <icmpdata> \n"
50                 "For Example usage look at the examples directory\n");
51 
52 }
------

OFFSETC:= offset <offval> <u8|u16|u32>
NOTE: offval is byte offset, must be multiple of 4

but the size of ethhdr is 14 bytes, 14 is not multiple of 4 .
How to use 'tc ... pedit ...'  modify  a packet's   h_dest and h_source 
of ethhdr ?
Use ' ... pedit munge offset -14 u16 set 0x0090 munge offset -12 u32 set 0x9600030a ... '   or 
use ' ... pedit munge offset -16 u32 ... munge offset -12  ... '  ?


--
Wu


      


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

* Re: [iproute2]  tc pedit   modify  ethhdr ?
  2010-03-24 12:31 [iproute2] tc pedit modify ethhdr ? Xiaofei Wu
@ 2010-03-24 13:50 ` jamal
  2010-03-25  2:59   ` Xiaofei Wu
  0 siblings, 1 reply; 4+ messages in thread
From: jamal @ 2010-03-24 13:50 UTC (permalink / raw)
  To: Xiaofei Wu; +Cc: stephen.hemminger, linux netdev

On Wed, 2010-03-24 at 05:31 -0700, Xiaofei Wu wrote:

> but the size of ethhdr is 14 bytes, 14 is not multiple of 4 .
> How to use 'tc ... pedit ...'  modify  a packet's   h_dest and h_source 
> of ethhdr ?
> Use ' ... pedit munge offset -14 u16 set 0x0090 munge offset -12 u32 set 0x9600030a ... '   or 
> use ' ... pedit munge offset -16 u32 ... munge offset -12  ... '  ?
> 

0 is at ip header.
dst MAC starts at -14
src MAC at -8
ethertype at -2

Example:
tc filter add dev eth0 parent ffff: protocol ip prio 10 u32 \
match ip src 192.168.1.10/32 flowid 1:2 \
action pedit munge offset -14 u16 set 0x0000 \
munge offset -12 u32 set 0x00010100 \
munge offset -8 u32 set 0x0aaf0100 \
munge offset -4 u32 set 0x0008ec06 pipe \
action mirred egress redirect dev eth1

cheers,
jamal



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

* Re: [iproute2]  tc pedit   modify  ethhdr ?
  2010-03-24 13:50 ` jamal
@ 2010-03-25  2:59   ` Xiaofei Wu
  2010-03-25  3:21     ` jamal
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaofei Wu @ 2010-03-25  2:59 UTC (permalink / raw)
  To: hadi; +Cc: linux netdev

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




I made a test like your example.
The terminal prints:
parse_cmd argc 20 set offset -14 length 2
pack_key16: Final val 90000000 mask 0000ffff
parse_cmd done argc 18 munge offset -16 length 2

what's the meaning of the above 3 lines;  It modify the value of  -16,-15,-14,-13 ,  or just modify -14,-13 ?
If it modified -16,-15 ,   would it cause any problems?

Thanks.


--
Wu



----- Original Message ----
> but the size of ethhdr is 14 bytes, 14 is not multiple of 4 .
> How to use 'tc ... pedit ...'  modify  a packet's   h_dest and h_source 
> of ethhdr ?
> Use ' ... pedit munge offset -14 u16 set 0x0090 munge offset -12 u32 set 0x9600030a ... '   or 
> use ' ... pedit munge offset -16 u32 ... munge offset -12  ... '  ?
> 

0 is at ip header.
dst MAC starts at -14
src MAC at -8
ethertype at -2

Example:
tc filter add dev eth0 parent ffff: protocol ip prio 10 u32 \
match ip src 192.168.1.10/32 flowid 1:2 \
action pedit munge offset -14 u16 set 0x0000 \
munge offset -12 u32 set 0x00010100 \
munge offset -8 u32 set 0x0aaf0100 \
munge offset -4 u32 set 0x0008ec06 pipe \
action mirred egress redirect dev eth1


      

[-- Attachment #2: test.png --]
[-- Type: application/octet-stream, Size: 61263 bytes --]

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

* Re: [iproute2]  tc pedit   modify  ethhdr ?
  2010-03-25  2:59   ` Xiaofei Wu
@ 2010-03-25  3:21     ` jamal
  0 siblings, 0 replies; 4+ messages in thread
From: jamal @ 2010-03-25  3:21 UTC (permalink / raw)
  To: Xiaofei Wu; +Cc: linux netdev


I put some effort in responding to you. Please put some
effort in testing it.

cheers,
jamal

On Wed, 2010-03-24 at 19:59 -0700, Xiaofei Wu wrote:
> 
> 
> I made a test like your example.
> The terminal prints:
> parse_cmd argc 20 set offset -14 length 2
> pack_key16: Final val 90000000 mask 0000ffff
> parse_cmd done argc 18 munge offset -16 length 2
> 
> what's the meaning of the above 3 lines;  It modify the value of  -16,-15,-14,-13 ,  or just modify -14,-13 ?
> If it modified -16,-15 ,   would it cause any problems?
> 
> Thanks.
> 
> 
> --
> Wu
> 
> 
> 
> ----- Original Message ----
> > but the size of ethhdr is 14 bytes, 14 is not multiple of 4 .
> > How to use 'tc ... pedit ...'  modify  a packet's   h_dest and h_source 
> > of ethhdr ?
> > Use ' ... pedit munge offset -14 u16 set 0x0090 munge offset -12 u32 set 0x9600030a ... '   or 
> > use ' ... pedit munge offset -16 u32 ... munge offset -12  ... '  ?
> > 
> 
> 0 is at ip header.
> dst MAC starts at -14
> src MAC at -8
> ethertype at -2
> 
> Example:
> tc filter add dev eth0 parent ffff: protocol ip prio 10 u32 \
> match ip src 192.168.1.10/32 flowid 1:2 \
> action pedit munge offset -14 u16 set 0x0000 \
> munge offset -12 u32 set 0x00010100 \
> munge offset -8 u32 set 0x0aaf0100 \
> munge offset -4 u32 set 0x0008ec06 pipe \
> action mirred egress redirect dev eth1
> 
> 
>       


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

end of thread, other threads:[~2010-03-25  3:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-24 12:31 [iproute2] tc pedit modify ethhdr ? Xiaofei Wu
2010-03-24 13:50 ` jamal
2010-03-25  2:59   ` Xiaofei Wu
2010-03-25  3:21     ` jamal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).