aboutgitcodebugslistschat
path: root/passt.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-07-26 17:20:30 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-07-26 14:07:38 +0200
commit37e3b24d90278288b6b6216da249b5d45fc4c411 (patch)
tree3cb4cb520b2c9e0d0407f817152ce62324485ffc /passt.h
parent4684f603446b1f5da20f242006eedb4fb9eced95 (diff)
downloadpasst-37e3b24d90278288b6b6216da249b5d45fc4c411.tar
passt-37e3b24d90278288b6b6216da249b5d45fc4c411.tar.gz
passt-37e3b24d90278288b6b6216da249b5d45fc4c411.tar.bz2
passt-37e3b24d90278288b6b6216da249b5d45fc4c411.tar.lz
passt-37e3b24d90278288b6b6216da249b5d45fc4c411.tar.xz
passt-37e3b24d90278288b6b6216da249b5d45fc4c411.tar.zst
passt-37e3b24d90278288b6b6216da249b5d45fc4c411.zip
tap: Correctly handle frames of odd length
The Qemu socket protocol consists of a 32-bit frame length in network (BE) order, followed by the Ethernet frame itself. As far as I can tell, frames can be any length, with no particular alignment requirement. This means that although pkt_buf itself is aligned, if we have a frame of odd length, frames after it will have their frame length at an unaligned address. Currently we load the frame length by just casting a char pointer to (uint32_t *) and loading. Some platforms will generate a fatal trap on such an unaligned load. Even if they don't casting an incorrectly aligned pointer to (uint32_t *) is undefined behaviour, strictly speaking. Introduce a new helper to safely load a possibly unaligned value here. We assume that the compiler is smart enough to optimize this into nothing on platforms that provide performant unaligned loads. If that turns out not to be the case, we can look at improvements then. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'passt.h')
0 files changed, 0 insertions, 0 deletions