aboutsummaryrefslogtreecommitdiffstats
path: root/include
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
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')
-rw-r--r--include/linux/skbuff.h47
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--include/net/neighbour.h9
-rw-r--r--include/net/sock.h13
4 files changed, 62 insertions, 9 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{
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 6d63a47c731b..7f933f302078 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -404,7 +404,7 @@ static inline int hci_recv_frame(struct sk_buff *skb)
404 bt_cb(skb)->incoming = 1; 404 bt_cb(skb)->incoming = 1;
405 405
406 /* Time stamp */ 406 /* Time stamp */
407 do_gettimeofday(&skb->stamp); 407 __net_timestamp(skb);
408 408
409 /* Queue frame for rx task */ 409 /* Queue frame for rx task */
410 skb_queue_tail(&hdev->rx_q, skb); 410 skb_queue_tail(&hdev->rx_q, skb);
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 89809891e5ab..34c07731933d 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -363,7 +363,14 @@ __neigh_lookup_errno(struct neigh_table *tbl, const void *pkey,
363 return neigh_create(tbl, pkey, dev); 363 return neigh_create(tbl, pkey, dev);
364} 364}
365 365
366#define LOCALLY_ENQUEUED -2 366struct neighbour_cb {
367 unsigned long sched_next;
368 unsigned int flags;
369};
370
371#define LOCALLY_ENQUEUED 0x1
372
373#define NEIGH_CB(skb) ((struct neighbour_cb *)(skb)->cb)
367 374
368#endif 375#endif
369#endif 376#endif
diff --git a/include/net/sock.h b/include/net/sock.h
index 065df67b6422..d59428877078 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1282,16 +1282,19 @@ static inline int sock_intr_errno(long timeo)
1282static __inline__ void 1282static __inline__ void
1283sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) 1283sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
1284{ 1284{
1285 struct timeval *stamp = &skb->stamp; 1285 struct timeval stamp;
1286
1287 skb_get_timestamp(skb, &stamp);
1286 if (sock_flag(sk, SOCK_RCVTSTAMP)) { 1288 if (sock_flag(sk, SOCK_RCVTSTAMP)) {
1287 /* Race occurred between timestamp enabling and packet 1289 /* Race occurred between timestamp enabling and packet
1288 receiving. Fill in the current time for now. */ 1290 receiving. Fill in the current time for now. */
1289 if (stamp->tv_sec == 0) 1291 if (stamp.tv_sec == 0)
1290 do_gettimeofday(stamp); 1292 do_gettimeofday(&stamp);
1293 skb_set_timestamp(skb, &stamp);
1291 put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP, sizeof(struct timeval), 1294 put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP, sizeof(struct timeval),
1292 stamp); 1295 &stamp);
1293 } else 1296 } else
1294 sk->sk_stamp = *stamp; 1297 sk->sk_stamp = stamp;
1295} 1298}
1296 1299
1297/** 1300/**