Skip to content

Commit

Permalink
[Update] DPDK 20.05, Pktgen 20.03 updates for Ubuntu 20.04
Browse files Browse the repository at this point in the history
This PR updates DPDK and Pktgen to new versions. This update also ensures compatibility with Ubuntu 20.04.

Commit log:

* dpdk: Update ONVM to use DPDK v20.05

* onvm: Update onvm to use updated DPDK APIs

* Update the onvm manager, nflib and examples to use the
updated DPDK APIs.

* Update install.sh to enable the igb_uio module build
  (CONFIG_RTE_EAL_IGB_UIO is disabled by default since v20.02)

* switch strncpy to memcpy

strncpy raises (precautionary) werrors during onvm compilation with ubuntu 20 compiler (gcc 9); gnu/gcc recommends use of memcpy to avoid warning

* update pktgen-dpdk submodule to v20.03

* pktgen submodule updates

* pktgen submodule to 807b4d

* modify pktgen config args

lua pktgen.set_mac() now takes three args: port, src|dst, mac addr

* remove pktgen blacklist

blacklists outdated as of pktgen v2.7.0

* c linter fixes

* shell linter fixes
  • Loading branch information
sreyanalla authored Aug 2, 2020
1 parent 324fef6 commit 1c6e171
Show file tree
Hide file tree
Showing 37 changed files with 245 additions and 235 deletions.
3 changes: 2 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
path = tools/Pktgen/pktgen-dpdk
url = http://dpdk.org/git/apps/pktgen-dpdk
branch = master
commit = 4199555481cd08fe08e32986c94e59836ca1cd4f
commit = 807b4d2cfcc8ded46ece85353cefe5d655674de3

2 changes: 1 addition & 1 deletion dpdk
Submodule dpdk updated from 0da7f4 to e2a234
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/NFD/heavy_hitter_detection/HHD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/NFD/napt/NAPT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/NFD/stateful_firewall/stateful_firewall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/NFD/stateless_firewall/stateless_firewall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/NFD/super_spreader_detection/SSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/NFD/syn_flood_detection/SYNFloodDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/NFD/udp_flood_mitigation/UDPFloodMitagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
12 changes: 6 additions & 6 deletions examples/aes_decrypt/aesdecrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand All @@ -154,14 +154,14 @@ do_stats_display(struct rte_mbuf *pkt) {

ip = onvm_pkt_ipv4_hdr(pkt);
if (ip != NULL) {
struct udp_hdr *udp;
struct rte_udp_hdr *udp;

onvm_pkt_print(pkt);
/* Check if we have a valid UDP packet */
udp = onvm_pkt_udp_hdr(pkt);
if (udp != NULL) {
uint8_t *pkt_data;
pkt_data = ((uint8_t *)udp) + sizeof(struct udp_hdr);
pkt_data = ((uint8_t *)udp) + sizeof(struct rte_udp_hdr);
printf("Payload : %.32s\n", pkt_data);
}
} else {
Expand All @@ -172,7 +172,7 @@ do_stats_display(struct rte_mbuf *pkt) {
static int
packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) {
struct udp_hdr *udp;
struct rte_udp_hdr *udp;
static uint32_t counter = 0;

/* Check if we have a valid UDP packet */
Expand All @@ -184,7 +184,7 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
uint16_t hlen;

/* Get at the payload */
pkt_data = ((uint8_t *)udp) + sizeof(struct udp_hdr);
pkt_data = ((uint8_t *)udp) + sizeof(struct rte_udp_hdr);
/* Calculate length */
eth = rte_pktmbuf_mtod(pkt, uint8_t *);
hlen = pkt_data - eth;
Expand All @@ -196,7 +196,7 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
aes_decrypt_ctr(pkt_data, plen, pkt_data, key_schedule, 256, iv[0]);
if (counter == 0) {
printf("Decrypted %d bytes at offset %d (%ld)\n", plen, hlen,
sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct udp_hdr));
sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_udp_hdr));
}
}

