Skip to content

Commit 3bc3b96

Browse files
ebirgerdavem330
authored andcommitted
net: add common accessor for setting dropcount on packets
As part of an effort to move skb->dropcount to skb->cb[], use a common function in order to set dropcount in struct sk_buff. Signed-off-by: Eyal Birger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b4772ef commit 3bc3b96

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

include/net/sock.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,6 +2081,12 @@ static inline int sock_intr_errno(long timeo)
20812081
#define sock_skb_cb_check_size(size) \
20822082
BUILD_BUG_ON((size) > FIELD_SIZEOF(struct sk_buff, cb))
20832083

2084+
static inline void
2085+
sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
2086+
{
2087+
skb->dropcount = atomic_read(&sk->sk_drops);
2088+
}
2089+
20842090
void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
20852091
struct sk_buff *skb);
20862092
void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,

net/core/sock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
466466
skb_dst_force(skb);
467467

468468
spin_lock_irqsave(&list->lock, flags);
469-
skb->dropcount = atomic_read(&sk->sk_drops);
469+
sock_skb_set_dropcount(sk, skb);
470470
__skb_queue_tail(list, skb);
471471
spin_unlock_irqrestore(&list->lock, flags);
472472

net/packet/af_packet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1845,7 +1845,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
18451845

18461846
spin_lock(&sk->sk_receive_queue.lock);
18471847
po->stats.stats1.tp_packets++;
1848-
skb->dropcount = atomic_read(&sk->sk_drops);
1848+
sock_skb_set_dropcount(sk, skb);
18491849
__skb_queue_tail(&sk->sk_receive_queue, skb);
18501850
spin_unlock(&sk->sk_receive_queue.lock);
18511851
sk->sk_data_ready(sk);

0 commit comments

Comments
 (0)