summaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
authorEyal Birger <eyal.birger@gmail.com>2015-03-01 14:58:31 +0200
committerDavid S. Miller <davem@davemloft.net>2015-03-02 00:19:30 -0500
commit744d5a3e9fe2690dd85d9991dbb078301694658b (patch)
treee8e54af77636cf51a1146cd638275f940bfe3db9 /include/net/sock.h
parent3bc3b96f3b455bd14a8ccd83ffffc85625aba641 (diff)
downloadop-kernel-dev-744d5a3e9fe2690dd85d9991dbb078301694658b.zip
op-kernel-dev-744d5a3e9fe2690dd85d9991dbb078301694658b.tar.gz
net: move skb->dropcount to skb->cb[]
Commit 977750076d98 ("af_packet: add interframe drop cmsg (v6)") unionized skb->mark and skb->dropcount in order to allow recording of the socket drop count while maintaining struct sk_buff size. skb->dropcount was introduced since there was no available room in skb->cb[] in packet sockets. However, its introduction led to the inability to export skb->mark, or any other aliased field to userspace if so desired. Moving the dropcount metric to skb->cb[] eliminates this problem at the expense of 4 bytes less in skb->cb[] for protocol families using it. Signed-off-by: Eyal Birger <eyal.birger@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 0996fe4..38369d3 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2078,13 +2078,27 @@ static inline int sock_intr_errno(long timeo)
return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR;
}
+struct sock_skb_cb {
+ u32 dropcount;
+};
+
+/* Store sock_skb_cb at the end of skb->cb[] so protocol families
+ * using skb->cb[] would keep using it directly and utilize its
+ * alignement guarantee.
+ */
+#define SOCK_SKB_CB_OFFSET ((FIELD_SIZEOF(struct sk_buff, cb) - \
+ sizeof(struct sock_skb_cb)))
+
+#define SOCK_SKB_CB(__skb) ((struct sock_skb_cb *)((__skb)->cb + \
+ SOCK_SKB_CB_OFFSET))
+
#define sock_skb_cb_check_size(size) \
- BUILD_BUG_ON((size) > FIELD_SIZEOF(struct sk_buff, cb))
+ BUILD_BUG_ON((size) > SOCK_SKB_CB_OFFSET)
static inline void
sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
{
- skb->dropcount = atomic_read(&sk->sk_drops);
+ SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
}
void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
OpenPOWER on IntegriCloud