Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drivers/net/wan/hdlc_fr: Improvements to the code of pvc_xmit

1. Keep the code for the normal (non-error) flow at the lowest
indentation level. And use "goto drop" for all error handling.

2. Replace code that pads short Ethernet frames with a "__skb_pad" call.

3. Change "dev_kfree_skb" to "kfree_skb" in error handling code.
"kfree_skb" is the correct function to call when dropping an skb due to
an error. "dev_kfree_skb", which is an alias of "consume_skb", is for
dropping skbs normally (not due to an error).

Cc: Krzysztof Halasa <khc@pm.waw.pl>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xie He and committed by
David S. Miller
f5083d0c 3e233cac

+26 -28
+26 -28
drivers/net/wan/hdlc_fr.c
··· 416 416 { 417 417 struct pvc_device *pvc = dev->ml_priv; 418 418 419 - if (pvc->state.active) { 420 - if (dev->type == ARPHRD_ETHER) { 421 - int pad = ETH_ZLEN - skb->len; 422 - if (pad > 0) { /* Pad the frame with zeros */ 423 - int len = skb->len; 424 - if (skb_tailroom(skb) < pad) 425 - if (pskb_expand_head(skb, 0, pad, 426 - GFP_ATOMIC)) { 427 - dev->stats.tx_dropped++; 428 - dev_kfree_skb(skb); 429 - return NETDEV_TX_OK; 430 - } 431 - skb_put(skb, pad); 432 - memset(skb->data + len, 0, pad); 433 - } 434 - } 435 - skb->dev = dev; 436 - if (!fr_hard_header(&skb, pvc->dlci)) { 437 - dev->stats.tx_bytes += skb->len; 438 - dev->stats.tx_packets++; 439 - if (pvc->state.fecn) /* TX Congestion counter */ 440 - dev->stats.tx_compressed++; 441 - skb->dev = pvc->frad; 442 - skb->protocol = htons(ETH_P_HDLC); 443 - skb_reset_network_header(skb); 444 - dev_queue_xmit(skb); 445 - return NETDEV_TX_OK; 419 + if (!pvc->state.active) 420 + goto drop; 421 + 422 + if (dev->type == ARPHRD_ETHER) { 423 + int pad = ETH_ZLEN - skb->len; 424 + 425 + if (pad > 0) { /* Pad the frame with zeros */ 426 + if (__skb_pad(skb, pad, false)) 427 + goto drop; 428 + skb_put(skb, pad); 446 429 } 447 430 } 448 431 432 + skb->dev = dev; 433 + if (fr_hard_header(&skb, pvc->dlci)) 434 + goto drop; 435 + 436 + dev->stats.tx_bytes += skb->len; 437 + dev->stats.tx_packets++; 438 + if (pvc->state.fecn) /* TX Congestion counter */ 439 + dev->stats.tx_compressed++; 440 + skb->dev = pvc->frad; 441 + skb->protocol = htons(ETH_P_HDLC); 442 + skb_reset_network_header(skb); 443 + dev_queue_xmit(skb); 444 + return NETDEV_TX_OK; 445 + 446 + drop: 449 447 dev->stats.tx_dropped++; 450 - dev_kfree_skb(skb); 448 + kfree_skb(skb); 451 449 return NETDEV_TX_OK; 452 450 } 453 451