Expand Down
12 changes: 6 additions & 6 deletions examples/aes_encrypt/aesencrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand All @@ -154,14 +154,14 @@ do_stats_display(struct rte_mbuf *pkt) {

ip = onvm_pkt_ipv4_hdr(pkt);
if (ip != NULL) {
struct udp_hdr *udp;
struct rte_udp_hdr *udp;

onvm_pkt_print(pkt);
/* Check if we have a valid UDP packet */
udp = onvm_pkt_udp_hdr(pkt);
if (udp != NULL) {
uint8_t *pkt_data;
pkt_data = ((uint8_t *)udp) + sizeof(struct udp_hdr);
pkt_data = ((uint8_t *)udp) + sizeof(struct rte_udp_hdr);
printf("Payload : %.32s\n", pkt_data);
}
} else {
Expand All @@ -172,7 +172,7 @@ do_stats_display(struct rte_mbuf *pkt) {
static int
packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) {
struct udp_hdr *udp;
struct rte_udp_hdr *udp;

static uint32_t counter = 0;
if (++counter == print_delay) {
Expand All @@ -189,7 +189,7 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
uint16_t hlen;

/* Get at the payload */
pkt_data = ((uint8_t *)udp) + sizeof(struct udp_hdr);
pkt_data = ((uint8_t *)udp) + sizeof(struct rte_udp_hdr);
/* Calculate length */
eth = rte_pktmbuf_mtod(pkt, uint8_t *);
hlen = pkt_data - eth;
Expand All @@ -201,7 +201,7 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
aes_encrypt_ctr(pkt_data, plen, pkt_data, key_schedule, 256, iv[0]);
if (counter == 0) {
printf("Encrypted %d bytes at offset %d (%ld)\n", plen, hlen,
sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct udp_hdr));
sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_udp_hdr));
}
}

