aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEyal Birger <eyal.birger@gmail.com>2015-03-01 07:58:31 -0500
committerDavid S. Miller <davem@davemloft.net>2015-03-02 00:19:30 -0500
commit744d5a3e9fe2690dd85d9991dbb078301694658b (patch)
treee8e54af77636cf51a1146cd638275f940bfe3db9 /include
parent3bc3b96f3b455bd14a8ccd83ffffc85625aba641 (diff)
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')
-rw-r--r--include/linux/skbuff.h2
-rw-r--r--include/net/sock.h18
2 files changed, 16 insertions, 4 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index d898b32dedcc..bba1330757c0 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -492,7 +492,6 @@ static inline u32 skb_mstamp_us_delta(const struct skb_mstamp *t1,
492 * @napi_id: id of the NAPI struct this skb came from 492 * @napi_id: id of the NAPI struct this skb came from
493 * @secmark: security marking 493 * @secmark: security marking
494 * @mark: Generic packet mark 494 * @mark: Generic packet mark
495 * @dropcount: total number of sk_receive_queue overflows
496 * @vlan_proto: vlan encapsulation protocol 495 * @vlan_proto: vlan encapsulation protocol
497 * @vlan_tci: vlan tag control information 496 * @vlan_tci: vlan tag control information
498 * @inner_protocol: Protocol (encapsulation) 497 * @inner_protocol: Protocol (encapsulation)
@@ -641,7 +640,6 @@ struct sk_buff {
641#endif 640#endif
642 union { 641 union {
643 __u32 mark; 642 __u32 mark;
644 __u32 dropcount;
645 __u32 reserved_tailroom; 643 __u32 reserved_tailroom;
646 }; 644 };
647 645
diff --git a/include/net/sock.h b/include/net/sock.h
index 0996fe451e5f..38369d3580a1 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2078,13 +2078,27 @@ static inline int sock_intr_errno(long timeo)
2078 return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR; 2078 return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR;
2079} 2079}
2080 2080
2081struct sock_skb_cb {
2082 u32 dropcount;
2083};
2084
2085/* Store sock_skb_cb at the end of skb->cb[] so protocol families
2086 * using skb->cb[] would keep using it directly and utilize its
2087 * alignement guarantee.
2088 */
2089#define SOCK_SKB_CB_OFFSET ((FIELD_SIZEOF(struct sk_buff, cb) - \
2090 sizeof(struct sock_skb_cb)))
2091
2092#define SOCK_SKB_CB(__skb) ((struct sock_skb_cb *)((__skb)->cb + \
2093 SOCK_SKB_CB_OFFSET))
2094
2081#define sock_skb_cb_check_size(size) \ 2095#define sock_skb_cb_check_size(size) \
2082 BUILD_BUG_ON((size) > FIELD_SIZEOF(struct sk_buff, cb)) 2096 BUILD_BUG_ON((size) > SOCK_SKB_CB_OFFSET)
2083 2097
2084static inline void 2098static inline void
2085sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb) 2099sock_skb_set_dropcount(const struct sock *sk, struct sk_buff *skb)
2086{ 2100{
2087 skb->dropcount = atomic_read(&sk->sk_drops); 2101 SOCK_SKB_CB(skb)->dropcount = atomic_read(&sk->sk_drops);
2088} 2102}
2089 2103
2090void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, 2104void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,