From d7b2940f9d75121811aa66522d994b8092308924 Mon Sep 17 00:00:00 2001 From: the Date: Thu, 29 Jun 2023 02:56:26 +0800 Subject: [PATCH] Use GitHub action (#5) * [Build] replace travis ci with github action * [Build] replace travis ci with github action --- .github/workflow/ci.yml | 21 ---------------- .github/workflows/ci.yml | 10 ++++---- .gitignore | 2 +- .gitmodules | 10 ++++---- boot.sh | 5 ++++ lib/dpdk | 2 +- lib/dpdk-kmods | 2 +- lib/libutil | 2 +- src/Makefile | 2 +- src/codec.c | 52 ++++++++++++++++++++-------------------- src/dhcp_codec.c | 20 ++++++++-------- src/dhcpd.c | 4 ++-- src/dp.c | 41 ++++++++++++++++--------------- src/dp_codec.h | 28 +++++++++++----------- src/ethtool.c | 23 ++++-------------- src/nat.h | 6 ++--- src/pppd.c | 2 +- 17 files changed, 103 insertions(+), 129 deletions(-) delete mode 100644 .github/workflow/ci.yml diff --git a/.github/workflow/ci.yml b/.github/workflow/ci.yml deleted file mode 100644 index 2bbcb333..00000000 --- a/.github/workflow/ci.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: vRG ci -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: sudo apt-get update && apt-get install -y libnuma-dev linux-headers-$(uname -r) python3-pip - - run: sudo pip3 install setuptools meson ninja pyelftools - - run: ./boot.sh - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - run: sudo apt-get update && apt-get install -y libnuma-dev linux-headers-$(uname -r) python3-pip - - run: sudo pip3 install setuptools meson ninja pyelftools \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bbcb333..9811b055 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,13 +9,13 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - run: sudo apt-get update && apt-get install -y libnuma-dev linux-headers-$(uname -r) python3-pip + - uses: actions/checkout@v2 + - run: sudo apt-get update && sudo apt-get install -y libnuma-dev linux-headers-$(uname -r) python3-pip git gcc make libtool-bin - run: sudo pip3 install setuptools meson ninja pyelftools - - run: ./boot.sh + - run: ${{ github.workspace }}/boot.sh test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - run: sudo apt-get update && apt-get install -y libnuma-dev linux-headers-$(uname -r) python3-pip + - uses: actions/checkout@v2 + - run: sudo apt-get update && sudo apt-get install -y libnuma-dev linux-headers-$(uname -r) python3-pip git gcc make libtool-bin - run: sudo pip3 install setuptools meson ninja pyelftools \ No newline at end of file diff --git a/.gitignore b/.gitignore index c3d57470..c6874873 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ **/.DS_Store -.vscode/* \ No newline at end of file +.vscode \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 6d04b4d6..30101cdb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,11 @@ [submodule "lib/libutil"] path = lib/libutil url = https://github.com/w180112/libutil.git -[submodule "lib/dpdk"] - path = lib/dpdk - url = https://github.com/DPDK/dpdk [submodule "lib/dpdk-kmods"] path = lib/dpdk-kmods - url = https://dpdk.org/git/dpdk-kmods \ No newline at end of file + url = https://dpdk.org/git/dpdk-kmods + branch = main +[submodule "lib/dpdk"] + path = lib/dpdk + url = https://dpdk.org/git/dpdk-stable + branch = 22.11 diff --git a/boot.sh b/boot.sh index 9637e55a..54bd106a 100755 --- a/boot.sh +++ b/boot.sh @@ -11,6 +11,9 @@ get_script_dir () { echo "$DIR" } path=$(get_script_dir) +pushd $path +git submodule update --init --recursive +popd pushd $path/lib/dpdk && meson $path/lib/dpdk_build popd pushd $path/lib/dpdk_build @@ -24,6 +27,8 @@ pushd $path/lib/libutil autoreconf --install ./configure make +sudo make install +sudo ldconfig popd pushd $path/src make diff --git a/lib/dpdk b/lib/dpdk index 543f40f5..d75b66ad 160000 --- a/lib/dpdk +++ b/lib/dpdk @@ -1 +1 @@ -Subproject commit 543f40f5952a869710e39ff51deccc96c5b88b3f +Subproject commit d75b66ad1cf8b9c0a14020a4cd9ddcd34dea924b diff --git a/lib/dpdk-kmods b/lib/dpdk-kmods index 2a9f0f72..e721c733 160000 --- a/lib/dpdk-kmods +++ b/lib/dpdk-kmods @@ -1 +1 @@ -Subproject commit 2a9f0f72a2d926382634cf8f1de10e1acf57542b +Subproject commit e721c733cd24206399bebb8f0751b0387c4c1595 diff --git a/lib/libutil b/lib/libutil index 33936e84..3176f23c 160000 --- a/lib/libutil +++ b/lib/libutil @@ -1 +1 @@ -Subproject commit 33936e84b47fcf00d26630e7720c82431c899a94 +Subproject commit 3176f23cc7da839cd5051c78f08717c0d4cdf1ac diff --git a/src/Makefile b/src/Makefile index aa6438cd..18f30367 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ PKGCONF ?= pkg-config INCLUDE += -I. -I../lib/libutil CFLAGS += $(INCLUDE) -Wall -fPIC -g -std=c99 -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_TEST_MODE #-D_DP_DBG -D_NON_VLAN -LDFLAGS += -L../lib/libutil -lutil +LDFLAGS += -lutils PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) diff --git a/src/codec.c b/src/codec.c index e7fb9eae..d95b25ec 100644 --- a/src/codec.c +++ b/src/codec.c @@ -511,8 +511,8 @@ STATUS build_padi(__attribute__((unused)) struct rte_timer *tim, PPP_INFO_t *s_p PPP_bye(s_ppp_ccb); } for(int i=0; i<6; i++) { - eth_hdr.s_addr.addr_bytes[i] = vrg_ccb.hsi_wan_src_mac.addr_bytes[i]; - eth_hdr.d_addr.addr_bytes[i] = 0xff; + eth_hdr.src_addr.addr_bytes[i] = vrg_ccb.hsi_wan_src_mac.addr_bytes[i]; + eth_hdr.dst_addr.addr_bytes[i] = 0xff; } eth_hdr.ether_type = rte_cpu_to_be_16(VLAN); @@ -566,8 +566,8 @@ STATUS build_padr(__attribute__((unused)) struct rte_timer *tim, PPP_INFO_t *s_p } if (s_ppp_ccb->pppoe_phase.timer_counter > 0) goto send; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &s_ppp_ccb->pppoe_phase.eth_hdr->s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &s_ppp_ccb->pppoe_phase.eth_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &s_ppp_ccb->pppoe_phase.eth_hdr->src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &s_ppp_ccb->pppoe_phase.eth_hdr->dst_addr); s_ppp_ccb->pppoe_phase.pppoe_header->code = PADR; U32 total_tag_length = 0; @@ -640,8 +640,8 @@ STATUS build_padt(PPP_INFO_t *s_ppp_ccb) vlan_header_t vlan_header; pppoe_header_t pppoe_header; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr.s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr.d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr.src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr.dst_addr); eth_hdr.ether_type = rte_cpu_to_be_16(VLAN); vlan_header.tci_union.tci_struct.priority = 0; @@ -692,8 +692,8 @@ STATUS build_config_request(unsigned char *buffer, PPP_INFO_t *s_ppp_ccb, U16 *m srand(time(NULL)); - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->dst_addr); eth_hdr->ether_type = rte_cpu_to_be_16(VLAN); @@ -810,8 +810,8 @@ STATUS build_config_ack(unsigned char* buffer, PPP_INFO_t *s_ppp_ccb, U16 *mulen ppp_hdr->code = CONFIG_ACK; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->dst_addr); *mulen = ntohs(pppoe_header->length) + sizeof(struct rte_ether_hdr) + sizeof(pppoe_header_t) + sizeof(vlan_header_t); @@ -849,8 +849,8 @@ STATUS build_config_nak_rej(unsigned char* buffer, PPP_INFO_t *s_ppp_ccb, U16 *m ppp_header_t *ppp_hdr = s_ppp_ccb->ppp_phase[s_ppp_ccb->cp].ppp_hdr; ppp_options_t *ppp_options = s_ppp_ccb->ppp_phase[s_ppp_ccb->cp].ppp_options; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->dst_addr); *mulen = ntohs(pppoe_header->length) + sizeof(struct rte_ether_hdr) + sizeof(pppoe_header_t) + sizeof(vlan_header_t); @@ -889,8 +889,8 @@ STATUS build_echo_reply(unsigned char* buffer, PPP_INFO_t *s_ppp_ccb, U16 *mulen ppp_hdr->code = ECHO_REPLY; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->dst_addr); pppoe_header->length = rte_cpu_to_be_16(sizeof(ppp_payload_t) + sizeof(ppp_header_t) + 4); *mulen = ntohs(pppoe_header->length) + sizeof(struct rte_ether_hdr) + sizeof(pppoe_header_t) + sizeof(vlan_header_t); @@ -926,8 +926,8 @@ STATUS build_terminate_ack(unsigned char* buffer, PPP_INFO_t *s_ppp_ccb, U16 *mu ppp_hdr->code = TERMIN_ACK; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->dst_addr); *mulen = ntohs(pppoe_header->length) + sizeof(struct rte_ether_hdr) + sizeof(vlan_header_t) + sizeof(pppoe_header_t); @@ -963,8 +963,8 @@ STATUS build_terminate_request(unsigned char* buffer, PPP_INFO_t *s_ppp_ccb, U16 ppp_payload_t *ppp_payload = s_ppp_ccb->ppp_phase[s_ppp_ccb->cp].ppp_payload; ppp_header_t *ppp_hdr = s_ppp_ccb->ppp_phase[s_ppp_ccb->cp].ppp_hdr; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->dst_addr); eth_hdr->ether_type = rte_cpu_to_be_16(VLAN); vlan_header->tci_union.tci_struct.priority = 0; @@ -1038,8 +1038,8 @@ STATUS build_auth_request_pap(unsigned char* buffer, PPP_INFO_t *s_ppp_ccb, U16 s_ppp_ccb->phase = AUTH_PHASE; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, ð_hdr->dst_addr); ppp_payload->ppp_protocol = rte_cpu_to_be_16(PAP_PROTOCOL); ppp_pap_header.code = PAP_REQUEST; @@ -1092,9 +1092,9 @@ STATUS build_auth_ack_pap(unsigned char *buffer, PPP_INFO_t *s_ppp_ccb, U16 *mul ppp_payload_t *ppp_payload = s_ppp_ccb->ppp_phase[s_ppp_ccb->cp].ppp_payload; ppp_header_t *ppp_hdr = s_ppp_ccb->ppp_phase[s_ppp_ccb->cp].ppp_hdr; - rte_ether_addr_copy(ð_hdr->s_addr, &tmp_mac); - rte_ether_addr_copy(ð_hdr->d_addr, ð_hdr->s_addr); - rte_ether_addr_copy(&tmp_mac, ð_hdr->d_addr); + rte_ether_addr_copy(ð_hdr->src_addr, &tmp_mac); + rte_ether_addr_copy(ð_hdr->dst_addr, ð_hdr->src_addr); + rte_ether_addr_copy(&tmp_mac, ð_hdr->dst_addr); ppp_payload->ppp_protocol = rte_cpu_to_be_16(PAP_PROTOCOL); ppp_pap_header.code = PAP_ACK; @@ -1154,9 +1154,9 @@ STATUS build_auth_response_chap(U8 *buffer, PPP_INFO_t *s_ppp_ccb, U16 *mulen, p new_ppp_chap_data.val = chap_hash; new_ppp_chap_data.name = s_ppp_ccb->ppp_user_id; - rte_ether_addr_copy(&s_ppp_ccb->ppp_phase[0].eth_hdr->s_addr, &tmp_mac); - rte_ether_addr_copy(&s_ppp_ccb->ppp_phase[0].eth_hdr->d_addr, &s_ppp_ccb->ppp_phase[0].eth_hdr->s_addr); - rte_ether_addr_copy(&tmp_mac, &s_ppp_ccb->ppp_phase[0].eth_hdr->d_addr); + rte_ether_addr_copy(&s_ppp_ccb->ppp_phase[0].eth_hdr->src_addr, &tmp_mac); + rte_ether_addr_copy(&s_ppp_ccb->ppp_phase[0].eth_hdr->dst_addr, &s_ppp_ccb->ppp_phase[0].eth_hdr->src_addr); + rte_ether_addr_copy(&tmp_mac, &s_ppp_ccb->ppp_phase[0].eth_hdr->dst_addr); *(struct rte_ether_hdr *)buf_ptr = *s_ppp_ccb->ppp_phase[0].eth_hdr; buf_ptr += sizeof(struct rte_ether_hdr); diff --git a/src/dhcp_codec.c b/src/dhcp_codec.c index 2b2d96c1..55b2fce7 100644 --- a/src/dhcp_codec.c +++ b/src/dhcp_codec.c @@ -65,7 +65,7 @@ BIT16 dhcp_decode(dhcp_ccb_t *dhcp_ccb, struct rte_ether_hdr *eth_hdr, vlan_head rte_timer_stop(&dhcp_ccb->lan_user_info[dhcp_ccb->cur_lan_user_index].timer); break; case DHCP_RELEASE: - if (check_pool(dhcp_ccb, eth_hdr->s_addr)) + if (check_pool(dhcp_ccb, eth_hdr->src_addr)) event = E_RELEASE; break; default: @@ -115,7 +115,7 @@ STATUS decode_request(dhcp_ccb_t *dhcp_ccb) dhcp_opt_t *cur = opt_ptr; struct rte_ether_addr mac_addr; - rte_ether_addr_copy(&dhcp_ccb->eth_hdr->s_addr, &mac_addr); + rte_ether_addr_copy(&dhcp_ccb->eth_hdr->src_addr, &mac_addr); if (dhcp_ccb->dhcp_info->client_ip | RTE_IPV4_ANY) { dhcp_ccb->dhcp_info->ur_client_ip = dhcp_ccb->dhcp_info->client_ip; dhcp_ccb->dhcp_info->client_ip = 0; @@ -162,9 +162,9 @@ STATUS build_dhcp_offer(dhcp_ccb_t *dhcp_ccb) U32 ip_addr; rte_eth_macaddr_get(0, &macaddr); - rte_ether_addr_copy(&dhcp_ccb->eth_hdr->s_addr, &dhcp_ccb->eth_hdr->d_addr); - rte_ether_addr_copy(&macaddr, &dhcp_ccb->eth_hdr->s_addr); - if (pick_ip_from_pool(dhcp_ccb, &ip_addr, dhcp_ccb->eth_hdr->d_addr) < 0) + rte_ether_addr_copy(&dhcp_ccb->eth_hdr->src_addr, &dhcp_ccb->eth_hdr->dst_addr); + rte_ether_addr_copy(&macaddr, &dhcp_ccb->eth_hdr->src_addr); + if (pick_ip_from_pool(dhcp_ccb, &ip_addr, dhcp_ccb->eth_hdr->dst_addr) < 0) return FALSE; dhcp_ccb->ip_hdr->packet_id = ip_hdr_id++; dhcp_ccb->ip_hdr->packet_id = rte_cpu_to_be_16(dhcp_ccb->ip_hdr->packet_id); @@ -246,8 +246,8 @@ STATUS build_dhcp_ack(dhcp_ccb_t *dhcp_ccb) struct rte_ether_addr macaddr; rte_eth_macaddr_get(0, &macaddr); - rte_ether_addr_copy(&dhcp_ccb->eth_hdr->s_addr, &dhcp_ccb->eth_hdr->d_addr); - rte_ether_addr_copy(&macaddr, &dhcp_ccb->eth_hdr->s_addr); + rte_ether_addr_copy(&dhcp_ccb->eth_hdr->src_addr, &dhcp_ccb->eth_hdr->dst_addr); + rte_ether_addr_copy(&macaddr, &dhcp_ccb->eth_hdr->src_addr); dhcp_ccb->ip_hdr->packet_id = ip_hdr_id++; dhcp_ccb->ip_hdr->packet_id = rte_cpu_to_be_16(dhcp_ccb->ip_hdr->packet_id); @@ -328,8 +328,8 @@ STATUS build_dhcp_nak(dhcp_ccb_t *dhcp_ccb) struct rte_ether_addr macaddr; rte_eth_macaddr_get(0, &macaddr); - rte_ether_addr_copy(&dhcp_ccb->eth_hdr->s_addr, &dhcp_ccb->eth_hdr->d_addr); - rte_ether_addr_copy(&macaddr, &dhcp_ccb->eth_hdr->s_addr); + rte_ether_addr_copy(&dhcp_ccb->eth_hdr->src_addr, &dhcp_ccb->eth_hdr->dst_addr); + rte_ether_addr_copy(&macaddr, &dhcp_ccb->eth_hdr->src_addr); dhcp_ccb->ip_hdr->packet_id = ip_hdr_id++; dhcp_ccb->ip_hdr->packet_id = rte_cpu_to_be_16(dhcp_ccb->ip_hdr->packet_id); @@ -367,7 +367,7 @@ STATUS build_dhcp_nak(dhcp_ccb_t *dhcp_ccb) cur = (dhcp_opt_t *)(((char *)cur) + sizeof(dhcp_opt_t) + cur->len); cur->opt_type = DHCP_CLIENT_ID; cur->len = RTE_ETHER_ADDR_LEN; - rte_ether_addr_copy(&dhcp_ccb->eth_hdr->d_addr, (struct rte_ether_addr *)(cur->val)); + rte_ether_addr_copy(&dhcp_ccb->eth_hdr->dst_addr, (struct rte_ether_addr *)(cur->val)); dhcp_ccb->udp_hdr->dgram_len += sizeof(dhcp_opt_t) + cur->len; cur = (dhcp_opt_t *)(((char *)cur) + sizeof(dhcp_opt_t) + cur->len); diff --git a/src/dhcpd.c b/src/dhcpd.c index 50aa44e3..c80d1fee 100644 --- a/src/dhcpd.c +++ b/src/dhcpd.c @@ -55,11 +55,11 @@ int dhcpd(struct rte_mbuf *single_pkt, struct rte_ether_hdr *eth_hdr, vlan_heade for(int i=0; is_addr, &dhcp_ccb[user_index].lan_user_info[i].mac_addr); + rte_ether_addr_copy(ð_hdr->src_addr, &dhcp_ccb[user_index].lan_user_info[i].mac_addr); dhcp_ccb[user_index].lan_user_info[i].lan_user_used = TRUE; break; } - else if (rte_is_same_ether_addr(ð_hdr->s_addr, &dhcp_ccb[user_index].lan_user_info[i].mac_addr)) { + else if (rte_is_same_ether_addr(ð_hdr->src_addr, &dhcp_ccb[user_index].lan_user_info[i].mac_addr)) { lan_user_index = dhcp_ccb[user_index].cur_lan_user_index = i; break; } diff --git a/src/dp.c b/src/dp.c index 3fe9c715..3e68e9b7 100644 --- a/src/dp.c +++ b/src/dp.c @@ -48,11 +48,14 @@ static U16 nb_rxd = RX_RING_SIZE; static U16 nb_txd = TX_RING_SIZE; static struct rte_eth_conf port_conf_default = { - .rxmode = { .max_rx_pkt_len = RTE_ETHER_MAX_LEN, }, - .txmode = { .offloads = DEV_TX_OFFLOAD_IPV4_CKSUM | - DEV_TX_OFFLOAD_UDP_CKSUM | - /*DEV_TX_OFFLOAD_MT_LOCKFREE |*/ - DEV_TX_OFFLOAD_TCP_CKSUM, }, + /* https://github.com/DPDK/dpdk/commit/1bb4a528c41f4af4847bd3d58cc2b2b9f1ec9a27#diff-71b61db11e3ee1ca6bb272a90e3c1aa0e8c90071b1a38387fd541687314b1843 + * From this commit, mtu field is only for jumbo frame + **/ + //.rxmode = { .mtu = RTE_ETHER_MAX_JUMBO_FRAME_LEN - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN, }, + .txmode = { .offloads = RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | + RTE_ETH_TX_OFFLOAD_UDP_CKSUM | + /*RTE_ETH_TX_OFFLOAD_MT_LOCKFREE |*/ + RTE_ETH_TX_OFFLOAD_TCP_CKSUM, }, .intr_conf = { .lsc = 1, /**< link status interrupt feature enabled */ }, }; @@ -82,8 +85,8 @@ int PORT_INIT(U16 port) int ret = rte_eth_dev_info_get(port, &dev_info); if (ret != 0) rte_exit(EXIT_FAILURE, "Error during getting device (port %u) info: %s\n", port, strerror(-ret)); - if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) - port_conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE; + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) + port_conf.txmode.offloads |= RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf); if (retval != 0) @@ -245,8 +248,8 @@ int wan_recvd(void) ori_port_id = rte_cpu_to_be_16(icmphdr->icmp_ident); int16_t icmp_cksum_diff = icmphdr->icmp_ident - vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].port_id; - rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].mac_addr, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].mac_addr, ð_hdr->dst_addr); ip_hdr->dst_addr = vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].src_ip; icmphdr->icmp_ident = vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].port_id; rte_atomic16_set(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].is_alive, 10); @@ -520,7 +523,7 @@ int lan_recvd(void) single_pkt->l3_len = sizeof(struct rte_ipv4_hdr); if (ip_hdr->next_proto_id == PROTO_TYPE_ICMP) { - if (unlikely(!rte_is_same_ether_addr(ð_hdr->d_addr, &vrg_ccb.hsi_lan_mac))) { + if (unlikely(!rte_is_same_ether_addr(ð_hdr->dst_addr, &vrg_ccb.hsi_lan_mac))) { pkt[total_tx++] = single_pkt; #ifdef _NON_VLAN rte_vlan_strip(single_pkt); @@ -547,8 +550,8 @@ int lan_recvd(void) icmp_new_cksum = (icmp_new_cksum & 0xFFFF) + (icmp_new_cksum >> 16); icmphdr->icmp_cksum = (U16)icmp_new_cksum; - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].PPP_dst_mac, ð_hdr->dst_addr); vlan_header->next_proto = rte_cpu_to_be_16(ETH_P_PPP_SES); cur = (char *)eth_hdr - 8; @@ -583,7 +586,7 @@ int lan_recvd(void) #endif } else if (ip_hdr->next_proto_id == PROTO_TYPE_TCP) { - if (unlikely(!rte_is_same_ether_addr(ð_hdr->d_addr, &vrg_ccb.hsi_lan_mac))) { + if (unlikely(!rte_is_same_ether_addr(ð_hdr->dst_addr, &vrg_ccb.hsi_lan_mac))) { #ifdef _NON_VLAN rte_vlan_strip(single_pkt); #endif @@ -606,7 +609,7 @@ int lan_recvd(void) rte_ring_enqueue_burst(gateway_q, (void **)&single_pkt, 1, NULL); continue; } - if (unlikely(!rte_is_same_ether_addr(ð_hdr->d_addr, &vrg_ccb.hsi_lan_mac))) { + if (unlikely(!rte_is_same_ether_addr(ð_hdr->dst_addr, &vrg_ccb.hsi_lan_mac))) { #ifdef _NON_VLAN rte_vlan_strip(single_pkt); #endif @@ -676,8 +679,8 @@ int gateway(void) if (unlikely(vlan_header->next_proto == rte_cpu_to_be_16(FRAME_TYPE_ARP))) { arphdr = (struct rte_arp_hdr *)(rte_pktmbuf_mtod(single_pkt, unsigned char *) + sizeof(struct rte_ether_hdr) + sizeof(vlan_header_t)); if (arphdr->arp_opcode == rte_cpu_to_be_16(RTE_ARP_OP_REQUEST) && arphdr->arp_data.arp_tip == vrg_ccb.lan_ip) { - rte_ether_addr_copy(ð_hdr->s_addr, ð_hdr->d_addr); - rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->s_addr); + rte_ether_addr_copy(ð_hdr->src_addr, ð_hdr->dst_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->src_addr); rte_ether_addr_copy(&arphdr->arp_data.arp_sha, &arphdr->arp_data.arp_tha); rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, &arphdr->arp_data.arp_sha); arphdr->arp_data.arp_tip = arphdr->arp_data.arp_sip; @@ -710,8 +713,8 @@ int gateway(void) case PROTO_TYPE_ICMP: icmphdr = (struct rte_icmp_hdr *)(rte_pktmbuf_mtod(single_pkt, unsigned char *) + sizeof(struct rte_ether_hdr) + sizeof(vlan_header_t) + sizeof(struct rte_ipv4_hdr)); if (ip_hdr->dst_addr == vrg_ccb.lan_ip) { - rte_ether_addr_copy(ð_hdr->s_addr, ð_hdr->d_addr); - rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->s_addr); + rte_ether_addr_copy(ð_hdr->src_addr, ð_hdr->dst_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->src_addr); ip_hdr->dst_addr = ip_hdr->src_addr; ip_hdr->src_addr = vrg_ccb.lan_ip; icmphdr->icmp_type = 0; @@ -805,7 +808,7 @@ static int lsi_event_callback(U16 port_id, enum rte_eth_event_type type, void *p if (link.link_status) { printf("Port %d Link Up - speed %u Mbps - %s\n\n", port_id, (unsigned)link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? + (link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ? ("full-duplex") : ("half-duplex")); mail->refp[0] = LINK_UP; } diff --git a/src/dp_codec.h b/src/dp_codec.h index 4ff4d8cd..ae7e968c 100644 --- a/src/dp_codec.h +++ b/src/dp_codec.h @@ -27,8 +27,8 @@ static inline void build_icmp_unreach(struct rte_mbuf *pkt, U16 user_index, stru vlan_header_t *vlan_header; struct rte_ether_hdr *new_eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); - rte_ether_addr_copy(ð_hdr->s_addr, &new_eth_hdr->d_addr); - rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, &new_eth_hdr->s_addr); + rte_ether_addr_copy(ð_hdr->src_addr, &new_eth_hdr->dst_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, &new_eth_hdr->src_addr); new_eth_hdr->ether_type = rte_cpu_to_be_16(VLAN); vlan_header = (vlan_header_t *)(new_eth_hdr + 1); *vlan_header = old_vlan_hdr; @@ -92,8 +92,8 @@ static inline int encaps_udp(struct rte_mbuf **single_pkt, struct rte_ether_hdr /* for PPPoE */ eth_hdr = (struct rte_ether_hdr *)rte_pktmbuf_prepend((*single_pkt), (U16)(sizeof(struct rte_ether_hdr) + sizeof(vlan_header_t) + sizeof(pppoe_header_t) + sizeof(ppp_payload_t))); - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].PPP_dst_mac, ð_hdr->dst_addr); eth_hdr->ether_type = rte_cpu_to_be_16(VLAN); vlan_header = (vlan_header_t *)(eth_hdr + 1); vlan_header->tci_union.tci_value = old_vlan_hdr.tci_union.tci_value; @@ -155,11 +155,11 @@ static inline int encaps_tcp(struct rte_mbuf **single_pkt, struct rte_ether_hdr //(*single_pkt)->ol_flags = PKT_TX_IPV4 | PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM; (*single_pkt)->l2_len = sizeof(struct rte_ether_hdr) + sizeof(vlan_header_t) + sizeof(pppoe_header_t) + sizeof(ppp_payload_t); - rte_memcpy(eth_hdr->s_addr.addr_bytes,vrg_ccb.ppp_ccb[user_index].src_mac,ETH_ALEN); - rte_memcpy(eth_hdr->d_addr.addr_bytes,vrg_ccb.ppp_ccb[user_index].dst_mac,ETH_ALEN); + rte_memcpy(eth_hdr->src_addr.addr_bytes,vrg_ccb.ppp_ccb[user_index].src_mac,ETH_ALEN); + rte_memcpy(eth_hdr->dst_addr.addr_bytes,vrg_ccb.ppp_ccb[user_index].dst_mac,ETH_ALEN); - //rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].src_mac, ð_hdr->s_addr); - //rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].dst_mac, ð_hdr->d_addr); + //rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].src_mac, ð_hdr->src_addr); + //rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].dst_mac, ð_hdr->dst_addr); eth_hdr->ether_type = rte_cpu_to_be_16(VLAN); vlan_header = (vlan_header_t *)(eth_hdr + 1); vlan_header->tci_union.tci_value = old_vlan_hdr.tci_union.tci_value; @@ -200,8 +200,8 @@ static inline int encaps_tcp(struct rte_mbuf **single_pkt, struct rte_ether_hdr new_pkt_num = 1; eth_hdr = (struct rte_ether_hdr *)rte_pktmbuf_prepend((*single_pkt), (U16)(sizeof(struct rte_ether_hdr) + sizeof(vlan_header_t) + sizeof(pppoe_header_t) + sizeof(ppp_payload_t))); /* for PPPoE */ - rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].PPP_dst_mac, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].PPP_dst_mac, ð_hdr->dst_addr); eth_hdr->ether_type = rte_cpu_to_be_16(VLAN); vlan_header = (vlan_header_t *)(eth_hdr + 1); vlan_header->tci_union.tci_value = old_vlan_hdr.tci_union.tci_value; @@ -229,8 +229,8 @@ static inline int decaps_udp(struct rte_mbuf *single_pkt, struct rte_ether_hdr * //single_pkt->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CKSUM/* | PKT_TX_UDP_CKSUM*/; udphdr = (struct rte_udp_hdr *)(ip_hdr + 1); ori_port_id = rte_cpu_to_be_16(udphdr->dst_port); - rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].mac_addr, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].mac_addr, ð_hdr->dst_addr); ip_hdr->dst_addr = vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].src_ip; udphdr->dst_port = vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].port_id; rte_atomic16_set(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].is_alive, 10); @@ -253,8 +253,8 @@ static inline int decaps_tcp(struct rte_mbuf *single_pkt, struct rte_ether_hdr * //single_pkt->ol_flags |= PKT_TX_IPV4 | PKT_TX_IP_CKSUM/* | PKT_TX_TCP_CKSUM*/; tcphdr = (struct rte_tcp_hdr *)(ip_hdr + 1); ori_port_id = rte_cpu_to_be_16(tcphdr->dst_port); - rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->s_addr); - rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].mac_addr, ð_hdr->d_addr); + rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, ð_hdr->src_addr); + rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].mac_addr, ð_hdr->dst_addr); ip_hdr->dst_addr = vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].src_ip; tcphdr->dst_port = vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].port_id; rte_atomic16_set(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].is_alive, 10); diff --git a/src/ethtool.c b/src/ethtool.c index 011d166f..3b66b7da 100644 --- a/src/ethtool.c +++ b/src/ethtool.c @@ -1,18 +1,15 @@ #include #include #include +#include #include #include #include -int rte_ethtool_get_drvinfo(U16 port_id, struct ethtool_drvinfo *drvinfo); - int rte_ethtool_get_drvinfo(U16 port_id, struct ethtool_drvinfo *drvinfo) { struct rte_eth_dev_info dev_info; struct rte_dev_reg_info reg_info; - const struct rte_pci_device *pci_dev; - const struct rte_bus *bus = NULL; int n; if (drvinfo == NULL) @@ -33,21 +30,9 @@ int rte_ethtool_get_drvinfo(U16 port_id, struct ethtool_drvinfo *drvinfo) memset(&dev_info, 0, sizeof(dev_info)); rte_eth_dev_info_get(port_id, &dev_info); - snprintf(drvinfo->driver, sizeof(drvinfo->driver), "%s", - dev_info.driver_name); - snprintf(drvinfo->version, sizeof(drvinfo->version), "%s", - rte_version()); - if (dev_info.device) - bus = rte_bus_find_by_device(dev_info.device); - if (bus && !strcmp(bus->name, "pci")) { - pci_dev = RTE_DEV_TO_PCI(dev_info.device); - snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), - "%04x:%02x:%02x.%x", - pci_dev->addr.domain, pci_dev->addr.bus, - pci_dev->addr.devid, pci_dev->addr.function); - } - else - snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "N/A"); + strlcpy(drvinfo->driver, dev_info.driver_name, sizeof(drvinfo->driver)); + strlcpy(drvinfo->version, rte_version(), sizeof(drvinfo->version)); + strlcpy(drvinfo->bus_info, rte_dev_name(dev_info.device), sizeof(drvinfo->bus_info)); memset(®_info, 0, sizeof(reg_info)); rte_eth_dev_get_reg_info(port_id, ®_info); diff --git a/src/nat.h b/src/nat.h index f8a2be02..052eb4ee 100644 --- a/src/nat.h +++ b/src/nat.h @@ -52,7 +52,7 @@ static inline void nat_icmp_learning(struct rte_ether_hdr *eth_hdr, struct rte_i #ifdef _DP_DBG puts("learning new icmp nat rule"); #endif - rte_ether_addr_copy(ð_hdr->s_addr, &addr_table[*new_port_id].mac_addr); + rte_ether_addr_copy(ð_hdr->src_addr, &addr_table[*new_port_id].mac_addr); addr_table[*new_port_id].src_ip = ip_hdr->src_addr; addr_table[*new_port_id].dst_ip = ip_hdr->dst_addr; addr_table[*new_port_id].port_id = icmphdr->icmp_ident; @@ -81,7 +81,7 @@ static inline void nat_udp_learning(struct rte_ether_hdr *eth_hdr, struct rte_ip #ifdef _DP_DBG puts("learning new udp nat rule"); #endif - rte_ether_addr_copy(ð_hdr->s_addr, &addr_table[*new_port_id].mac_addr); + rte_ether_addr_copy(ð_hdr->src_addr, &addr_table[*new_port_id].mac_addr); addr_table[*new_port_id].src_ip = ip_hdr->src_addr; addr_table[*new_port_id].dst_ip = ip_hdr->dst_addr; addr_table[*new_port_id].port_id = udphdr->src_port; @@ -110,7 +110,7 @@ static inline void nat_tcp_learning(struct rte_ether_hdr *eth_hdr, struct rte_ip #ifdef _DP_DBG puts("learning new tcp nat rule"); #endif - rte_ether_addr_copy(ð_hdr->s_addr, &addr_table[*new_port_id].mac_addr); + rte_ether_addr_copy(ð_hdr->src_addr, &addr_table[*new_port_id].mac_addr); addr_table[*new_port_id].src_ip = ip_hdr->src_addr; addr_table[*new_port_id].dst_ip = ip_hdr->dst_addr; addr_table[*new_port_id].port_id = tcphdr->src_port; diff --git a/src/pppd.c b/src/pppd.c index 155f34c5..a8d97b2a 100644 --- a/src/pppd.c +++ b/src/pppd.c @@ -213,7 +213,7 @@ STATUS ppp_process(tVRG_MBX *mail) ppp_ccb[session_index].pppoe_phase.max_retransmit = MAX_RETRAN; ppp_ccb[session_index].pppoe_phase.timer_counter = 0; rte_timer_stop(&(ppp_ccb[session_index].pppoe)); - rte_ether_addr_copy(ð_hdr.s_addr, &ppp_ccb[session_index].PPP_dst_mac); + rte_ether_addr_copy(ð_hdr.src_addr, &ppp_ccb[session_index].PPP_dst_mac); if (build_padr(&(ppp_ccb[session_index].pppoe),&(ppp_ccb[session_index])) == FALSE) { exit_ppp(&(ppp_ccb[session_index].pppoe), &(ppp_ccb[session_index])); return FALSE;