Commit 583d5333 authored by Xie He's avatar Xie He Committed by Jakub Kicinski

net: hdlc_fr: Simpify fr_rx by using "goto rx_drop" to drop frames

When the fr_rx function drops a received frame (because the protocol type
is not supported, or because the PVC virtual device that corresponds to
the DLCI number and the protocol type doesn't exist), the function frees
the skb and returns.

The code for freeing the skb and returning is repeated several times, this
patch uses "goto rx_drop" to replace them so that the code looks cleaner.

Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Signed-off-by: default avatarXie He <xie.he.0141@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 16b5f5ce
...@@ -904,8 +904,7 @@ static int fr_rx(struct sk_buff *skb) ...@@ -904,8 +904,7 @@ static int fr_rx(struct sk_buff *skb)
netdev_info(frad, "No PVC for received frame's DLCI %d\n", netdev_info(frad, "No PVC for received frame's DLCI %d\n",
dlci); dlci);
#endif #endif
dev_kfree_skb_any(skb); goto rx_drop;
return NET_RX_DROP;
} }
if (pvc->state.fecn != fh->fecn) { if (pvc->state.fecn != fh->fecn) {
...@@ -963,14 +962,12 @@ static int fr_rx(struct sk_buff *skb) ...@@ -963,14 +962,12 @@ static int fr_rx(struct sk_buff *skb)
default: default:
netdev_info(frad, "Unsupported protocol, OUI=%x PID=%x\n", netdev_info(frad, "Unsupported protocol, OUI=%x PID=%x\n",
oui, pid); oui, pid);
dev_kfree_skb_any(skb); goto rx_drop;
return NET_RX_DROP;
} }
} else { } else {
netdev_info(frad, "Unsupported protocol, NLPID=%x length=%i\n", netdev_info(frad, "Unsupported protocol, NLPID=%x length=%i\n",
data[3], skb->len); data[3], skb->len);
dev_kfree_skb_any(skb); goto rx_drop;
return NET_RX_DROP;
} }
if (dev) { if (dev) {
...@@ -982,12 +979,12 @@ static int fr_rx(struct sk_buff *skb) ...@@ -982,12 +979,12 @@ static int fr_rx(struct sk_buff *skb)
netif_rx(skb); netif_rx(skb);
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
} else { } else {
dev_kfree_skb_any(skb); goto rx_drop;
return NET_RX_DROP;
} }
rx_error: rx_error:
frad->stats.rx_errors++; /* Mark error */ frad->stats.rx_errors++; /* Mark error */
rx_drop:
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
return NET_RX_DROP; return NET_RX_DROP;
} }
......
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