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 7c695aa
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 101 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
- 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
- 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
9 changes: 5 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[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
[submodule "lib/dpdk"]
path = lib/dpdk
url = https://dpdk.org/git/dpdk-stable
branch = 22.11
3 changes: 3 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 Down
2 changes: 1 addition & 1 deletion lib/dpdk
Submodule dpdk updated from 543f40 to d75b66
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
41 changes: 22 additions & 19 deletions src/dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */ },
};
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].mac_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, &eth_hdr->src_addr);
rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].addr_table[ori_port_id].mac_addr, &eth_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);
Expand Down Expand Up @@ -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(&eth_hdr->d_addr, &vrg_ccb.hsi_lan_mac))) {
if (unlikely(!rte_is_same_ether_addr(&eth_hdr->dst_addr, &vrg_ccb.hsi_lan_mac))) {
pkt[total_tx++] = single_pkt;
#ifdef _NON_VLAN
rte_vlan_strip(single_pkt);
Expand All @@ -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, &eth_hdr->s_addr);
rte_ether_addr_copy(&vrg_ccb.ppp_ccb[user_index].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(&vrg_ccb.ppp_ccb[user_index].PPP_dst_mac, &eth_hdr->dst_addr);

vlan_header->next_proto = rte_cpu_to_be_16(ETH_P_PPP_SES);
cur = (char *)eth_hdr - 8;
Expand Down Expand Up @@ -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(&eth_hdr->d_addr, &vrg_ccb.hsi_lan_mac))) {
if (unlikely(!rte_is_same_ether_addr(&eth_hdr->dst_addr, &vrg_ccb.hsi_lan_mac))) {
#ifdef _NON_VLAN
rte_vlan_strip(single_pkt);
#endif
Expand All @@ -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(&eth_hdr->d_addr, &vrg_ccb.hsi_lan_mac))) {
if (unlikely(!rte_is_same_ether_addr(&eth_hdr->dst_addr, &vrg_ccb.hsi_lan_mac))) {
#ifdef _NON_VLAN
rte_vlan_strip(single_pkt);
#endif
Expand Down Expand Up @@ -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(&eth_hdr->s_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, &eth_hdr->s_addr);
rte_ether_addr_copy(&eth_hdr->src_addr, &eth_hdr->dst_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, &eth_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;
Expand Down Expand Up @@ -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(&eth_hdr->s_addr, &eth_hdr->d_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, &eth_hdr->s_addr);
rte_ether_addr_copy(&eth_hdr->src_addr, &eth_hdr->dst_addr);
rte_ether_addr_copy(&vrg_ccb.hsi_lan_mac, &eth_hdr->src_addr);
ip_hdr->dst_addr = ip_hdr->src_addr;
ip_hdr->src_addr = vrg_ccb.lan_ip;
icmphdr->icmp_type = 0;
Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit 7c695aa

Please sign in to comment.