summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHanhui <sylixos@gmail.com>2019-04-08 15:52:23 (GMT)
committer Hanhui <sylixos@gmail.com>2019-03-07 12:37:36 (GMT)
commit750c0e8eac386a8fa9198a791a1ac204a1fe383f (patch)
treed48339137228acf1947439b98801cfcc91398658
parent4edf7c6bc7b67f65a435fbbb0ee46a998e47ff96 (diff)
downloadAIC-OS-750c0e8eac386a8fa9198a791a1ac204a1fe383f.zip
Fixed network driver statistical risk.
-rw-r--r--SylixOS/driver/net/dm9000.c6
-rw-r--r--SylixOS/driver/net/smethnd.c4
-rw-r--r--SylixOS/net/lwip/bonding/netbonding.c5
-rw-r--r--SylixOS/net/lwip/bridge/netbridge.c5
-rw-r--r--SylixOS/net/lwip/netdev/vnetdev.c3
5 files changed, 15 insertions, 8 deletions
diff --git a/SylixOS/driver/net/dm9000.c b/SylixOS/driver/net/dm9000.c
index 15f9f83..0edee26 100644
--- a/SylixOS/driver/net/dm9000.c
+++ b/SylixOS/driver/net/dm9000.c
@@ -808,6 +808,7 @@ static void dm9000_receive (struct netdev *netdev, int (*input)(struct netdev *
UINT8 rx_byte;
UINT16 rx_len;
UINT16 rx_status;
+ int mcast;
int good_pkt;
int err;
@@ -863,7 +864,8 @@ static void dm9000_receive (struct netdev *netdev, int (*input)(struct netdev *
(priv->inblk)(dm9000, q->payload, q->len);
}
- err = input(netdev, p);
+ mcast = ((UINT8 *)p->payload)[0] & 1;
+ err = input(netdev, p);
if (err) {
netdev_pbuf_free(p);
p = NULL;
@@ -874,7 +876,7 @@ static void dm9000_receive (struct netdev *netdev, int (*input)(struct netdev *
} else {
netdev_linkinfo_recv_inc(netdev);
netdev_statinfo_total_add(netdev, LINK_INPUT, rx_len);
- if (((UINT8 *)p->payload)[0] & 1) {
+ if (mcast) {
netdev_statinfo_mcasts_inc(netdev, LINK_INPUT);
} else {
netdev_statinfo_ucasts_inc(netdev, LINK_INPUT);
diff --git a/SylixOS/driver/net/smethnd.c b/SylixOS/driver/net/smethnd.c
index 68dcc8b..df6065d 100644
--- a/SylixOS/driver/net/smethnd.c
+++ b/SylixOS/driver/net/smethnd.c
@@ -257,6 +257,7 @@ static void smethnd_receive (struct netdev *netdev, int (*input)(struct netdev
addr_t packet_base;
size_t offset;
struct pbuf *p, *q;
+ int mcast;
if (!config->block_msg) {
return;
@@ -280,6 +281,7 @@ static void smethnd_receive (struct netdev *netdev, int (*input)(struct netdev
offset += q->len;
}
+ mcast = ((UINT8 *)p->payload)[0] & 1;
if (input(netdev, p)) {
netdev_pbuf_free(p);
p = NULL;
@@ -290,7 +292,7 @@ static void smethnd_receive (struct netdev *netdev, int (*input)(struct netdev
} else {
netdev_linkinfo_recv_inc(netdev);
netdev_statinfo_total_add(netdev, LINK_INPUT, packet->len);
- if (((UINT8 *)p->payload)[0] & 1) {
+ if (mcast) {
netdev_statinfo_mcasts_inc(netdev, LINK_INPUT);
} else {
netdev_statinfo_ucasts_inc(netdev, LINK_INPUT);
diff --git a/SylixOS/net/lwip/bonding/netbonding.c b/SylixOS/net/lwip/bonding/netbonding.c
index dd0e143..db7ec9a 100644
--- a/SylixOS/net/lwip/bonding/netbonding.c
+++ b/SylixOS/net/lwip/bonding/netbonding.c
@@ -331,6 +331,7 @@ static err_t netbd_input (struct pbuf *p, struct netif *netif)
netbd_t *netbd = (netbd_t *)netdev_bd->priv;
struct netif *netif_bd = (struct netif *)netdev_bd->sys;
struct eth_hdr *eh = (struct eth_hdr *)p->payload;
+ int mcast = eh->dest.addr[0] & 1;
if (netdev->init_flags & NETDEV_INIT_TIGHT) {
u16_t type;
@@ -367,7 +368,7 @@ to_sub:
} else {
netdev_linkinfo_recv_inc(netdev);
netdev_statinfo_total_add(netdev, LINK_INPUT, (p->tot_len - ETH_PAD_SIZE));
- if (eh->dest.addr[0] & 1) {
+ if (mcast) {
netdev_statinfo_mcasts_inc(netdev, LINK_INPUT);
} else {
netdev_statinfo_ucasts_inc(netdev, LINK_INPUT);
@@ -423,7 +424,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));
- if (eh->dest.addr[0] & 1) {
+ if (mcast) {
netdev_statinfo_mcasts_inc(netdev_bd, LINK_INPUT);
} else {
netdev_statinfo_ucasts_inc(netdev_bd, LINK_INPUT);
diff --git a/SylixOS/net/lwip/bridge/netbridge.c b/SylixOS/net/lwip/bridge/netbridge.c
index cd5b442..3d0724a 100644
--- a/SylixOS/net/lwip/bridge/netbridge.c
+++ b/SylixOS/net/lwip/bridge/netbridge.c
@@ -163,6 +163,7 @@ static err_t netbr_input (struct pbuf *p, struct netif *netif)
netbr_mcache_t *mac;
LW_LIST_LINE *pline;
struct eth_hdr *eh = (struct eth_hdr *)p->payload;
+ int mcast = eh->dest.addr[0] & 1;
SYS_ARCH_DECL_PROTECT(lev);
@@ -201,7 +202,7 @@ to_sub:
} else {
netdev_linkinfo_recv_inc(netdev);
netdev_statinfo_total_add(netdev, LINK_INPUT, (p->tot_len - ETH_PAD_SIZE));
- if (eh->dest.addr[0] & 1) {
+ if (mcast) {
netdev_statinfo_mcasts_inc(netdev, LINK_INPUT);
} else {
netdev_statinfo_ucasts_inc(netdev, LINK_INPUT);
@@ -303,7 +304,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));
- if (eh->dest.addr[0] & 1) {
+ if (mcast) {
netdev_statinfo_mcasts_inc(netdev_br, LINK_INPUT);
} else {
netdev_statinfo_ucasts_inc(netdev_br, LINK_INPUT);
diff --git a/SylixOS/net/lwip/netdev/vnetdev.c b/SylixOS/net/lwip/netdev/vnetdev.c
index e09285c..22484a8 100644
--- a/SylixOS/net/lwip/netdev/vnetdev.c
+++ b/SylixOS/net/lwip/netdev/vnetdev.c
@@ -261,6 +261,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;
if (!netif_is_link_up(netif)) {
return (-1);
@@ -282,7 +283,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);
- if (((UINT8 *)p->payload)[0] & 1) {
+ if (mcast) {
netdev_statinfo_mcasts_inc(netdev, LINK_INPUT);
} else {
netdev_statinfo_ucasts_inc(netdev, LINK_INPUT);