Commit 54709795 authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: remove out_drop label in taggers rcv

Many rcv functions from net/dsa/tag_*.c have a useless out_drop goto
label which simply returns NULL. Kill it in favor of the obvious.
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 717ffbfb
...@@ -104,27 +104,27 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -104,27 +104,27 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
ds = dst->cpu_dp->ds; ds = dst->cpu_dp->ds;
if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN))) if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN)))
goto out_drop; return NULL;
/* skb->data points to the EtherType, the tag is right before it */ /* skb->data points to the EtherType, the tag is right before it */
brcm_tag = skb->data - 2; brcm_tag = skb->data - 2;
/* The opcode should never be different than 0b000 */ /* The opcode should never be different than 0b000 */
if (unlikely((brcm_tag[0] >> BRCM_OPCODE_SHIFT) & BRCM_OPCODE_MASK)) if (unlikely((brcm_tag[0] >> BRCM_OPCODE_SHIFT) & BRCM_OPCODE_MASK))
goto out_drop; return NULL;
/* We should never see a reserved reason code without knowing how to /* We should never see a reserved reason code without knowing how to
* handle it * handle it
*/ */
if (unlikely(brcm_tag[2] & BRCM_EG_RC_RSVD)) if (unlikely(brcm_tag[2] & BRCM_EG_RC_RSVD))
goto out_drop; return NULL;
/* Locate which port this is coming from */ /* Locate which port this is coming from */
source_port = brcm_tag[3] & BRCM_EG_PID_MASK; source_port = brcm_tag[3] & BRCM_EG_PID_MASK;
/* Validate port against switch setup, either the port is totally */ /* Validate port against switch setup, either the port is totally */
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev) if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
goto out_drop; return NULL;
/* Remove Broadcom tag and update checksum */ /* Remove Broadcom tag and update checksum */
skb_pull_rcsum(skb, BRCM_TAG_LEN); skb_pull_rcsum(skb, BRCM_TAG_LEN);
...@@ -137,9 +137,6 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -137,9 +137,6 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
skb->dev = ds->ports[source_port].netdev; skb->dev = ds->ports[source_port].netdev;
return skb; return skb;
out_drop:
return NULL;
} }
const struct dsa_device_ops brcm_netdev_ops = { const struct dsa_device_ops brcm_netdev_ops = {
......
...@@ -79,7 +79,7 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -79,7 +79,7 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
int source_port; int source_port;
if (unlikely(!pskb_may_pull(skb, DSA_HLEN))) if (unlikely(!pskb_may_pull(skb, DSA_HLEN)))
goto out_drop; return NULL;
/* /*
* The ethertype field is part of the DSA header. * The ethertype field is part of the DSA header.
...@@ -90,7 +90,7 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -90,7 +90,7 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
* Check that frame type is either TO_CPU or FORWARD. * Check that frame type is either TO_CPU or FORWARD.
*/ */
if ((dsa_header[0] & 0xc0) != 0x00 && (dsa_header[0] & 0xc0) != 0xc0) if ((dsa_header[0] & 0xc0) != 0x00 && (dsa_header[0] & 0xc0) != 0xc0)
goto out_drop; return NULL;
/* /*
* Determine source device and port. * Determine source device and port.
...@@ -103,14 +103,14 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -103,14 +103,14 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
* port is a registered DSA port. * port is a registered DSA port.
*/ */
if (source_device >= DSA_MAX_SWITCHES) if (source_device >= DSA_MAX_SWITCHES)
goto out_drop; return NULL;
ds = dst->ds[source_device]; ds = dst->ds[source_device];
if (!ds) if (!ds)
goto out_drop; return NULL;
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev) if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
goto out_drop; return NULL;
/* /*
* Convert the DSA header to an 802.1q header if the 'tagged' * Convert the DSA header to an 802.1q header if the 'tagged'
...@@ -161,9 +161,6 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -161,9 +161,6 @@ static struct sk_buff *dsa_rcv(struct sk_buff *skb, struct net_device *dev,
skb->dev = ds->ports[source_port].netdev; skb->dev = ds->ports[source_port].netdev;
return skb; return skb;
out_drop:
return NULL;
} }
const struct dsa_device_ops dsa_netdev_ops = { const struct dsa_device_ops dsa_netdev_ops = {
......
...@@ -92,7 +92,7 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -92,7 +92,7 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
int source_port; int source_port;
if (unlikely(!pskb_may_pull(skb, EDSA_HLEN))) if (unlikely(!pskb_may_pull(skb, EDSA_HLEN)))
goto out_drop; return NULL;
/* /*
* Skip the two null bytes after the ethertype. * Skip the two null bytes after the ethertype.
...@@ -103,7 +103,7 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -103,7 +103,7 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
* Check that frame type is either TO_CPU or FORWARD. * Check that frame type is either TO_CPU or FORWARD.
*/ */
if ((edsa_header[0] & 0xc0) != 0x00 && (edsa_header[0] & 0xc0) != 0xc0) if ((edsa_header[0] & 0xc0) != 0x00 && (edsa_header[0] & 0xc0) != 0xc0)
goto out_drop; return NULL;
/* /*
* Determine source device and port. * Determine source device and port.
...@@ -116,14 +116,14 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -116,14 +116,14 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
* port is a registered DSA port. * port is a registered DSA port.
*/ */
if (source_device >= DSA_MAX_SWITCHES) if (source_device >= DSA_MAX_SWITCHES)
goto out_drop; return NULL;
ds = dst->ds[source_device]; ds = dst->ds[source_device];
if (!ds) if (!ds)
goto out_drop; return NULL;
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev) if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
goto out_drop; return NULL;
/* /*
* If the 'tagged' bit is set, convert the DSA tag to a 802.1q * If the 'tagged' bit is set, convert the DSA tag to a 802.1q
...@@ -180,9 +180,6 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -180,9 +180,6 @@ static struct sk_buff *edsa_rcv(struct sk_buff *skb, struct net_device *dev,
skb->dev = ds->ports[source_port].netdev; skb->dev = ds->ports[source_port].netdev;
return skb; return skb;
out_drop:
return NULL;
} }
const struct dsa_device_ops edsa_netdev_ops = { const struct dsa_device_ops edsa_netdev_ops = {
......
...@@ -57,7 +57,7 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -57,7 +57,7 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
__be16 *phdr, hdr; __be16 *phdr, hdr;
if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN)))
goto out_drop; return NULL;
/* The MTK header is added by the switch between src addr /* The MTK header is added by the switch between src addr
* and ethertype at this point, skb->data points to 2 bytes * and ethertype at this point, skb->data points to 2 bytes
...@@ -79,19 +79,16 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -79,19 +79,16 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
*/ */
ds = dst->ds[0]; ds = dst->ds[0];
if (!ds) if (!ds)
goto out_drop; return NULL;
/* Get source port information */ /* Get source port information */
port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK); port = (hdr & MTK_HDR_RECV_SOURCE_PORT_MASK);
if (!ds->ports[port].netdev) if (!ds->ports[port].netdev)
goto out_drop; return NULL;
skb->dev = ds->ports[port].netdev; skb->dev = ds->ports[port].netdev;
return skb; return skb;
out_drop:
return NULL;
} }
const struct dsa_device_ops mtk_netdev_ops = { const struct dsa_device_ops mtk_netdev_ops = {
......
...@@ -77,7 +77,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -77,7 +77,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
__be16 *phdr, hdr; __be16 *phdr, hdr;
if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN))) if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN)))
goto out_drop; return NULL;
/* The QCA header is added by the switch between src addr and Ethertype /* The QCA header is added by the switch between src addr and Ethertype
* At this point, skb->data points to ethertype so header should be * At this point, skb->data points to ethertype so header should be
...@@ -89,7 +89,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -89,7 +89,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
/* Make sure the version is correct */ /* Make sure the version is correct */
ver = (hdr & QCA_HDR_RECV_VERSION_MASK) >> QCA_HDR_RECV_VERSION_S; ver = (hdr & QCA_HDR_RECV_VERSION_MASK) >> QCA_HDR_RECV_VERSION_S;
if (unlikely(ver != QCA_HDR_VERSION)) if (unlikely(ver != QCA_HDR_VERSION))
goto out_drop; return NULL;
/* Remove QCA tag and recalculate checksum */ /* Remove QCA tag and recalculate checksum */
skb_pull_rcsum(skb, QCA_HDR_LEN); skb_pull_rcsum(skb, QCA_HDR_LEN);
...@@ -101,20 +101,17 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -101,20 +101,17 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
*/ */
ds = dst->cpu_dp->ds; ds = dst->cpu_dp->ds;
if (!ds) if (!ds)
goto out_drop; return NULL;
/* Get source port information */ /* Get source port information */
port = (hdr & QCA_HDR_RECV_SOURCE_PORT_MASK); port = (hdr & QCA_HDR_RECV_SOURCE_PORT_MASK);
if (!ds->ports[port].netdev) if (!ds->ports[port].netdev)
goto out_drop; return NULL;
/* Update skb & forward the frame accordingly */ /* Update skb & forward the frame accordingly */
skb->dev = ds->ports[port].netdev; skb->dev = ds->ports[port].netdev;
return skb; return skb;
out_drop:
return NULL;
} }
const struct dsa_device_ops qca_netdev_ops = { const struct dsa_device_ops qca_netdev_ops = {
......
...@@ -70,25 +70,22 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -70,25 +70,22 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
ds = dst->cpu_dp->ds; ds = dst->cpu_dp->ds;
if (skb_linearize(skb)) if (skb_linearize(skb))
goto out_drop; return NULL;
trailer = skb_tail_pointer(skb) - 4; trailer = skb_tail_pointer(skb) - 4;
if (trailer[0] != 0x80 || (trailer[1] & 0xf8) != 0x00 || if (trailer[0] != 0x80 || (trailer[1] & 0xf8) != 0x00 ||
(trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00) (trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00)
goto out_drop; return NULL;
source_port = trailer[1] & 7; source_port = trailer[1] & 7;
if (source_port >= ds->num_ports || !ds->ports[source_port].netdev) if (source_port >= ds->num_ports || !ds->ports[source_port].netdev)
goto out_drop; return NULL;
pskb_trim_rcsum(skb, skb->len - 4); pskb_trim_rcsum(skb, skb->len - 4);
skb->dev = ds->ports[source_port].netdev; skb->dev = ds->ports[source_port].netdev;
return skb; return skb;
out_drop:
return NULL;
} }
const struct dsa_device_ops trailer_netdev_ops = { const struct dsa_device_ops trailer_netdev_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment