Phonet: return an error when packet TX fails
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>
Tue, 8 Mar 2011 22:44:07 +0000 (22:44 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Mar 2011 19:59:30 +0000 (11:59 -0800)
Phonet assumes that packets are never dropped. We try our best to
avoid this situation. But lets return ENOBUFS if queueing to the
network device fails so that the caller knows things went wrong.

Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/phonet/af_phonet.c

index 4706b77e67bfce90532b2891616020735682d371..c6fffd946d42e4dc44b818a7b194b3a92274aa2e 100644 (file)
@@ -195,11 +195,7 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev,
        if (skb->pkt_type == PACKET_LOOPBACK) {
                skb_reset_mac_header(skb);
                skb_orphan(skb);
-               if (irq)
-                       netif_rx(skb);
-               else
-                       netif_rx_ni(skb);
-               err = 0;
+               err = (irq ? netif_rx(skb) : netif_rx_ni(skb)) ? -ENOBUFS : 0;
        } else {
                err = dev_hard_header(skb, dev, ntohs(skb->protocol),
                                        NULL, NULL, skb->len);
@@ -208,6 +204,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev,
                        goto drop;
                }
                err = dev_queue_xmit(skb);
+               if (unlikely(err > 0))
+                       err = net_xmit_errno(err);
        }
 
        return err;