[PATCH RFC 8/9] sk_buff: move vlan field after tail.
Paolo Abeni
pabeni at redhat.com
Wed Jul 21 16:44:40 UTC 2021
Such field validity is already tracked by the existing
'vlan_present' bit. Move them after tail and conditinally copy
as needed.
Signed-off-by: Paolo Abeni <pabeni at redhat.com>
---
include/linux/skbuff.h | 10 ++++++++--
net/core/skbuff.c | 5 +++--
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a3e756575aa7..7acf2a203918 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -897,8 +897,6 @@ struct sk_buff {
__u32 priority;
int skb_iif;
__u32 hash;
- __be16 vlan_proto;
- __u16 vlan_tci;
#if defined(CONFIG_NET_RX_BUSY_POLL) || defined(CONFIG_XPS)
union {
unsigned int napi_id;
@@ -955,6 +953,14 @@ struct sk_buff {
};
__u64 inner_headers;
};
+
+ union {
+ struct {
+ __be16 vlan_proto;
+ __u16 vlan_tci;
+ };
+ __u32 vlan_info;
+ };
};
#ifdef __KERNEL__
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 53b8db10e567..c59e90db80d5 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -996,6 +996,8 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
__skb_ext_copy(new, old);
__nf_copy(new, old, false);
__skb_copy_inner_headers(new, old);
+ if (old->vlan_present)
+ new->vlan_info = old->vlan_info;
/* Note : this field could be in headers_start/headers_end section
* It is not yet because we do not want to have a 16 bit hole
@@ -1007,13 +1009,12 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
offsetof(struct sk_buff, headers_start));
CHECK_SKB_FIELD(_state);
CHECK_SKB_FIELD(__pkt_encapsulation_offset);
+ CHECK_SKB_FIELD(__pkt_vlan_present_offset);
CHECK_SKB_FIELD(protocol);
CHECK_SKB_FIELD(csum);
CHECK_SKB_FIELD(hash);
CHECK_SKB_FIELD(priority);
CHECK_SKB_FIELD(skb_iif);
- CHECK_SKB_FIELD(vlan_proto);
- CHECK_SKB_FIELD(vlan_tci);
CHECK_SKB_FIELD(transport_header);
CHECK_SKB_FIELD(network_header);
CHECK_SKB_FIELD(mac_header);
--
2.26.3
More information about the Linux-security-module-archive
mailing list