Skip to content

Commit bc5c1b7

Browse files
committed
Use official __rte_packed_begin and __rte_packed_end
1 parent 977a30e commit bc5c1b7

File tree

10 files changed

+71
-71
lines changed

10 files changed

+71
-71
lines changed

include/dp_flow.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extern "C" {
5353

5454
#define DP_FLOW_HAS_FLAG_NF(flag) ((flag) & DP_FLOW_FLAG_NF)
5555

56-
enum dp_flow_nat_type {
56+
enum __rte_packed_begin dp_flow_nat_type {
5757
DP_FLOW_NAT_TYPE_NONE,
5858
DP_FLOW_NAT_TYPE_VIP,
5959
DP_FLOW_NAT_TYPE_NETWORK_LOCAL,
@@ -62,7 +62,7 @@ enum dp_flow_nat_type {
6262
DP_FLOW_LB_TYPE_LOCAL_NEIGH_TRAFFIC,
6363
DP_FLOW_LB_TYPE_RECIRC,
6464
DP_FLOW_LB_TYPE_FORWARD,
65-
} __attribute__((__packed__));
65+
} __rte_packed_end;
6666

6767
enum dp_flow_tcp_state {
6868
DP_FLOW_TCP_STATE_NONE,
@@ -73,7 +73,7 @@ enum dp_flow_tcp_state {
7373
DP_FLOW_TCP_STATE_RST_FIN,
7474
};
7575

76-
struct flow_key {
76+
struct __rte_packed_begin flow_key {
7777
struct dp_ip_address l3_dst;
7878
uint8_t proto;
7979
uint16_t port_dst;
@@ -84,7 +84,7 @@ struct flow_key {
8484
uint16_t type_src; /* ICMP */
8585
} src;
8686
uint32_t vni;
87-
} __attribute__((__packed__));
87+
} __rte_packed_end;
8888
static_assert(sizeof(((struct flow_key *)0)->vnf_type) == 1,
8989
"enum dp_vnf_type is unnecessarily big");
9090

include/dp_ipaddr.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ union dp_ipv6 {
3131
rte_be64_t _suffix;
3232
};
3333
const uint8_t bytes[DP_IPV6_ADDR_SIZE];
34-
struct __attribute__((__packed__)) {
34+
struct __rte_packed_begin {
3535
uint8_t prefix[DP_IPV6_ADDR_SIZE - sizeof(rte_be32_t)];
3636
rte_be32_t ipv4;
37-
} _nat64;
38-
struct __attribute__((__packed__)) {
37+
} __rte_packed_end _nat64;
38+
struct __rte_packed_begin {
3939
rte_be64_t prefix;
4040
uint8_t type;
4141
uint8_t subtype;
4242
uint8_t flags;
4343
uint8_t random;
4444
rte_be32_t local;
45-
} _ul;
45+
} __rte_packed_end _ul;
4646
const struct rte_ipv6_addr addr;
4747
};
4848
static_assert(sizeof(union dp_ipv6) == DP_IPV6_ADDR_SIZE, "union dp_ipv6 has padding");
@@ -176,7 +176,7 @@ void dp_generate_virtsvc_ul_ipv6(union dp_ipv6 *dest, uint32_t index);
176176

177177
// structure for holding dual IP addresses
178178
// made read-only without the right macro to prevent uninitialized bytes due to the the use of this structure in hash keys
179-
struct dp_ip_address {
179+
struct __rte_packed_begin dp_ip_address {
180180
union {
181181
union dp_ipv6 _ipv6;
182182
uint32_t _ipv4;
@@ -187,7 +187,7 @@ struct dp_ip_address {
187187
bool _is_v6;
188188
const bool is_v6;
189189
};
190-
} __attribute__((__packed__));
190+
} __rte_packed_end;
191191

192192
static __rte_always_inline
193193
int dp_ipv6_from_ipaddr(union dp_ipv6 *ipv6, const struct dp_ip_address *addr)

include/dp_lb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ extern "C" {
1818
/* Needs to be a prime number at least 2xDP_LB_MAX_IPS_PER_VIP for a uniform distribution */
1919
#define DP_LB_MAGLEV_LOOKUP_SIZE 503
2020

21-
struct lb_key {
21+
struct __rte_packed_begin lb_key {
2222
uint32_t vni;
2323
struct dp_ip_address ip;
24-
} __attribute__((__packed__));
24+
} __rte_packed_end;
2525

2626
struct lb_port {
2727
uint8_t protocol;

include/dp_mbuf_dyn.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,32 @@
2121
extern "C" {
2222
#endif
2323

24-
enum dp_flow_type {
24+
enum __rte_packed_begin dp_flow_type {
2525
DP_FLOW_WEST_EAST,
2626
DP_FLOW_SOUTH_NORTH,
27-
} __attribute__((__packed__));
27+
} __rte_packed_end;
2828

29-
enum dp_pkt_offload_state {
29+
enum __rte_packed_begin dp_pkt_offload_state {
3030
DP_FLOW_NON_OFFLOAD,
3131
DP_FLOW_OFFLOAD_INSTALL,
3232
DP_FLOW_OFFLOADED,
33-
} __attribute__((__packed__));
33+
} __rte_packed_end;
3434

35-
enum dp_flow_dir {
35+
enum __rte_packed_begin dp_flow_dir {
3636
DP_FLOW_DIR_ORG,
3737
DP_FLOW_DIR_REPLY,
38-
} __attribute__((__packed__));
38+
} __rte_packed_end;
3939
#define DP_FLOW_DIR_CAPACITY 2
4040

41-
enum dp_nat_type {
41+
enum __rte_packed_begin dp_nat_type {
4242
DP_NAT_CHG_NONE,
4343
DP_NAT_CHG_SRC_IP,
4444
DP_NAT_CHG_DST_IP,
4545
DP_CHG_UL_DST_IP,
4646
DP_LB_RECIRC,
4747
DP_NAT_64_CHG_SRC_IP,
4848
DP_NAT_64_CHG_DST_IP,
49-
} __attribute__((__packed__));
49+
} __rte_packed_end;
5050

5151
struct dp_flow {
5252
enum dp_flow_type flow_type : 1;

include/dp_nat.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ extern "C" {
2323

2424
#define DP_NETWORK_NAT_ALL_VNI 0
2525

26-
struct nat_key {
26+
struct __rte_packed_begin nat_key {
2727
uint32_t ip;
2828
uint32_t vni;
29-
} __attribute__((__packed__));
29+
} __rte_packed_end;
3030

3131
struct nat_entry {
3232
uint32_t nat_ip;
@@ -50,25 +50,25 @@ struct dnat_data {
5050
uint32_t dnat_ip;
5151
};
5252

53-
struct netnat_portmap_key {
53+
struct __rte_packed_begin netnat_portmap_key {
5454
uint32_t vni;
5555
struct dp_ip_address src_ip;
5656
uint16_t iface_src_port;
57-
} __attribute__((__packed__));
57+
} __rte_packed_end;
5858

5959
struct netnat_portmap_data {
6060
uint32_t nat_ip;
6161
uint16_t nat_port;
6262
uint16_t flow_cnt;
6363
};
6464

65-
struct netnat_portoverload_tbl_key {
65+
struct __rte_packed_begin netnat_portoverload_tbl_key {
6666
uint32_t nat_ip;
6767
uint16_t nat_port;
6868
uint32_t dst_ip;
6969
uint16_t dst_port;
7070
uint8_t l4_type;
71-
} __attribute__((__packed__));
71+
} __rte_packed_end;
7272

7373
struct netnat_portoverload_sync_metadata {
7474
struct netnat_portmap_key portmap_key;

include/dp_sync.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,36 @@
1212
// NOTE: there will be no endianness protection; both ends should be running on the same machine
1313

1414
// no versioning, if really needed, just create another message type
15-
struct __attribute__((__packed__)) dp_sync_hdr {
15+
struct __rte_packed_begin dp_sync_hdr {
1616
uint8_t msg_type;
17-
};
17+
} __rte_packed_end;
1818

1919
// active -> backup: incremental change to NAT tables
2020
#define DP_SYNC_MSG_NAT_CREATE 1
21-
struct __attribute__((__packed__)) dp_sync_msg_nat_create {
21+
struct __rte_packed_begin dp_sync_msg_nat_create {
2222
struct netnat_portmap_key portmap_key;
2323
struct netnat_portoverload_tbl_key portoverload_key;
2424
uint16_t created_port_id;
2525
uint16_t icmp_type_src;
2626
rte_be16_t icmp_err_ip_cksum;
27-
};
27+
} __rte_packed_end;
2828

2929
#define DP_SYNC_MSG_NAT_DELETE 2
30-
struct __attribute__((__packed__)) dp_sync_msg_nat_delete {
30+
struct __rte_packed_begin dp_sync_msg_nat_delete {
3131
struct netnat_portmap_key portmap_key;
3232
struct netnat_portoverload_tbl_key portoverload_key;
33-
};
33+
} __rte_packed_end;
3434

3535
#define DP_SYNC_MSG_VIRTSVC_CONN 3
36-
struct __attribute__((__packed__)) dp_sync_msg_virtsvc_conn {
36+
struct __rte_packed_begin dp_sync_msg_virtsvc_conn {
3737
rte_be32_t virtual_addr;
3838
rte_be16_t virtual_port;
3939
uint16_t conn_port;
4040
rte_be32_t vf_ip;
4141
rte_be16_t vf_l4_port;
4242
uint16_t vf_port_id;
4343
uint8_t proto;
44-
};
44+
} __rte_packed_end;
4545

4646
#define DP_SYNC_MSG_PORT_MAC 4
4747
struct dp_sync_msg_port_mac {

include/dp_vnf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ extern "C" {
2121
// forward declaration as 'struct dp_grpc_responder' needs some definitions from here
2222
struct dp_grpc_responder;
2323

24-
enum dp_vnf_type {
24+
enum __rte_packed_begin dp_vnf_type {
2525
DP_VNF_TYPE_UNDEFINED,
2626
DP_VNF_TYPE_INTERFACE_IP,
2727
DP_VNF_TYPE_VIP,
2828
DP_VNF_TYPE_NAT,
2929
DP_VNF_TYPE_LB,
3030
DP_VNF_TYPE_LB_ALIAS_PFX,
3131
DP_VNF_TYPE_ALIAS_PFX,
32-
} __attribute__((__packed__)); // for 'struct dp_flow' and 'struct flow_key'
32+
} __rte_packed_end; // for 'struct dp_flow' and 'struct flow_key'
3333

3434
struct dp_vnf_prefix {
3535
struct dp_ip_address ol;

include/dp_vni.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ extern struct rte_hash *vni_handle_tbl;
2828
// Also, when NUMA is not available, DPDK uses SOCKET_ID_ANY (-1)
2929
#define DP_SOCKETID(SOCKETID) (unlikely((unsigned int)(SOCKETID) >= DP_NB_SOCKETS) ? 0 : (SOCKETID))
3030

31-
struct dp_vni_key {
31+
struct __rte_packed_begin dp_vni_key {
3232
uint32_t vni;
33-
} __attribute__((__packed__));
33+
} __rte_packed_end;
3434

3535
struct dp_vni_data {
3636
struct rte_rib *ipv4[DP_NB_SOCKETS];

include/protocols/dp_dhcpv6.h

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,77 +63,77 @@
6363
#define DHCPV6_OPT_BOOT_FILE 59
6464

6565
// General definitions as per RFC
66-
struct dhcpv6_packet {
66+
struct __rte_packed_begin dhcpv6_packet {
6767
uint8_t msg_type;
6868
uint8_t transaction_id[3];
6969
uint8_t options[];
70-
} __attribute__((__packed__));
70+
} __rte_packed_end;
7171

72-
struct dhcpv6_option {
72+
struct __rte_packed_begin dhcpv6_option {
7373
rte_be16_t op_code;
7474
rte_be16_t op_len;
7575
uint8_t data[];
76-
} __attribute__((__packed__));
76+
} __rte_packed_end;
7777

78-
struct dhcpv6_opt_dns_servers {
78+
struct __rte_packed_begin dhcpv6_opt_dns_servers {
7979
uint16_t opt_code;
8080
uint16_t opt_len;
8181
struct in6_addr dns_server_addrs[]; // Array of IPv6 addresses
82-
} __attribute__((__packed__));
82+
} __rte_packed_end;
8383

8484
// client id can be of any type, this is the maximum size allowed
85-
struct dhcpv6_opt_client_id {
85+
struct __rte_packed_begin dhcpv6_opt_client_id {
8686
rte_be16_t op_code;
8787
rte_be16_t op_len;
8888
uint8_t id[128];
89-
} __attribute__((__packed__));
89+
} __rte_packed_end;
9090

91-
struct dhcpv6_ia_na {
91+
struct __rte_packed_begin dhcpv6_ia_na {
9292
rte_be32_t iaid;
9393
rte_be32_t t1;
9494
rte_be32_t t2;
9595
struct dhcpv6_option options[];
96-
} __attribute__((__packed__));
96+
} __rte_packed_end;
9797

9898
struct dhcpv6_opt_ia_na {
9999
rte_be16_t op_code;
100100
rte_be16_t op_len;
101101
struct dhcpv6_ia_na ia_na;
102-
} __attribute__((__packed__));
102+
} __rte_packed_end;
103103

104-
struct dhcpv6_opt_vnd_cls {
104+
struct __rte_packed_begin dhcpv6_opt_vnd_cls {
105105
rte_be16_t op_code;
106106
rte_be16_t op_len;
107107
rte_be32_t entp_id;
108108
rte_be16_t opq_data_len;
109109
uint8_t opq_data[];
110-
} __attribute__((__packed__));
110+
} __rte_packed_end;
111111

112-
struct dhcpv6_opt_usr_cls {
112+
struct __rte_packed_begin dhcpv6_opt_usr_cls {
113113
rte_be16_t op_code;
114114
rte_be16_t op_len;
115115
rte_be16_t sub_opt_len;
116116
uint8_t sub_opt_data[];
117-
} __attribute__((__packed__));
117+
} __rte_packed_end;
118118

119-
struct dhcpv6_ia_addr {
119+
struct __rte_packed_begin dhcpv6_ia_addr {
120120
uint8_t ipv6[16];
121121
rte_be32_t preferred_lifetime;
122122
rte_be32_t valid_lifetime;
123123
struct dhcpv6_option options[];
124-
} __attribute__((__packed__));
124+
} __rte_packed_end;
125125

126-
struct dhcpv6_opt_ia_addr {
126+
struct __rte_packed_begin dhcpv6_opt_ia_addr {
127127
rte_be16_t op_code;
128128
rte_be16_t op_len;
129129
struct dhcpv6_ia_addr addr;
130-
} __attribute__((__packed__));
130+
} __rte_packed_end;
131131

132-
struct dhcpv6_opt_status_code {
132+
struct __rte_packed_begin dhcpv6_opt_status_code {
133133
rte_be16_t op_code;
134134
rte_be16_t op_len;
135135
rte_be16_t status;
136-
} __attribute__((__packed__));
136+
} __rte_packed_end;
137137

138138
struct dhcpv6_duid_ll {
139139
rte_be16_t type;
@@ -149,36 +149,36 @@ struct dhcpv6_opt_server_id_ll {
149149
struct dhcpv6_duid_ll id;
150150
};
151151

152-
struct dhcpv6_ia_addr_status {
152+
struct __rte_packed_begin dhcpv6_ia_addr_status {
153153
uint8_t ipv6[16];
154154
rte_be32_t preferred_lifetime;
155155
rte_be32_t valid_lifetime;
156156
struct dhcpv6_opt_status_code options[1];
157-
} __attribute__((__packed__));
157+
} __rte_packed_end;
158158

159-
struct dhcpv6_opt_ia_addr_status {
159+
struct __rte_packed_begin dhcpv6_opt_ia_addr_status {
160160
rte_be16_t op_code;
161161
rte_be16_t op_len;
162162
struct dhcpv6_ia_addr_status addr;
163-
} __attribute__((__packed__));
163+
} __rte_packed_end;
164164

165-
struct dhcpv6_ia_na_single_addr_status {
165+
struct __rte_packed_begin dhcpv6_ia_na_single_addr_status {
166166
rte_be32_t iaid;
167167
rte_be32_t t1;
168168
rte_be32_t t2;
169169
struct dhcpv6_opt_ia_addr_status options[1];
170-
} __attribute__((__packed__));
170+
} __rte_packed_end;
171171

172-
struct dhcpv6_opt_ia_na_single_addr_status {
172+
struct __rte_packed_begin dhcpv6_opt_ia_na_single_addr_status {
173173
rte_be16_t op_code;
174174
rte_be16_t op_len;
175175
struct dhcpv6_ia_na_single_addr_status ia_na;
176-
} __attribute__((__packed__));
176+
} __rte_packed_end;
177177

178-
struct dhcpv6_opt_boot_file_url {
178+
struct __rte_packed_begin dhcpv6_opt_boot_file_url {
179179
rte_be16_t op_code;
180180
rte_be16_t op_len;
181181
char boot_file_url[DHCPV6_BOOT_FILE_BUF_LEN];
182-
} __attribute__((__packed__));
182+
} __rte_packed_end;
183183

184184
#endif

0 commit comments

Comments
 (0)