Skip to content

Commit 8f0e9d1

Browse files
authored
Merge pull request #137 from polycube-network/pr/fix_nat_session_table
pcn-nat: fix natting-tables show
2 parents 0aeaa45 + 9a75f00 commit 8f0e9d1

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/services/pcn-nat/src/Nat_dp_common.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
(sizeof(struct eth_hdr) + sizeof(struct iphdr) + \
4141
offsetof(struct icmphdr, checksum))
4242
#define IS_PSEUDO 0x10
43+
44+
/* __attribute__((packed))
45+
* forces alignment for this structure;
46+
* otherwise misaligned read/write could happen
47+
* between userspace and kernel space.
48+
* same attribute should be used in kernel/user space
49+
* structs declaration.
50+
*/
4351
struct eth_hdr {
4452
__be64 dst : 48;
4553
__be64 src : 48;
@@ -52,9 +60,9 @@ struct st_k {
5260
uint16_t src_port;
5361
uint16_t dst_port;
5462
uint8_t proto;
55-
};
63+
} __attribute__((packed));
5664
struct st_v {
5765
uint32_t new_ip;
5866
uint16_t new_port;
5967
uint8_t originating_rule_type;
60-
};
68+
} __attribute__((packed));

src/services/pcn-nat/src/NattingTable.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ class Nat;
2525
using namespace io::swagger::server::model;
2626

2727
/* definitions copied from datapath */
28+
29+
/* __attribute__((packed))
30+
* forces alignment for this structure;
31+
* otherwise misaligned read/write could happen
32+
* between userspace and kernel space.
33+
* same attribute should be used in kernel/user space
34+
* structs declaration.
35+
*/
2836
struct st_k {
2937
uint32_t src_ip;
3038
uint32_t dst_ip;

0 commit comments

Comments
 (0)