Commit fbb192a8 authored by David S. Miller's avatar David S. Miller

Merge branch 'skbuff-bitfields'

Jakub Kicinski says:

====================
net: skbuff: hide some bitfield members

There is a number of protocol or subsystem specific fields
in struct sk_buff which are only accessed by one subsystem.
We can wrap them in ifdefs with minimal code impact.

This gives us a better chance to save a 2B and a 4B holes
resulting with the following savings (assuming a lucky
kernel config):

-	/* size: 232, cachelines: 4, members: 28 */
-	/* sum members: 227, holes: 1, sum holes: 4 */
-	/* sum bitfield members: 8 bits (1 bytes) */
+	/* size: 224, cachelines: 4, members: 28 */
 	/* forced alignments: 2 */
-	/* last cacheline: 40 bytes */
+	/* last cacheline: 32 bytes */

I think that the changes shouldn't be too controversial.
The only one I'm not 100% sure of is the SCTP one,
12 extra LoC for one bit.. But it did fit squarely
in the "this bit has only one user" category.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Acked-by: default avatarSimon Horman <horms@kernel.org>
parents 4edd97fb 48d80c39
...@@ -934,7 +934,7 @@ struct sk_buff { ...@@ -934,7 +934,7 @@ struct sk_buff {
/* public: */ /* public: */
__u8 pkt_type:3; /* see PKT_TYPE_MAX */ __u8 pkt_type:3; /* see PKT_TYPE_MAX */
__u8 ignore_df:1; __u8 ignore_df:1;
__u8 nf_trace:1; __u8 dst_pending_confirm:1;
__u8 ip_summed:2; __u8 ip_summed:2;
__u8 ooo_okay:1; __u8 ooo_okay:1;
...@@ -949,12 +949,14 @@ struct sk_buff { ...@@ -949,12 +949,14 @@ struct sk_buff {
__u8 remcsum_offload:1; __u8 remcsum_offload:1;
__u8 csum_complete_sw:1; __u8 csum_complete_sw:1;
__u8 csum_level:2; __u8 csum_level:2;
__u8 dst_pending_confirm:1; __u8 inner_protocol_type:1;
__u8 l4_hash:1; __u8 l4_hash:1;
__u8 sw_hash:1; __u8 sw_hash:1;
#ifdef CONFIG_WIRELESS
__u8 wifi_acked_valid:1; __u8 wifi_acked_valid:1;
__u8 wifi_acked:1; __u8 wifi_acked:1;
#endif
__u8 no_fcs:1; __u8 no_fcs:1;
/* Indicates the inner headers are valid in the skbuff. */ /* Indicates the inner headers are valid in the skbuff. */
__u8 encapsulation:1; __u8 encapsulation:1;
...@@ -964,8 +966,12 @@ struct sk_buff { ...@@ -964,8 +966,12 @@ struct sk_buff {
__u8 ndisc_nodetype:2; __u8 ndisc_nodetype:2;
#endif #endif
#if IS_ENABLED(CONFIG_IP_VS)
__u8 ipvs_property:1; __u8 ipvs_property:1;
__u8 inner_protocol_type:1; #endif
#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) || IS_ENABLED(CONFIG_NF_TABLES)
__u8 nf_trace:1;
#endif
#ifdef CONFIG_NET_SWITCHDEV #ifdef CONFIG_NET_SWITCHDEV
__u8 offload_fwd_mark:1; __u8 offload_fwd_mark:1;
__u8 offload_l3_fwd_mark:1; __u8 offload_l3_fwd_mark:1;
...@@ -981,12 +987,16 @@ struct sk_buff { ...@@ -981,12 +987,16 @@ struct sk_buff {
__u8 decrypted:1; __u8 decrypted:1;
#endif #endif
__u8 slow_gro:1; __u8 slow_gro:1;
#if IS_ENABLED(CONFIG_IP_SCTP)
__u8 csum_not_inet:1; __u8 csum_not_inet:1;
#endif
#ifdef CONFIG_NET_SCHED #ifdef CONFIG_NET_SCHED
__u16 tc_index; /* traffic control index */ __u16 tc_index; /* traffic control index */
#endif #endif
u16 alloc_cpu;
union { union {
__wsum csum; __wsum csum;
struct { struct {
...@@ -1010,7 +1020,6 @@ struct sk_buff { ...@@ -1010,7 +1020,6 @@ struct sk_buff {
unsigned int sender_cpu; unsigned int sender_cpu;
}; };
#endif #endif
u16 alloc_cpu;
#ifdef CONFIG_NETWORK_SECMARK #ifdef CONFIG_NETWORK_SECMARK
__u32 secmark; __u32 secmark;
#endif #endif
...@@ -1187,6 +1196,15 @@ static inline unsigned int skb_napi_id(const struct sk_buff *skb) ...@@ -1187,6 +1196,15 @@ static inline unsigned int skb_napi_id(const struct sk_buff *skb)
#endif #endif
} }
static inline bool skb_wifi_acked_valid(const struct sk_buff *skb)
{
#ifdef CONFIG_WIRELESS
return skb->wifi_acked_valid;
#else
return 0;
#endif
}
/** /**
* skb_unref - decrement the skb's reference count * skb_unref - decrement the skb's reference count
* @skb: buffer * @skb: buffer
...@@ -5049,7 +5067,19 @@ static inline void skb_reset_redirect(struct sk_buff *skb) ...@@ -5049,7 +5067,19 @@ static inline void skb_reset_redirect(struct sk_buff *skb)
static inline bool skb_csum_is_sctp(struct sk_buff *skb) static inline bool skb_csum_is_sctp(struct sk_buff *skb)
{ {
#if IS_ENABLED(CONFIG_IP_SCTP)
return skb->csum_not_inet; return skb->csum_not_inet;
#else
return 0;
#endif
}
static inline void skb_reset_csum_not_inet(struct sk_buff *skb)
{
skb->ip_summed = CHECKSUM_NONE;
#if IS_ENABLED(CONFIG_IP_SCTP)
skb->csum_not_inet = 0;
#endif
} }
static inline void skb_set_kcov_handle(struct sk_buff *skb, static inline void skb_set_kcov_handle(struct sk_buff *skb,
......
...@@ -2697,7 +2697,7 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) ...@@ -2697,7 +2697,7 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
else else
sock_write_timestamp(sk, kt); sock_write_timestamp(sk, kt);
if (sock_flag(sk, SOCK_WIFI_STATUS) && skb->wifi_acked_valid) if (sock_flag(sk, SOCK_WIFI_STATUS) && skb_wifi_acked_valid(skb))
__sock_recv_wifi_status(msg, sk, skb); __sock_recv_wifi_status(msg, sk, skb);
} }
......
...@@ -3315,8 +3315,7 @@ int skb_crc32c_csum_help(struct sk_buff *skb) ...@@ -3315,8 +3315,7 @@ int skb_crc32c_csum_help(struct sk_buff *skb)
skb->len - start, ~(__u32)0, skb->len - start, ~(__u32)0,
crc32c_csum_stub)); crc32c_csum_stub));
*(__le32 *)(skb->data + offset) = crc32c_csum; *(__le32 *)(skb->data + offset) = crc32c_csum;
skb->ip_summed = CHECKSUM_NONE; skb_reset_csum_not_inet(skb);
skb->csum_not_inet = 0;
out: out:
return ret; return ret;
} }
......
...@@ -5189,6 +5189,7 @@ void skb_tstamp_tx(struct sk_buff *orig_skb, ...@@ -5189,6 +5189,7 @@ void skb_tstamp_tx(struct sk_buff *orig_skb,
} }
EXPORT_SYMBOL_GPL(skb_tstamp_tx); EXPORT_SYMBOL_GPL(skb_tstamp_tx);
#ifdef CONFIG_WIRELESS
void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) void skb_complete_wifi_ack(struct sk_buff *skb, bool acked)
{ {
struct sock *sk = skb->sk; struct sock *sk = skb->sk;
...@@ -5214,6 +5215,7 @@ void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) ...@@ -5214,6 +5215,7 @@ void skb_complete_wifi_ack(struct sk_buff *skb, bool acked)
kfree_skb(skb); kfree_skb(skb);
} }
EXPORT_SYMBOL_GPL(skb_complete_wifi_ack); EXPORT_SYMBOL_GPL(skb_complete_wifi_ack);
#endif /* CONFIG_WIRELESS */
/** /**
* skb_partial_csum_set - set up and verify partial csum values for packet * skb_partial_csum_set - set up and verify partial csum values for packet
......
...@@ -376,8 +376,7 @@ static int tcf_csum_sctp(struct sk_buff *skb, unsigned int ihl, ...@@ -376,8 +376,7 @@ static int tcf_csum_sctp(struct sk_buff *skb, unsigned int ihl,
sctph->checksum = sctp_compute_cksum(skb, sctph->checksum = sctp_compute_cksum(skb,
skb_network_offset(skb) + ihl); skb_network_offset(skb) + ihl);
skb->ip_summed = CHECKSUM_NONE; skb_reset_csum_not_inet(skb);
skb->csum_not_inet = 0;
return 1; return 1;
} }
......
...@@ -957,6 +957,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, ...@@ -957,6 +957,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
} }
EXPORT_SYMBOL_GPL(__sock_recv_timestamp); EXPORT_SYMBOL_GPL(__sock_recv_timestamp);
#ifdef CONFIG_WIRELESS
void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,
struct sk_buff *skb) struct sk_buff *skb)
{ {
...@@ -972,6 +973,7 @@ void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, ...@@ -972,6 +973,7 @@ void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,
put_cmsg(msg, SOL_SOCKET, SCM_WIFI_STATUS, sizeof(ack), &ack); put_cmsg(msg, SOL_SOCKET, SCM_WIFI_STATUS, sizeof(ack), &ack);
} }
EXPORT_SYMBOL_GPL(__sock_recv_wifi_status); EXPORT_SYMBOL_GPL(__sock_recv_wifi_status);
#endif
static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk,
struct sk_buff *skb) struct sk_buff *skb)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment