@@ -211,11 +211,11 @@ parse_app_args(int argc, char *argv[], const char *progname) {
211
211
* For RFC about ARP, see https://tools.ietf.org/html/rfc826
212
212
* RETURNS 0 if success, -1 otherwise */
213
213
static int
214
- send_arp_reply (int port , struct ether_addr * tha , uint32_t tip , struct onvm_nf * nf ) {
214
+ send_arp_reply (int port , struct rte_ether_addr * tha , uint32_t tip , struct onvm_nf * nf ) {
215
215
struct rte_mbuf * out_pkt = NULL ;
216
216
struct onvm_pkt_meta * pmeta = NULL ;
217
- struct ether_hdr * eth_hdr = NULL ;
218
- struct arp_hdr * out_arp_hdr = NULL ;
217
+ struct rte_ether_hdr * eth_hdr = NULL ;
218
+ struct rte_arp_hdr * out_arp_hdr = NULL ;
219
219
220
220
size_t pkt_size = 0 ;
221
221
@@ -229,30 +229,30 @@ send_arp_reply(int port, struct ether_addr *tha, uint32_t tip, struct onvm_nf *n
229
229
return -1 ;
230
230
}
231
231
232
- pkt_size = sizeof (struct ether_hdr ) + sizeof (struct arp_hdr );
232
+ pkt_size = sizeof (struct rte_ether_hdr ) + sizeof (struct rte_arp_hdr );
233
233
out_pkt -> data_len = pkt_size ;
234
234
out_pkt -> pkt_len = pkt_size ;
235
235
236
236
// SET ETHER HEADER INFO
237
237
eth_hdr = onvm_pkt_ether_hdr (out_pkt );
238
- ether_addr_copy (& ports -> mac [port ], & eth_hdr -> s_addr );
239
- eth_hdr -> ether_type = rte_cpu_to_be_16 (ETHER_TYPE_ARP );
240
- ether_addr_copy (tha , & eth_hdr -> d_addr );
238
+ rte_ether_addr_copy (& ports -> mac [port ], & eth_hdr -> s_addr );
239
+ eth_hdr -> ether_type = rte_cpu_to_be_16 (RTE_ETHER_TYPE_ARP );
240
+ rte_ether_addr_copy (tha , & eth_hdr -> d_addr );
241
241
242
242
// SET ARP HDR INFO
243
- out_arp_hdr = rte_pktmbuf_mtod_offset (out_pkt , struct arp_hdr * , sizeof (struct ether_hdr ));
243
+ out_arp_hdr = rte_pktmbuf_mtod_offset (out_pkt , struct rte_arp_hdr * , sizeof (struct rte_ether_hdr ));
244
244
245
- out_arp_hdr -> arp_hrd = rte_cpu_to_be_16 (ARP_HRD_ETHER );
246
- out_arp_hdr -> arp_pro = rte_cpu_to_be_16 (ETHER_TYPE_IPv4 );
247
- out_arp_hdr -> arp_hln = 6 ;
248
- out_arp_hdr -> arp_pln = sizeof (uint32_t );
249
- out_arp_hdr -> arp_op = rte_cpu_to_be_16 (ARP_OP_REPLY );
245
+ out_arp_hdr -> arp_hardware = rte_cpu_to_be_16 (RTE_ARP_HRD_ETHER );
246
+ out_arp_hdr -> arp_protocol = rte_cpu_to_be_16 (RTE_ETHER_TYPE_IPV4 );
247
+ out_arp_hdr -> arp_hlen = 6 ;
248
+ out_arp_hdr -> arp_plen = sizeof (uint32_t );
249
+ out_arp_hdr -> arp_opcode = rte_cpu_to_be_16 (RTE_ARP_OP_REPLY );
250
250
251
- ether_addr_copy (& ports -> mac [port ], & out_arp_hdr -> arp_data .arp_sha );
251
+ rte_ether_addr_copy (& ports -> mac [port ], & out_arp_hdr -> arp_data .arp_sha );
252
252
out_arp_hdr -> arp_data .arp_sip = state_info -> source_ips [ports -> id [port ]];
253
253
254
254
out_arp_hdr -> arp_data .arp_tip = tip ;
255
- ether_addr_copy (tha , & out_arp_hdr -> arp_data .arp_tha );
255
+ rte_ether_addr_copy (tha , & out_arp_hdr -> arp_data .arp_tha );
256
256
257
257
// SEND PACKET OUT/SET METAINFO
258
258
pmeta = onvm_get_pkt_meta (out_pkt );
@@ -265,8 +265,8 @@ send_arp_reply(int port, struct ether_addr *tha, uint32_t tip, struct onvm_nf *n
265
265
static int
266
266
packet_handler (struct rte_mbuf * pkt , struct onvm_pkt_meta * meta ,
267
267
__attribute__((unused )) struct onvm_nf_local_ctx * nf_local_ctx ) {
268
- struct ether_hdr * eth_hdr = onvm_pkt_ether_hdr (pkt );
269
- struct arp_hdr * in_arp_hdr = NULL ;
268
+ struct rte_ether_hdr * eth_hdr = onvm_pkt_ether_hdr (pkt );
269
+ struct rte_arp_hdr * in_arp_hdr = NULL ;
270
270
int result = -1 ;
271
271
272
272
/*
@@ -276,10 +276,10 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
276
276
* If its an ARP REPLY send to dest
277
277
* Ignore (fwd to dest) other opcodes
278
278
*/
279
- if (rte_cpu_to_be_16 (eth_hdr -> ether_type ) == ETHER_TYPE_ARP ) {
280
- in_arp_hdr = rte_pktmbuf_mtod_offset (pkt , struct arp_hdr * , sizeof (struct ether_hdr ));
281
- switch (rte_cpu_to_be_16 (in_arp_hdr -> arp_op )) {
282
- case ARP_OP_REQUEST :
279
+ if (rte_cpu_to_be_16 (eth_hdr -> ether_type ) == RTE_ETHER_TYPE_ARP ) {
280
+ in_arp_hdr = rte_pktmbuf_mtod_offset (pkt , struct rte_arp_hdr * , sizeof (struct rte_ether_hdr ));
281
+ switch (rte_cpu_to_be_16 (in_arp_hdr -> arp_opcode )) {
282
+ case RTE_ARP_OP_REQUEST :
283
283
if (rte_be_to_cpu_32 (in_arp_hdr -> arp_data .arp_tip ) ==
284
284
state_info -> source_ips [ports -> id [pkt -> port ]]) {
285
285
result = send_arp_reply (pkt -> port , & eth_hdr -> s_addr ,
@@ -292,13 +292,14 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
292
292
return 0 ;
293
293
}
294
294
break ;
295
- case ARP_OP_REPLY :
295
+ case RTE_ARP_OP_REPLY :
296
296
/* Here we can potentially save the information */
297
297
break ;
298
298
default :
299
299
if (state_info -> print_flag ) {
300
300
printf ("ARP with opcode %d, port %d (ID %d) DROPPED\n" ,
301
- rte_cpu_to_be_16 (in_arp_hdr -> arp_op ), pkt -> port , ports -> id [pkt -> port ]);
301
+ rte_cpu_to_be_16 (in_arp_hdr -> arp_opcode ),
302
+ pkt -> port , ports -> id [pkt -> port ]);
302
303
}
303
304
}
304
305
}
0 commit comments