Expand Down
47 changes: 24 additions & 23 deletions examples/arp_response/arp_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ parse_app_args(int argc, char *argv[], const char *progname) {
* For RFC about ARP, see https://tools.ietf.org/html/rfc826
* RETURNS 0 if success, -1 otherwise */
static int
send_arp_reply(int port, struct ether_addr *tha, uint32_t tip, struct onvm_nf *nf) {
send_arp_reply(int port, struct rte_ether_addr *tha, uint32_t tip, struct onvm_nf *nf) {
struct rte_mbuf *out_pkt = NULL;
struct onvm_pkt_meta *pmeta = NULL;
struct ether_hdr *eth_hdr = NULL;
struct arp_hdr *out_arp_hdr = NULL;
struct rte_ether_hdr *eth_hdr = NULL;
struct rte_arp_hdr *out_arp_hdr = NULL;

size_t pkt_size = 0;

Expand All @@ -229,30 +229,30 @@ send_arp_reply(int port, struct ether_addr *tha, uint32_t tip, struct onvm_nf *n
return -1;
}

pkt_size = sizeof(struct ether_hdr) + sizeof(struct arp_hdr);
pkt_size = sizeof(struct rte_ether_hdr) + sizeof(struct rte_arp_hdr);
out_pkt->data_len = pkt_size;
out_pkt->pkt_len = pkt_size;

// SET ETHER HEADER INFO
eth_hdr = onvm_pkt_ether_hdr(out_pkt);
ether_addr_copy(&ports->mac[port], &eth_hdr->s_addr);
eth_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_ARP);
ether_addr_copy(tha, &eth_hdr->d_addr);
rte_ether_addr_copy(&ports->mac[port], &eth_hdr->s_addr);
eth_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP);
rte_ether_addr_copy(tha, &eth_hdr->d_addr);

// SET ARP HDR INFO
out_arp_hdr = rte_pktmbuf_mtod_offset(out_pkt, struct arp_hdr *, sizeof(struct ether_hdr));
out_arp_hdr = rte_pktmbuf_mtod_offset(out_pkt, struct rte_arp_hdr *, sizeof(struct rte_ether_hdr));

out_arp_hdr->arp_hrd = rte_cpu_to_be_16(ARP_HRD_ETHER);
out_arp_hdr->arp_pro = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
out_arp_hdr->arp_hln = 6;
out_arp_hdr->arp_pln = sizeof(uint32_t);
out_arp_hdr->arp_op = rte_cpu_to_be_16(ARP_OP_REPLY);
out_arp_hdr->arp_hardware = rte_cpu_to_be_16(RTE_ARP_HRD_ETHER);
out_arp_hdr->arp_protocol = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
out_arp_hdr->arp_hlen = 6;
out_arp_hdr->arp_plen = sizeof(uint32_t);
out_arp_hdr->arp_opcode = rte_cpu_to_be_16(RTE_ARP_OP_REPLY);

ether_addr_copy(&ports->mac[port], &out_arp_hdr->arp_data.arp_sha);
rte_ether_addr_copy(&ports->mac[port], &out_arp_hdr->arp_data.arp_sha);
out_arp_hdr->arp_data.arp_sip = state_info->source_ips[ports->id[port]];

out_arp_hdr->arp_data.arp_tip = tip;
ether_addr_copy(tha, &out_arp_hdr->arp_data.arp_tha);
rte_ether_addr_copy(tha, &out_arp_hdr->arp_data.arp_tha);

// SEND PACKET OUT/SET METAINFO
pmeta = onvm_get_pkt_meta(out_pkt);
Expand All @@ -265,8 +265,8 @@ send_arp_reply(int port, struct ether_addr *tha, uint32_t tip, struct onvm_nf *n
static int
packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) {
struct ether_hdr *eth_hdr = onvm_pkt_ether_hdr(pkt);
struct arp_hdr *in_arp_hdr = NULL;
struct rte_ether_hdr *eth_hdr = onvm_pkt_ether_hdr(pkt);
struct rte_arp_hdr *in_arp_hdr = NULL;
int result = -1;

/*
Expand All @@ -276,10 +276,10 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
* If its an ARP REPLY send to dest
* Ignore (fwd to dest) other opcodes
*/
if (rte_cpu_to_be_16(eth_hdr->ether_type) == ETHER_TYPE_ARP) {
in_arp_hdr = rte_pktmbuf_mtod_offset(pkt, struct arp_hdr *, sizeof(struct ether_hdr));
switch (rte_cpu_to_be_16(in_arp_hdr->arp_op)) {
case ARP_OP_REQUEST:
if (rte_cpu_to_be_16(eth_hdr->ether_type) == RTE_ETHER_TYPE_ARP) {
in_arp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_arp_hdr *, sizeof(struct rte_ether_hdr));
switch (rte_cpu_to_be_16(in_arp_hdr->arp_opcode)) {
case RTE_ARP_OP_REQUEST:
if (rte_be_to_cpu_32(in_arp_hdr->arp_data.arp_tip) ==
state_info->source_ips[ports->id[pkt->port]]) {
result = send_arp_reply(pkt->port, &eth_hdr->s_addr,
Expand All @@ -292,13 +292,14 @@ packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
return 0;
}
break;
case ARP_OP_REPLY:
case RTE_ARP_OP_REPLY:
/* Here we can potentially save the information */
break;
default:
if (state_info->print_flag) {
printf("ARP with opcode %d, port %d (ID %d) DROPPED\n",
rte_cpu_to_be_16(in_arp_hdr->arp_op), pkt->port, ports->id[pkt->port]);
rte_cpu_to_be_16(in_arp_hdr->arp_opcode),
pkt->port, ports->id[pkt->port]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_monitor/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char clr[] = {27, '[', '2', 'J', '\0'};
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/bridge/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ do_stats_display(struct rte_mbuf *pkt) {
const char topLeft[] = {27, '[', '1', ';', '1', 'H', '\0'};
static uint64_t pkt_process = 0;

struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;

pkt_process += print_delay;

Expand Down
2 changes: 1 addition & 1 deletion examples/firewall/firewall.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ do_stats_display(void) {
static int
packet_handler(struct rte_mbuf *pkt, struct onvm_pkt_meta *meta,
__attribute__((unused)) struct onvm_nf_local_ctx *nf_local_ctx) {
struct ipv4_hdr *ipv4_hdr;
struct rte_ipv4_hdr *ipv4_hdr;
static uint32_t counter = 0;
int ret;
uint32_t rule = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/flow_table/flow_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ do_stats_display(struct rte_mbuf *pkt, int32_t tbl_index) {
printf("\n\n");

#ifdef DEBUG_PRINT
struct ipv4_hdr *ip;
struct rte_ipv4_hdr *ip;
ip = onvm_pkt_ipv4_hdr(pkt);
if (ip != NULL) {
onvm_pkt_print(pkt);
Expand Down
Loading

0 comments on commit 1c6e171

Please sign in to comment.