summaryrefslogtreecommitdiffstatsabout
path: root/SylixOS
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2020-09-26 01:11:56 (GMT)
committer Hanhui <hanhui@acoinfo.com>2020-09-26 01:11:56 (GMT)
commit8be77112f396363a45f1250dbb16881cb627da98 (patch)
treeda25f230e7751af41916590f8a4a1e2757dfac41 /SylixOS
parent2aff4fd5086d4cad4d23bc9be22e6ce77402d84a (diff)
downloadlibsylixos-8be77112f396363a45f1250dbb16881cb627da98.zip
libsylixos-8be77112f396363a45f1250dbb16881cb627da98.tar.gz
libsylixos-8be77112f396363a45f1250dbb16881cb627da98.tar.bz2
Fixed bridge and bound network firewall error.
Diffstat (limited to 'SylixOS')
-rw-r--r--SylixOS/include/network/lwip/netif.h4
-rw-r--r--SylixOS/kernel/include/k_kernel.h2
-rw-r--r--SylixOS/net/lwip/bonding/netbonding.c12
-rw-r--r--SylixOS/net/lwip/bridge/netbridge.c13
-rw-r--r--SylixOS/net/lwip/lwip_config.h8
-rw-r--r--SylixOS/net/lwip/lwip_fix.c6
-rw-r--r--SylixOS/net/lwip/netdev/netdev.c5
-rw-r--r--SylixOS/net/lwip/src/core/netif.c4
-rw-r--r--SylixOS/net/lwip/src/netif/ppp/pppoe.c24
9 files changed, 65 insertions, 13 deletions
diff --git a/SylixOS/include/network/lwip/netif.h b/SylixOS/include/network/lwip/netif.h
index 4eca9c2..95c753d 100644
--- a/SylixOS/include/network/lwip/netif.h
+++ b/SylixOS/include/network/lwip/netif.h
@@ -416,6 +416,7 @@ struct netif {
int priv_flags;
void *ext_eth; /* net bridge or bonding or ... eth node */
void *ext_ctl; /* net bridge or bonding or ... ctl block */
+ struct netif *ext_inp; /* net bridge or bonding netif */
void *flowctl; /* net flow ctl */
u16_t vlanid; /* include tag & pri */
int metric; /* netif metric (NOT support now) */
@@ -432,6 +433,9 @@ struct netif {
u8_t nat_mode;
/* ARPHRD_xxx */
u16_t ar_hrd;
+#if PPP_SUPPORT
+ u32_t ppp_ref; /* PPP reference count */
+#endif
#if LW_CFG_LWIP_DNS_SWITCH > 0
ip_addr_t dns_save[DNS_MAX_SERVERS];
#endif /* LW_CFG_LWIP_DNS_SWITCH */
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index c429bad..976bdfe 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -53,7 +53,7 @@
#define __SYLIXOS_MAJOR_VER 2
#define __SYLIXOS_MINOR_VER 0
-#define __SYLIXOS_PATCH_VER 0
+#define __SYLIXOS_PATCH_VER 1
#define __SYLIXOS_PATCH_PAD 0
/*********************************************************************************************************
diff --git a/SylixOS/net/lwip/bonding/netbonding.c b/SylixOS/net/lwip/bonding/netbonding.c
index a82874a..41c5006 100644
--- a/SylixOS/net/lwip/bonding/netbonding.c
+++ b/SylixOS/net/lwip/bonding/netbonding.c
@@ -461,6 +461,7 @@ static int netbd_rxmode (struct netdev *netdev, int flags)
'netif' is sub erhernet device */
static err_t netbd_input (struct pbuf *p, struct netif *netif)
{
+ int pppoe = 0;
netdev_t *netdev = (netdev_t *)(netif->state); /* sub ethernet device */
netbd_eth_t *netbd_eth = (netbd_eth_t *)netif->ext_eth;
netdev_t *netdev_bd = netbd_eth->netdev_bd; /* bonding device */
@@ -484,10 +485,11 @@ static err_t netbd_input (struct pbuf *p, struct netif *netif)
type = vlan->tpid;
}
switch (type) {
- case PP_HTONS(ETHTYPE_ARP):
- case PP_HTONS(ETHTYPE_RARP):
case PP_HTONS(ETHTYPE_PPPOE):
case PP_HTONS(ETHTYPE_PPPOEDISC):
+ pppoe = 1;
+ case PP_HTONS(ETHTYPE_ARP):
+ case PP_HTONS(ETHTYPE_RARP):
case PP_HTONS(ETHTYPE_IP):
case PP_HTONS(ETHTYPE_IPV6):
goto to_bd;
@@ -515,7 +517,7 @@ to_sub:
}
to_bd:
- if (!(netif_bd->flags & NETIF_FLAG_UP)) {
+ if (!(netif_bd->flags & NETIF_FLAG_UP) && !pppoe) {
return (ERR_IF); /* bonding was down */
}
@@ -731,6 +733,7 @@ int netbd_add_dev (const char *bddev, int bdindex, const char *sub, int sub_is_
netif->input = netbd_input; /* set new input function */
netif->ext_eth = (void *)netbd_eth;
netif->ext_ctl = (void *)netbd;
+ netif->ext_inp = (struct netif *)(netbd->netdev_bd.sys);
if (need_up) {
netifapi_netif_set_up(netif_bd); /* make bonding up */
@@ -861,6 +864,7 @@ int netbd_delete_dev (const char *bddev, int bdindex, const char *sub, int sub_
netif->input = netbd_eth->input; /* restore old input function */
netif->ext_ctl = netif->ext_eth = NULL;
+ netif->ext_inp = NULL;
NETBD_LOCK(netbd);
if (netbd->master == netbd_eth) {
@@ -1285,6 +1289,7 @@ int netbd_delete (const char *bddev, int bdindex)
netif->input = netbd_eth->input; /* restore input function */
netif->ext_ctl = netif->ext_eth = NULL;
+ netif->ext_inp = NULL;
mem_free(netbd_eth);
@@ -1452,6 +1457,7 @@ void netbd_sub_delete_hook (netdev_t *netdev)
netif->input = netbd_eth->input; /* restore old input function */
netif->ext_ctl = netif->ext_eth = NULL;
+ netif->ext_inp = NULL;
mem_free(netbd_eth);
}
diff --git a/SylixOS/net/lwip/bridge/netbridge.c b/SylixOS/net/lwip/bridge/netbridge.c
index 3aea2fb..dd0082a 100644
--- a/SylixOS/net/lwip/bridge/netbridge.c
+++ b/SylixOS/net/lwip/bridge/netbridge.c
@@ -157,7 +157,7 @@ static int netbr_rxmode (struct netdev *netdev, int flags)
'netif' is sub erhernet device */
static err_t netbr_input (struct pbuf *p, struct netif *netif)
{
- int found, key;
+ int found, key, pppoe = 0;
netdev_t *netdev = (netdev_t *)(netif->state); /* sub ethernet device */
netbr_eth_t *netbr_eth = (netbr_eth_t *)netif->ext_eth;
netdev_t *netdev_br = netbr_eth->netdev_br; /* bridge device */
@@ -184,10 +184,11 @@ static err_t netbr_input (struct pbuf *p, struct netif *netif)
type = vlan->tpid;
}
switch (type) {
- case PP_HTONS(ETHTYPE_ARP):
- case PP_HTONS(ETHTYPE_RARP):
case PP_HTONS(ETHTYPE_PPPOE):
case PP_HTONS(ETHTYPE_PPPOEDISC):
+ pppoe = 1;
+ case PP_HTONS(ETHTYPE_ARP):
+ case PP_HTONS(ETHTYPE_RARP):
case PP_HTONS(ETHTYPE_IP):
case PP_HTONS(ETHTYPE_IPV6):
goto to_br;
@@ -215,7 +216,7 @@ to_sub:
}
to_br:
- if (!(netif_br->flags & NETIF_FLAG_UP)) {
+ if (!(netif_br->flags & NETIF_FLAG_UP) && !pppoe) {
return (ERR_IF); /* bridge was down */
}
@@ -444,6 +445,7 @@ int netbr_add_dev (const char *brdev, int brindex, const char *sub, int sub_is_
netif->input = netbr_input; /* set new input function */
netif->ext_eth = (void *)netbr_eth;
netif->ext_ctl = (void *)netbr;
+ netif->ext_inp = (struct netif *)(netbr->netdev_br.sys);
if (need_up) {
netifapi_netif_set_up(netif_br); /* make bridge up */
@@ -562,6 +564,7 @@ int netbr_delete_dev (const char *brdev, int brindex, const char *sub, int sub_
netif->input = netbr_eth->input; /* restore old input function */
netif->ext_ctl = netif->ext_eth = NULL;
+ netif->ext_inp = NULL;
NETBR_LOCK(netbr);
_List_Line_Del(&netbr_eth->list, &netbr->eth_list);
@@ -727,6 +730,7 @@ int netbr_delete (const char *brdev, int brindex)
netif->input = netbr_eth->input; /* restore input function */
netif->ext_ctl = netif->ext_eth = NULL;
+ netif->ext_inp = NULL;
mem_free(netbr_eth);
@@ -852,6 +856,7 @@ void netbr_sub_delete_hook (netdev_t *netdev)
netif->input = netbr_eth->input; /* restore old input function */
netif->ext_ctl = netif->ext_eth = NULL;
+ netif->ext_inp = NULL;
mem_free(netbr_eth);
}
diff --git a/SylixOS/net/lwip/lwip_config.h b/SylixOS/net/lwip/lwip_config.h
index 6829871..79ee642 100644
--- a/SylixOS/net/lwip/lwip_config.h
+++ b/SylixOS/net/lwip/lwip_config.h
@@ -646,14 +646,16 @@ extern INT __inetHostTableGetItem(CPCHAR pcHost, size_t stLen, PVOID pvAddr,
#define MSCHAP_SUPPORT 0
#endif /* __LWIP_USE_PPP_NEW > 0 */
+#define MPPE_SUPPORT 1
#define EAP_SUPPORT 1
-#define CBCP_SUPPORT 0
-#define CCP_SUPPORT 0
-#define ECP_SUPPORT 0
+#define CCP_SUPPORT 1
#define LQR_SUPPORT 1
#define VJ_SUPPORT 1
#define MD5_SUPPORT 1
+#define CBCP_SUPPORT 0 /* NOT SUPPORT NOW! */
+#define ECP_SUPPORT 0
+
#define PPP_MD5_RANDM 1
#define PPP_IPV6_SUPPORT LWIP_IPV6
diff --git a/SylixOS/net/lwip/lwip_fix.c b/SylixOS/net/lwip/lwip_fix.c
index 4f9b6c5..ce7e0c2 100644
--- a/SylixOS/net/lwip/lwip_fix.c
+++ b/SylixOS/net/lwip/lwip_fix.c
@@ -1406,7 +1406,11 @@ int link_input_hook (struct pbuf *p, struct netif *pnetif)
{
extern INT packet_link_input(struct pbuf *p, struct netif *inp, BOOL bOutgo);
- if (!netif_is_up(pnetif)) {
+ if (LW_UNLIKELY(!netif_is_up(pnetif)
+#if PPP_SUPPORT
+ && !pnetif->ppp_ref
+#endif /* PPP_SUPPORT */
+ )) {
return (1); /* 没有使能的网卡不接收 */
}
diff --git a/SylixOS/net/lwip/netdev/netdev.c b/SylixOS/net/lwip/netdev/netdev.c
index e09b064..28084ec 100644
--- a/SylixOS/net/lwip/netdev/netdev.c
+++ b/SylixOS/net/lwip/netdev/netdev.c
@@ -480,6 +480,7 @@ static int netdev_netif_linkinput (netdev_t *netdev, struct pbuf *p)
{
err_t err;
struct netif *netif = (struct netif *)netdev->sys;
+ struct netif *inpfw;
struct eth_hdr *eh;
/* fixed pad */
@@ -502,7 +503,9 @@ static int netdev_netif_linkinput (netdev_t *netdev, struct pbuf *p)
}
}
- if (netif->inner_fw && netif->inner_fw(netif, p)) {
+ inpfw = netif->ext_inp ? netif->ext_inp : netif;
+
+ if (inpfw->inner_fw && inpfw->inner_fw(inpfw, p)) {
return (0); /* inner firewall eaten */
}
diff --git a/SylixOS/net/lwip/src/core/netif.c b/SylixOS/net/lwip/src/core/netif.c
index d56d15e..279e174 100644
--- a/SylixOS/net/lwip/src/core/netif.c
+++ b/SylixOS/net/lwip/src/core/netif.c
@@ -389,6 +389,7 @@ netif_add(struct netif *netif,
netif->priv_flags = 0;
netif->ext_eth = NULL;
netif->ext_ctl = NULL;
+ netif->ext_inp = NULL;
netif->flowctl = NULL;
netif->vlanid = (u16_t)-1;
netif->metric = 1;
@@ -398,6 +399,9 @@ netif_add(struct netif *netif,
netif->masterif = NULL;
netif->nat_mode = NETIF_NAT_NONE;
netif->ar_hrd = 0xffff;
+#if PPP_SUPPORT
+ netif->ppp_ref = 0;
+#endif /* PPP_SUPPORT */
#if LW_CFG_LWIP_DNS_SWITCH > 0
lib_bzero(netif->dns_save, sizeof(netif->dns_save));
#endif /* LW_CFG_LWIP_DNS_SWITCH */
diff --git a/SylixOS/net/lwip/src/netif/ppp/pppoe.c b/SylixOS/net/lwip/src/netif/ppp/pppoe.c
index 6e90c86..de16451 100644
--- a/SylixOS/net/lwip/src/netif/ppp/pppoe.c
+++ b/SylixOS/net/lwip/src/netif/ppp/pppoe.c
@@ -195,6 +195,11 @@ ppp_pcb *pppoe_create(struct netif *pppif,
memset(sc, 0, sizeof(struct pppoe_softc));
sc->pcb = ppp;
sc->sc_ethif = ethif;
+#ifdef SYLIXOS /* SylixOS process pppoe count */
+ if (ethif) {
+ ethif->ppp_ref++;
+ }
+#endif /* SYLIXOS */
#if PPPOE_SCNAME_SUPPORT
sc->sc_service_name = service_name;
sc->sc_concentrator_name = concentrator_name;
@@ -299,6 +304,14 @@ pppoe_destroy(ppp_pcb *ppp, void *ctx)
sys_untimeout(pppoe_timeout, sc);
+#ifdef SYLIXOS /* SylixOS process pppoe count */
+ if (sc->sc_ethif) {
+ if (sc->sc_ethif->ppp_ref) {
+ sc->sc_ethif->ppp_ref--;
+ }
+ }
+#endif /* SYLIXOS */
+
/* remove interface from list */
for (copp = &pppoe_softc_list; (freep = *copp); copp = &freep->next) {
if (freep == sc) {
@@ -769,6 +782,11 @@ pppoe_send_padi(struct pppoe_softc *sc)
l2 = (int)strlen(sc->sc_concentrator_name);
len += 2 + 2 + l2;
}
+#ifdef SYLIXOS /* SylixOS Add empty AC name */
+ else {
+ len += 2 + 2;
+ }
+#endif /* SYLIXOS */
#endif /* PPPOE_SCNAME_SUPPORT */
LWIP_ASSERT("sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff",
sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len <= 0xffff);
@@ -801,6 +819,12 @@ pppoe_send_padi(struct pppoe_softc *sc)
MEMCPY(p, sc->sc_concentrator_name, l2);
p += l2;
}
+#ifdef SYLIXOS /* SylixOS Add empty AC name */
+ else {
+ PPPOE_ADD_16(p, PPPOE_TAG_ACNAME);
+ PPPOE_ADD_16(p, 0);
+ }
+#endif /* SYLIXOS */
#endif /* PPPOE_SCNAME_SUPPORT */
PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
PPPOE_ADD_16(p, sizeof(sc));