net/vxlan: Avoid unaligned access in vxlan_build_skb()
Subsystems (2)
PATCH v2 1/1 net/vxlan: Avoid unaligned access in vxlan_build_skb()
The vxlan header may not be aligned to 4 bytes in vxlan_build_skb (e.g., for MLD packets). This patch avoids unaligned access traps from vxlan_build_skb (in platforms like sparc) by making struct vxlanhdr __packed.
--- include/net/vxlan.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/net/vxlan.h +1 -1
@@ -18,7 +18,7 @@struct vxlanhdr {__be32 vx_flags;__be32 vx_vni; -}; +} __packed;/* VXLAN header flags. */ #define VXLAN_HF_VNI cpu_to_be32(BIT(27))
Signature · 1 line
1.7.1
Quoted 6 lines · Sowmini Varadhan
The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb(e.g., for MLD packets). This patch avoids unaligned access traps fromvxlan_build_skb(in platforms like sparc) by making struct vxlanhdr__packed.Signed-off-by Sowmini Varadhan <[email protected]>
Quoted 6 lines · Sowmini Varadhan
The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb(e.g., for MLD packets). This patch avoids unaligned access traps fromvxlan_build_skb(in platforms like sparc) by making struct vxlanhdr__packed.Signed-off-by Sowmini Varadhan <[email protected]>
Performance wise this should only affect code generation for archs where it matters anyway.
Thanks,
Hannes
Quoted 10 lines · Hannes Frederic Sowa
Quoted 6 lines · Sowmini Varadhan
The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb(e.g., for MLD packets). This patch avoids unaligned access traps fromvxlan_build_skb(in platforms like sparc) by making struct vxlanhdr__packed.Signed-off-by Sowmini Varadhan <[email protected]>Performance wise this should only affect code generation for archs where it matters anyway.
I think it's the opposite. Even on x86 compiler will use byte loads.
Quoted 7 lines · Alexei Starovoitov
Quoted 6 lines · Hannes Frederic Sowa
Quoted 5 lines · Sowmini Varadhan
The vxlan header may not be aligned to 4 bytes in
vxlan_build_skb(e.g., for MLD packets). This patch avoids unaligned access traps fromvxlan_build_skb(in platforms like sparc) by making struct vxlanhdr__packed.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Sowmini Varadhan <[email protected]>Performance wise this should only affect code generation for archs where it matters anyway.
I think it's the opposite. Even on x86 compiler will use byte loads.
I checked that on x86-64 actually. Also clearly visible here:
Bye,
Hannes
Quoted 2 lines · Alexei Starovoitov
I think it's the opposite. Even on x86 compiler will use byte loads.
Unless you tweaked gcc, it should still use word loads on x86.
Quoted 8 lines · Eric Dumazet
Quoted 2 lines · Alexei Starovoitov
I think it's the opposite. Even on x86 compiler will use byte loads.
Unless you tweaked gcc, it should still use word loads on x86.
checked that on x86-64 actually. Also clearly visible here:
ahh. ok. good to know. thanks guys!