aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorSimon Horman <horms@verge.net.au>2013-05-23 17:02:51 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-28 01:50:59 -0400
commit1a37e412a0225fcba5587f24c0dfc7636efc8b69 (patch)
tree34abfd79e6e06b0be580ebacfa497330e4dc1634 /include/linux
parent50ab731e967d65549b11b808f129329dd614e8d9 (diff)
net: Use 16bits for *_headers fields of struct skbuff
In order to mitigate ongoing incresase in the size of struct skbuff use 16 bit integer offsets rather than pointers for inner_*_headers. This appears to reduce the size of struct skbuff from 0xd0 to 0xc0 bytes on x86_64 with the following all unset. CONFIG_XFRM CONFIG_NF_CONNTRACK CONFIG_NF_CONNTRACK_MODULE NET_SKBUFF_NF_DEFRAG_NEEDED CONFIG_BRIDGE_NETFILTER CONFIG_NET_SCHED CONFIG_IPV6_NDISC_NODETYPE CONFIG_NET_DMA CONFIG_NETWORK_SECMARK Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/skbuff.h119
1 files changed, 6 insertions, 113 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 2e0ced1af3b1..5663e3592784 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -509,12 +509,12 @@ struct sk_buff {
509 __u32 reserved_tailroom; 509 __u32 reserved_tailroom;
510 }; 510 };
511 511
512 sk_buff_data_t inner_transport_header; 512 __u16 inner_transport_header;
513 sk_buff_data_t inner_network_header; 513 __u16 inner_network_header;
514 sk_buff_data_t inner_mac_header; 514 __u16 inner_mac_header;
515 sk_buff_data_t transport_header; 515 __u16 transport_header;
516 sk_buff_data_t network_header; 516 __u16 network_header;
517 sk_buff_data_t mac_header; 517 __u16 mac_header;
518 /* These elements must be at the end, see alloc_skb() for details. */ 518 /* These elements must be at the end, see alloc_skb() for details. */
519 sk_buff_data_t tail; 519 sk_buff_data_t tail;
520 sk_buff_data_t end; 520 sk_buff_data_t end;
@@ -1527,7 +1527,6 @@ static inline void skb_reset_mac_len(struct sk_buff *skb)
1527 skb->mac_len = skb->network_header - skb->mac_header; 1527 skb->mac_len = skb->network_header - skb->mac_header;
1528} 1528}
1529 1529
1530#ifdef NET_SKBUFF_DATA_USES_OFFSET
1531static inline unsigned char *skb_inner_transport_header(const struct sk_buff 1530static inline unsigned char *skb_inner_transport_header(const struct sk_buff
1532 *skb) 1531 *skb)
1533{ 1532{
@@ -1638,112 +1637,6 @@ static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1638 skb->mac_header += offset; 1637 skb->mac_header += offset;
1639} 1638}
1640 1639
1641#else /* NET_SKBUFF_DATA_USES_OFFSET */
1642static inline unsigned char *skb_inner_transport_header(const struct sk_buff
1643 *skb)
1644{
1645 return skb->inner_transport_header;
1646}
1647
1648static inline void skb_reset_inner_transport_header(struct sk_buff *skb)
1649{
1650 skb->inner_transport_header = skb->data;
1651}
1652
1653static inline void skb_set_inner_transport_header(struct sk_buff *skb,
1654 const int offset)
1655{
1656 skb->inner_transport_header = skb->data + offset;
1657}
1658
1659static inline unsigned char *skb_inner_network_header(const struct sk_buff *skb)
1660{
1661 return skb->inner_network_header;
1662}
1663
1664static inline void skb_reset_inner_network_header(struct sk_buff *skb)
1665{
1666 skb->inner_network_header = skb->data;
1667}
1668
1669static inline void skb_set_inner_network_header(struct sk_buff *skb,
1670 const int offset)
1671{
1672 skb->inner_network_header = skb->data + offset;
1673}
1674
1675static inline unsigned char *skb_inner_mac_header(const struct sk_buff *skb)
1676{
1677 return skb->inner_mac_header;
1678}
1679
1680static inline void skb_reset_inner_mac_header(struct sk_buff *skb)
1681{
1682 skb->inner_mac_header = skb->data;
1683}
1684
1685static inline void skb_set_inner_mac_header(struct sk_buff *skb,
1686 const int offset)
1687{
1688 skb->inner_mac_header = skb->data + offset;
1689}
1690static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
1691{
1692 return skb->transport_header != NULL;
1693}
1694
1695static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
1696{
1697 return skb->transport_header;
1698}
1699
1700static inline void skb_reset_transport_header(struct sk_buff *skb)
1701{
1702 skb->transport_header = skb->data;
1703}
1704
1705static inline void skb_set_transport_header(struct sk_buff *skb,
1706 const int offset)
1707{
1708 skb->transport_header = skb->data + offset;
1709}
1710
1711static inline unsigned char *skb_network_header(const struct sk_buff *skb)
1712{
1713 return skb->network_header;
1714}
1715
1716static inline void skb_reset_network_header(struct sk_buff *skb)
1717{
1718 skb->network_header = skb->data;
1719}
1720
1721static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
1722{
1723 skb->network_header = skb->data + offset;
1724}
1725
1726static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
1727{
1728 return skb->mac_header;
1729}
1730
1731static inline int skb_mac_header_was_set(const struct sk_buff *skb)
1732{
1733 return skb->mac_header != NULL;
1734}
1735
1736static inline void skb_reset_mac_header(struct sk_buff *skb)
1737{
1738 skb->mac_header = skb->data;
1739}
1740
1741static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
1742{
1743 skb->mac_header = skb->data + offset;
1744}
1745#endif /* NET_SKBUFF_DATA_USES_OFFSET */
1746
1747static inline void skb_probe_transport_header(struct sk_buff *skb, 1640static inline void skb_probe_transport_header(struct sk_buff *skb,
1748 const int offset_hint) 1641 const int offset_hint)
1749{ 1642{