aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet/af_packet.c
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2013-07-19 13:40:09 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-22 17:58:19 -0400
commitcb820f8e4b7f73d1a32175e6591735b25bb5398d (patch)
tree0a361e6465be4bd549c17d957708d2e280914f21 /net/packet/af_packet.c
parent0887a576a17965732270b2f8d37821fc02ef2feb (diff)
net: Provide a generic socket error queue delivery method for Tx time stamps.
This patch moves the private error queue delivery function from the af_packet code to the core socket method. In this way, network layers only needing the error queue for transmit time stamping can share common code. Signed-off-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r--net/packet/af_packet.c48
1 files changed, 2 insertions, 46 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4b66c752eae5..4cb28a7f639b 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2638,51 +2638,6 @@ out:
2638 return err; 2638 return err;
2639} 2639}
2640 2640
2641static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
2642{
2643 struct sock_exterr_skb *serr;
2644 struct sk_buff *skb, *skb2;
2645 int copied, err;
2646
2647 err = -EAGAIN;
2648 skb = skb_dequeue(&sk->sk_error_queue);
2649 if (skb == NULL)
2650 goto out;
2651
2652 copied = skb->len;
2653 if (copied > len) {
2654 msg->msg_flags |= MSG_TRUNC;
2655 copied = len;
2656 }
2657 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
2658 if (err)
2659 goto out_free_skb;
2660
2661 sock_recv_timestamp(msg, sk, skb);
2662
2663 serr = SKB_EXT_ERR(skb);
2664 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
2665 sizeof(serr->ee), &serr->ee);
2666
2667 msg->msg_flags |= MSG_ERRQUEUE;
2668 err = copied;
2669
2670 /* Reset and regenerate socket error */
2671 spin_lock_bh(&sk->sk_error_queue.lock);
2672 sk->sk_err = 0;
2673 if ((skb2 = skb_peek(&sk->sk_error_queue)) != NULL) {
2674 sk->sk_err = SKB_EXT_ERR(skb2)->ee.ee_errno;
2675 spin_unlock_bh(&sk->sk_error_queue.lock);
2676 sk->sk_error_report(sk);
2677 } else
2678 spin_unlock_bh(&sk->sk_error_queue.lock);
2679
2680out_free_skb:
2681 kfree_skb(skb);
2682out:
2683 return err;
2684}
2685
2686/* 2641/*
2687 * Pull a packet from our receive queue and hand it to the user. 2642 * Pull a packet from our receive queue and hand it to the user.
2688 * If necessary we block. 2643 * If necessary we block.
@@ -2708,7 +2663,8 @@ static int packet_recvmsg(struct kiocb *iocb, struct socket *sock,
2708#endif 2663#endif
2709 2664
2710 if (flags & MSG_ERRQUEUE) { 2665 if (flags & MSG_ERRQUEUE) {
2711 err = packet_recv_error(sk, msg, len); 2666 err = sock_recv_errqueue(sk, msg, len,
2667 SOL_PACKET, PACKET_TX_TIMESTAMP);
2712 goto out; 2668 goto out;
2713 } 2669 }
2714 2670