summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHanhui <hanhui@acoinfo.com>2021-06-11 14:35:09 (GMT)
committer Hanhui <hanhui@acoinfo.com>2021-06-11 14:35:09 (GMT)
commit405051e3fca492b1010dd369186f645693f3b69d (patch)
tree77e3eb98ff9f602f2a38ec4092a21c27b7c2c47e
parent3995fe529009e4efab9c416b1df7418f9841ea50 (diff)
downloadlibsylixos-405051e3fca492b1010dd369186f645693f3b69d.zip
libsylixos-405051e3fca492b1010dd369186f645693f3b69d.tar.gz
libsylixos-405051e3fca492b1010dd369186f645693f3b69d.tar.bz2
Fixed bridge and bonding network statistical information race risk.
-rw-r--r--SylixOS/net/lwip/bonding/netbonding.c7
-rw-r--r--SylixOS/net/lwip/bridge/netbridge.c7
-rw-r--r--SylixOS/net/lwip/netdev/vnetdev.c4
-rw-r--r--SylixOS/system/ioLib/ioSys.c2
4 files changed, 14 insertions, 6 deletions
diff --git a/SylixOS/net/lwip/bonding/netbonding.c b/SylixOS/net/lwip/bonding/netbonding.c
index caaf907..9c889eb 100644
--- a/SylixOS/net/lwip/bonding/netbonding.c
+++ b/SylixOS/net/lwip/bonding/netbonding.c
@@ -462,6 +462,7 @@ static int netbd_rxmode (struct netdev *netdev, int flags)
static err_t netbd_input (struct pbuf *p, struct netif *netif)
{
int pppoe = 0;
+ u32_t length;
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 */
@@ -499,6 +500,7 @@ static err_t netbd_input (struct pbuf *p, struct netif *netif)
}
to_sub:
+ length = p->tot_len - ETH_PAD_SIZE;
if (netbd_eth->input(p, netif)) {
netdev_linkinfo_drop_inc(netdev);
netdev_statinfo_discards_inc(netdev, LINK_INPUT);
@@ -506,7 +508,7 @@ to_sub:
} else {
netdev_linkinfo_recv_inc(netdev);
- netdev_statinfo_total_add(netdev, LINK_INPUT, (p->tot_len - ETH_PAD_SIZE));
+ netdev_statinfo_total_add(netdev, LINK_INPUT, length);
if (mcast) {
netdev_statinfo_mcasts_inc(netdev, LINK_INPUT);
} else {
@@ -568,6 +570,7 @@ input: /* TODO: this function may be parallelization, and statistical variables
}
}
+ length = p->tot_len - ETH_PAD_SIZE;
if (netif_bd->input(p, netif_bd)) { /* send to our tcpip stack */
netdev_linkinfo_drop_inc(netdev_bd);
netdev_statinfo_discards_inc(netdev_bd, LINK_INPUT);
@@ -575,7 +578,7 @@ input: /* TODO: this function may be parallelization, and statistical variables
} else {
netdev_linkinfo_recv_inc(netdev_bd);
- netdev_statinfo_total_add(netdev_bd, LINK_INPUT, (p->tot_len - ETH_PAD_SIZE));
+ netdev_statinfo_total_add(netdev_bd, LINK_INPUT, length);
if (mcast) {
netdev_statinfo_mcasts_inc(netdev_bd, LINK_INPUT);
} else {
diff --git a/SylixOS/net/lwip/bridge/netbridge.c b/SylixOS/net/lwip/bridge/netbridge.c
index 563b2e7..2b932f7 100644
--- a/SylixOS/net/lwip/bridge/netbridge.c
+++ b/SylixOS/net/lwip/bridge/netbridge.c
@@ -165,6 +165,7 @@ static int netbr_rxmode (struct netdev *netdev, int flags)
static err_t netbr_input (struct pbuf *p, struct netif *netif)
{
int found, key, pppoe = 0;
+ u32_t length;
struct pbuf *q;
netdev_t *netdev = (netdev_t *)(netif->state); /* sub ethernet device */
netbr_eth_t *netbr_eth = (netbr_eth_t *)netif->ext_eth;
@@ -206,6 +207,7 @@ static err_t netbr_input (struct pbuf *p, struct netif *netif)
}
to_sub:
+ length = p->tot_len - ETH_PAD_SIZE;
if (netbr_eth->input(p, netif)) {
netdev_linkinfo_drop_inc(netdev);
netdev_statinfo_discards_inc(netdev, LINK_INPUT);
@@ -213,7 +215,7 @@ to_sub:
} else {
netdev_linkinfo_recv_inc(netdev);
- netdev_statinfo_total_add(netdev, LINK_INPUT, (p->tot_len - ETH_PAD_SIZE));
+ netdev_statinfo_total_add(netdev, LINK_INPUT, length);
if (mcast) {
netdev_statinfo_mcasts_inc(netdev, LINK_INPUT);
} else {
@@ -316,6 +318,7 @@ to_br:
}
input_p: /* TODO: this function may be parallelization, and statistical variables should be locked */
+ length = p->tot_len - ETH_PAD_SIZE;
if (netif_br->input(p, netif_br)) { /* send to our tcpip stack */
netdev_linkinfo_drop_inc(netdev_br);
netdev_statinfo_discards_inc(netdev_br, LINK_INPUT);
@@ -323,7 +326,7 @@ input_p: /* TODO: this function may be parallelization, and statistical variable
} else {
netdev_linkinfo_recv_inc(netdev_br);
- netdev_statinfo_total_add(netdev_br, LINK_INPUT, (p->tot_len - ETH_PAD_SIZE));
+ netdev_statinfo_total_add(netdev_br, LINK_INPUT, length);
if (mcast) {
netdev_statinfo_mcasts_inc(netdev_br, LINK_INPUT);
} else {
diff --git a/SylixOS/net/lwip/netdev/vnetdev.c b/SylixOS/net/lwip/netdev/vnetdev.c
index 35a95b5..b37e8d9 100644
--- a/SylixOS/net/lwip/netdev/vnetdev.c
+++ b/SylixOS/net/lwip/netdev/vnetdev.c
@@ -284,6 +284,7 @@ int vnetdev_put (struct vnetdev *vnetdev, struct pbuf *p)
struct netdev *netdev = &vnetdev->netdev;
struct netif *netif = (struct netif *)netdev->sys;
int mcast = ((UINT8 *)p->payload)[0] & 1;
+ u32_t length;
if (!netif_is_link_up(netif)) {
return (-1);
@@ -297,6 +298,7 @@ int vnetdev_put (struct vnetdev *vnetdev, struct pbuf *p)
#endif
}
+ length = p->tot_len;
if (netif->input(p, netif)) {
netdev_linkinfo_drop_inc(netdev);
netdev_statinfo_discards_inc(netdev, LINK_INPUT);
@@ -304,7 +306,7 @@ int vnetdev_put (struct vnetdev *vnetdev, struct pbuf *p)
}
netdev_linkinfo_recv_inc(netdev);
- netdev_statinfo_total_add(netdev, LINK_INPUT, p->tot_len);
+ netdev_statinfo_total_add(netdev, LINK_INPUT, length);
if (mcast && (netdev->net_type == NETDEV_TYPE_ETHERNET)) {
netdev_statinfo_mcasts_inc(netdev, LINK_INPUT);
} else {
diff --git a/SylixOS/system/ioLib/ioSys.c b/SylixOS/system/ioLib/ioSys.c
index 4044972..88bbfb5 100644
--- a/SylixOS/system/ioLib/ioSys.c
+++ b/SylixOS/system/ioLib/ioSys.c
@@ -1339,7 +1339,7 @@ INT API_IosIoctl (INT iFd, INT iCmd, LONG lArg)
if (iCmd == FIOUNSELECT) { /* 这里可能是 unselect 之前关闭*/
return (PX_ERROR); /* 了文件, 不用打印错误 */
}
- _DebugFormat(__ERRORMESSAGE_LEVEL, "file descriptor invalidate: %d.\r\n", iFd);
+ _DebugFormat(__ERRORMESSAGE_LEVEL, "file descriptor %d invalid! command: %u.\r\n", iFd, iCmd);
_ErrorHandle(ERROR_IOS_INVALID_FILE_DESCRIPTOR);
}
return (PX_ERROR);