aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2005-08-14 20:24:31 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:58:24 -0400
commita61bbcf28a8cb0ba56f8193d512f7222e711a294 (patch)
tree33ae1976ab3b08aac516debb2742d2c6696d5436 /include/linux/skbuff.h
parent25ed891019b84498c83903ecf53df7ce35e9cff6 (diff)
[NET]: Store skb->timestamp as offset to a base timestamp
Reduces skb size by 8 bytes on 64-bit. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h47
1 files changed, 45 insertions, 2 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 60b32151f76a..32635c401d4d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -155,13 +155,20 @@ struct skb_shared_info {
155#define SKB_DATAREF_SHIFT 16 155#define SKB_DATAREF_SHIFT 16
156#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1) 156#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
157 157
158extern struct timeval skb_tv_base;
159
160struct skb_timeval {
161 u32 off_sec;
162 u32 off_usec;
163};
164
158/** 165/**
159 * struct sk_buff - socket buffer 166 * struct sk_buff - socket buffer
160 * @next: Next buffer in list 167 * @next: Next buffer in list
161 * @prev: Previous buffer in list 168 * @prev: Previous buffer in list
162 * @list: List we are on 169 * @list: List we are on
163 * @sk: Socket we are owned by 170 * @sk: Socket we are owned by
164 * @stamp: Time we arrived 171 * @tstamp: Time we arrived stored as offset to skb_tv_base
165 * @dev: Device we arrived on/are leaving by 172 * @dev: Device we arrived on/are leaving by
166 * @input_dev: Device we arrived on 173 * @input_dev: Device we arrived on
167 * @h: Transport layer header 174 * @h: Transport layer header
@@ -202,7 +209,7 @@ struct sk_buff {
202 struct sk_buff *prev; 209 struct sk_buff *prev;
203 210
204 struct sock *sk; 211 struct sock *sk;
205 struct timeval stamp; 212 struct skb_timeval tstamp;
206 struct net_device *dev; 213 struct net_device *dev;
207 struct net_device *input_dev; 214 struct net_device *input_dev;
208 215
@@ -1213,6 +1220,42 @@ static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
1213extern void skb_init(void); 1220extern void skb_init(void);
1214extern void skb_add_mtu(int mtu); 1221extern void skb_add_mtu(int mtu);
1215 1222
1223/**
1224 * skb_get_timestamp - get timestamp from a skb
1225 * @skb: skb to get stamp from
1226 * @stamp: pointer to struct timeval to store stamp in
1227 *
1228 * Timestamps are stored in the skb as offsets to a base timestamp.
1229 * This function converts the offset back to a struct timeval and stores
1230 * it in stamp.
1231 */
1232static inline void skb_get_timestamp(struct sk_buff *skb, struct timeval *stamp)
1233{
1234 stamp->tv_sec = skb->tstamp.off_sec;
1235 stamp->tv_usec = skb->tstamp.off_usec;
1236 if (skb->tstamp.off_sec) {
1237 stamp->tv_sec += skb_tv_base.tv_sec;
1238 stamp->tv_usec += skb_tv_base.tv_usec;
1239 }
1240}
1241
1242/**
1243 * skb_set_timestamp - set timestamp of a skb
1244 * @skb: skb to set stamp of
1245 * @stamp: pointer to struct timeval to get stamp from
1246 *
1247 * Timestamps are stored in the skb as offsets to a base timestamp.
1248 * This function converts a struct timeval to an offset and stores
1249 * it in the skb.
1250 */
1251static inline void skb_set_timestamp(struct sk_buff *skb, struct timeval *stamp)
1252{
1253 skb->tstamp.off_sec = stamp->tv_sec - skb_tv_base.tv_sec;
1254 skb->tstamp.off_usec = stamp->tv_usec - skb_tv_base.tv_usec;
1255}
1256
1257extern void __net_timestamp(struct sk_buff *skb);
1258
1216#ifdef CONFIG_NETFILTER 1259#ifdef CONFIG_NETFILTER
1217static inline void nf_conntrack_put(struct nf_conntrack *nfct) 1260static inline void nf_conntrack_put(struct nf_conntrack *nfct)
1218{ 1261{