Click here to Skip to main content
13,766,261 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
The VLAN strip code for egress GTP packets results in source IP address ac150569 getting corrupted. After VLAN tag(4 bytes) is removed the source IP in the packet becomes ac150000 which is wrong.

Packet dump before VLAN tag is removed: 0ca402e8 deb15254 00b3fb19 81000873 08004500 002a00fc 00003e11 bf42ac15 05690a5f 00aa0868 08680016 001c3202 000600

Code for VLAN strip:
memcpy( (rte_pktmbuf_mtod(m, unsigned char *)+12),
       ( rte_pktmbuf_mtod(m, unsigned char *)+16), m->pkt.data_len-16);
Packet dump after VLAN tag is removed: 0ca402e8 deb15254 00b3fb19 08004500 002a00fc 00003e11 bf42ac15 00000a5f 00aa0868 08680016 001c3202 1bdb0000 0000004e 00000e00

Can you please let me know how 0000 gets added in place of 0569 for source IP address in the modified packet after vlan tag is removed? What code changes needs to be done?

Thanks,

What I have tried:

memcpy( (rte_pktmbuf_mtod(m, unsigned char *)+12),
        (rte_pktmbuf_mtod(m, unsigned char *)+16), m->pkt.data_len-16 );
m->pkt.data_len -= 4;
m->pkt.pkt_len -= 4;
Posted 14-Sep-18 2:42am
Updated 14-Sep-18 5:51am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I find it helpful to expand the packet display and add offset labels to them:
81 00 08 73  08 00 45 00  00 2a 00 fc  00 00 3e 11  bf 42 ac 15  05 69 0a 5f  00 aa 08 68 
12 13 14 15  16 17 18 19  20 21 22 23  24 25 26 27  28 29 30 31  32 33 34 35  36 37 38 39

08 00 45 00  00 2a 00 fc  00 00 3e 11  bf 42 ac 15  00 00 0a 5f  00 aa 08 68  08 68 00 16
12 13 14 15  16 17 18 19  20 21 22 23  24 25 26 27  28 29 30 31  32 33 34 35  36 37 38 39
I see nothing in the code that would explain why two bytes of zeros are dropped into that sequence of bytes. It looks correct except for those two bytes. I would watch the data in the debugger and make sure that is what it looks like before and after the memcpy call. Look closely at the definition of the data packet structure and note where the data_len and pkt_len members are. It could be that the subtraction operation is clearing those bytes. Also verify what rte_pktmbuf_mtod does. If you just can't sort it out then you could save the address in a temporary variable before the memcpy call for use later.
  Permalink  
v2
Comments
sarali 14-Sep-18 14:06pm
   
Thanks for your inputs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.181114.1 | Last Updated 14 Sep 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100