From 6ee38533edad51f729a81b8e1a45672c162460b6 Mon Sep 17 00:00:00 2001 From: huangxin Date: Tue, 14 Jun 2022 09:14:03 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E5=8F=AF=E4=BB=A5=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E4=B8=8B=E5=8F=91=E7=9A=84=E9=85=8D=E7=BD=AE=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0vxLan=E4=BF=A1=E6=81=AF=202.=20vxLan=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C=E7=BD=91?= =?UTF-8?q?=E5=8D=A1=E8=B5=B0=E6=99=AE=E9=80=9A=E6=95=B0=E6=8D=AE=E5=8C=85?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/libs/config/agent.cfg | 2 +- srcs/libs/mq/mq_data.c | 4 +-- srcs/lwip/src/arch_linux/netif/pcapif.c | 39 ++++++++++++------------- srcs/pppoe/vcpe_pppoe.c | 1 - 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/srcs/libs/config/agent.cfg b/srcs/libs/config/agent.cfg index 7dbb989..3856ac5 100644 --- a/srcs/libs/config/agent.cfg +++ b/srcs/libs/config/agent.cfg @@ -45,7 +45,7 @@ application: zero_mq: { svr_port = 6278; # ZeroMQ 服务器端口 - agent_addr = "ipc:///tmp/msg_fifo0"; # 消息通道路径 + agent_addr = "ipc:///tmp/msg_fifo1"; # 消息通道路径 }; # vxlan 相关 diff --git a/srcs/libs/mq/mq_data.c b/srcs/libs/mq/mq_data.c index 7af7950..1764fdc 100644 --- a/srcs/libs/mq/mq_data.c +++ b/srcs/libs/mq/mq_data.c @@ -14,6 +14,7 @@ #include "pppoe_info.h" #include "user_errno.h" #include "user_info.h" +#include "vxlan_pkg.h" #define AGENT_CMD_ADDUSER ("add-ywg-pppoe-vcpe") @@ -247,7 +248,6 @@ static void process_data_msg(void *UNUSED(pDataCh), zmq_msg_t *pMsg) { PADD_INFO pInfo = &(p->pInfo[m]); for (n = 0; n < pInfo->userCount; n++) { PADD_USER_USER pUser = &(pInfo->pUser[n]); -#if 1 USER_PARAMS userInfo; memset(&userInfo, 0, sizeof(USER_PARAMS)); @@ -259,8 +259,8 @@ static void process_data_msg(void *UNUSED(pDataCh), zmq_msg_t *pMsg) { userInfo.q1 = pUser->c_tag_in; userInfo.q2 = pUser->s_tag_in; str_to_mac(pUser->clientMac, userInfo.mac_addr); + vxlan_peer_add(pUser->vni, pInfo->vxlan.vsvxlanIP, pInfo->vxlan.vsvxlanMac); user_info_add(userInfo.userid, &userInfo); -#endif } } free_add_user(p); diff --git a/srcs/lwip/src/arch_linux/netif/pcapif.c b/srcs/lwip/src/arch_linux/netif/pcapif.c index e66a603..af70fec 100644 --- a/srcs/lwip/src/arch_linux/netif/pcapif.c +++ b/srcs/lwip/src/arch_linux/netif/pcapif.c @@ -143,7 +143,7 @@ static void pcap_pkg_cb(unsigned char *args, const struct pcap_pkthdr *pkthdr, c } /*-----------------------------------------------------------------------------------*/ static void low_level_init(struct netif *netif) { - struct pcapif *pcapif = (struct pcapif *)netif->state; + struct pcapif *pcapif = (struct pcapif *)netif->state; /* Obtain MAC address from network interface. */ @@ -197,15 +197,14 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) { if (pBuf && outSize != 0) { written = pcap_inject(pcapif->pcap, pBuf, outSize); + free(pBuf); + + return written == (outSize) ? ERR_OK : ERR_IF; } - - free(pBuf); - - return written == (outSize) ? ERR_OK : ERR_IF; - } else { - written = pcap_inject(pcapif->pcap, buf, p->tot_len); - return (written == p->tot_len) ? ERR_OK : ERR_IF; } + + written = pcap_inject(pcapif->pcap, buf, p->tot_len); + return (written == p->tot_len) ? ERR_OK : ERR_IF; } err_t pcapif_output(struct netif *netif, struct pbuf *p) { @@ -309,7 +308,8 @@ static void link_callback(struct netif *state_netif) { #endif /* LWIP_NETIF_LINK_CALLBACK */ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { - err_t err = ERR_OK; + err_t err = ERR_OK; + struct netif *netif; struct pcapif *pcapif = (struct pcapif *)inp->state; const unsigned char *pBuf = (const unsigned char *)p->payload; @@ -331,9 +331,9 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { if (ebuf == NULL) { return ERR_IF; } else { - struct eth_hdr* eth = (struct eth_hdr*)ebuf->payload; + struct eth_hdr *eth = (struct eth_hdr *)ebuf->payload; - if(strlen(pContext->session.data.svrBaseMac) == 0) { + if (strlen(pContext->session.data.svrBaseMac) == 0) { if (strlen(pContext->session.data.svrBaseMac) == 0) { sprintf(pContext->session.data.svrBaseMac, "%02X:%02X:%02X:%02X:%02X:%02X", @@ -354,18 +354,17 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { pbuf_free(p); return err; } - } else { - struct netif *netif; - 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) { - LWIP_DEBUGF(NETIF_DEBUG, ("pppoeif_input: netif input error\n")); - pbuf_free(p); - } + NETIF_FOREACH(netif) { + if (netif->hwaddr_len == 6 && memcmp(p->payload, netif->hwaddr, netif->hwaddr_len) == 0) { - return err; + if ((err = netif->input(p, netif)) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("pppoeif_input: netif input error\n")); + pbuf_free(p); } + + return err; } } diff --git a/srcs/pppoe/vcpe_pppoe.c b/srcs/pppoe/vcpe_pppoe.c index 1ca4280..4b4e67b 100644 --- a/srcs/pppoe/vcpe_pppoe.c +++ b/srcs/pppoe/vcpe_pppoe.c @@ -145,7 +145,6 @@ _Noreturn void sessionCalcCb(void *UNUSED(pArg)) { case STATUS_TASK_INIT: if (pppoe_session_create(pUser) == ERR_SUCCESS) { dzlog_debug("User(%05d:%s) init pppoe session\n", pUser->userid, pUser->user_info.pppoe_user); - vxlan_peer_add(pUser->vxlan.vni, config_get_vxlan_peer_ip(), config_get_vxlan_peer_mac()); pSession->status = STATUS_TASK_DIAL; } break;