Skip to content

Commit

Permalink
[Build] replace travis ci with github action
Browse files Browse the repository at this point in the history
  • Loading branch information
w180112 committed Jun 28, 2023
1 parent 7b59b22 commit 80ac42a
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 108 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
**/.DS_Store
.vscode/*
.vscode
10 changes: 6 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
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
5 changes: 5 additions & 0 deletions boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,6 +27,8 @@ pushd $path/lib/libutil
autoreconf --install
./configure
make
sudo make install
sudo ldconfig
popd
pushd $path/src
make
Expand Down
2 changes: 1 addition & 1 deletion lib/dpdk
Submodule dpdk updated from 543f40 to d75b66
2 changes: 1 addition & 1 deletion lib/dpdk-kmods
Submodule dpdk-kmods updated from 2a9f0f to e721c7
2 changes: 1 addition & 1 deletion lib/libutil
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
52 changes: 26 additions & 26 deletions src/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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, &eth_hdr.s_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr.d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &eth_hdr.src_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr.dst_addr);
eth_hdr.ether_type = rte_cpu_to_be_16(VLAN);

vlan_header.tci_union.tci_struct.priority = 0;
Expand Down Expand Up @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &eth_hdr->src_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->dst_addr);

eth_hdr->ether_type = rte_cpu_to_be_16(VLAN);

Expand Down Expand Up @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &eth_hdr->src_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->dst_addr);

*mulen = ntohs(pppoe_header->length) + sizeof(struct rte_ether_hdr) + sizeof(pppoe_header_t) + sizeof(vlan_header_t);

Expand Down Expand Up @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &eth_hdr->src_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->dst_addr);

*mulen = ntohs(pppoe_header->length) + sizeof(struct rte_ether_hdr) + sizeof(pppoe_header_t) + sizeof(vlan_header_t);

Expand Down Expand Up @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &eth_hdr->src_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_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);
Expand Down Expand Up @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &eth_hdr->src_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->dst_addr);

*mulen = ntohs(pppoe_header->length) + sizeof(struct rte_ether_hdr) + sizeof(vlan_header_t) + sizeof(pppoe_header_t);

Expand Down Expand Up @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &eth_hdr->src_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->dst_addr);
eth_hdr->ether_type = rte_cpu_to_be_16(VLAN);

vlan_header->tci_union.tci_struct.priority = 0;
Expand Down Expand Up @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_wan_src_mac, &eth_hdr->src_addr);
rte_ether_addr_copy(&s_ppp_ccb->PPP_dst_mac, &eth_hdr->dst_addr);

ppp_payload->ppp_protocol = rte_cpu_to_be_16(PAP_PROTOCOL);
ppp_pap_header.code = PAP_REQUEST;
Expand Down Expand Up @@ -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(&eth_hdr->s_addr, &tmp_mac);
rte_ether_addr_copy(&eth_hdr->d_addr, &eth_hdr->s_addr);
rte_ether_addr_copy(&tmp_mac, &eth_hdr->d_addr);
rte_ether_addr_copy(&eth_hdr->src_addr, &tmp_mac);
rte_ether_addr_copy(&eth_hdr->dst_addr, &eth_hdr->src_addr);
rte_ether_addr_copy(&tmp_mac, &eth_hdr->dst_addr);

ppp_payload->ppp_protocol = rte_cpu_to_be_16(PAP_PROTOCOL);
ppp_pap_header.code = PAP_ACK;
Expand Down Expand Up @@ -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);
Expand Down
20 changes: 10 additions & 10 deletions src/dhcp_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/dhcpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ int dhcpd(struct rte_mbuf *single_pkt, struct rte_ether_hdr *eth_hdr, vlan_heade
for(int i=0; i<LAN_USER; i++) {
if (dhcp_ccb[user_index].lan_user_info[i].lan_user_used == FALSE) {
lan_user_index = dhcp_ccb[user_index].cur_lan_user_index = i;
rte_ether_addr_copy(&eth_hdr->s_addr, &dhcp_ccb[user_index].lan_user_info[i].mac_addr);
rte_ether_addr_copy(&eth_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(&eth_hdr->s_addr, &dhcp_ccb[user_index].lan_user_info[i].mac_addr)) {
else if (rte_is_same_ether_addr(&eth_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;
}
Expand Down
Loading

0 comments on commit 80ac42a

Please sign in to comment.