From 704ddb08d0f173256d47964016954e58e99eab87 Mon Sep 17 00:00:00 2001 From: huangxin Date: Wed, 15 Jun 2022 11:04:04 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E8=A1=A5=E5=85=85vxlan?= =?UTF-8?q?=E4=B8=8D=E5=8F=AF=E7=94=A8=E6=83=85=E5=86=B5=E4=B8=8B=E7=BD=91?= =?UTF-8?q?=E5=8D=A1=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/lwip/src/arch_linux/netif/pcapif.c | 22 ++++++++++++++-------- srcs/user/user_info.c | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/srcs/lwip/src/arch_linux/netif/pcapif.c b/srcs/lwip/src/arch_linux/netif/pcapif.c index af70fec..4c5e3ce 100644 --- a/srcs/lwip/src/arch_linux/netif/pcapif.c +++ b/srcs/lwip/src/arch_linux/netif/pcapif.c @@ -329,8 +329,6 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { vxlan_pkg_decode(p, &ebuf, &tag); if (ebuf == NULL) { - return ERR_IF; - } else { struct eth_hdr *eth = (struct eth_hdr *)ebuf->payload; if (strlen(pContext->session.data.svrBaseMac) == 0) { @@ -345,18 +343,25 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { eth->src.addr[5]); } } - } - if ((err = pContext->session.nicif->input(ebuf, pContext->session.nicif)) != ERR_OK) { - LWIP_DEBUGF(NETIF_DEBUG, ("pppoeif_input: netif input error\n")); - } + if ((err = pContext->session.nicif->input(ebuf, pContext->session.nicif)) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("pppoeif_input: netif input error\n")); + } - pbuf_free(p); - return err; + pbuf_free(p); + return err; + } } } + // 当前网卡的数据包,vxLan无法处理则送回协议栈处理 + if (memcmp(pBuf, inp->hwaddr, inp->hwaddr_len) == 0) { + return tcpip_input(p, inp); + } + + // 遍历用户网卡处理数据 NETIF_FOREACH(netif) { + if (netif->hwaddr_len == 6 && memcmp(p->payload, netif->hwaddr, netif->hwaddr_len) == 0) { if ((err = netif->input(p, netif)) != ERR_OK) { @@ -368,6 +373,7 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { } } + // 无用户关联网卡数据直接送协议栈处理 return tcpip_input(p, inp); } diff --git a/srcs/user/user_info.c b/srcs/user/user_info.c index 620da96..eb5fbf0 100644 --- a/srcs/user/user_info.c +++ b/srcs/user/user_info.c @@ -23,7 +23,7 @@ void user_info_init() { //user_info_add(0, &g_userInfo[0]); //user_info_add(1, &g_userInfo[1]); //user_info_add(2, &g_userInfo[2]); - //user_info_add(3, &g_userInfo[3]); + user_info_add(3, &g_userInfo[3]); } void user_info_change_status(PUSER_INFO_CONTEXT pInfo, USER_STATUS status) {