diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-05-01 16:53:45 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-05-02 16:13:08 +0200 |
commit | 34fb381b5a5cb61e9e5ca554ff58349b6d5fe154 (patch) | |
tree | a3e92c27c5e21ba7f4d18297265202835b11835b /tap.h | |
parent | c27ca9156422bdf2ecdcbf9e1fe06a702a7e288d (diff) | |
download | passt-34fb381b5a5cb61e9e5ca554ff58349b6d5fe154.tar passt-34fb381b5a5cb61e9e5ca554ff58349b6d5fe154.tar.gz passt-34fb381b5a5cb61e9e5ca554ff58349b6d5fe154.tar.bz2 passt-34fb381b5a5cb61e9e5ca554ff58349b6d5fe154.tar.lz passt-34fb381b5a5cb61e9e5ca554ff58349b6d5fe154.tar.xz passt-34fb381b5a5cb61e9e5ca554ff58349b6d5fe154.tar.zst passt-34fb381b5a5cb61e9e5ca554ff58349b6d5fe154.zip |
tap: Split tap specific and L2 (ethernet) headers
In some places (well, actually only UDP now) we use struct tap_hdr to
represent both tap backend specific and L2 ethernet headers. Handling
these together seemed like a good idea at the time, but Laurent's changes
in the TCP code working towards vhost-user support suggest that treating
them separately is more useful, more often.
Alter struct tap_hdr to represent only the TAP backend specific headers.
Updated related helpers and the UDP code to match.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tap.h')
-rw-r--r-- | tap.h | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -6,30 +6,28 @@ #ifndef TAP_H #define TAP_H +#define ETH_HDR_INIT(proto) { .h_proto = htons_constant(proto) } + /** - * struct tap_hdr - L2 and tap specific headers + * struct tap_hdr - tap backend specific headers * @vnet_len: Frame length (for qemu socket transport) - * @eh: Ethernet header */ struct tap_hdr { uint32_t vnet_len; - struct ethhdr eh; } __attribute__((packed)); -#define TAP_HDR_INIT(proto) { .eh.h_proto = htons_constant(proto) } - static inline size_t tap_hdr_len_(const struct ctx *c) { if (c->mode == MODE_PASST) return sizeof(struct tap_hdr); else - return sizeof(struct ethhdr); + return 0; } /** * tap_frame_base() - Find start of tap frame * @c: Execution context - * @taph: Pointer to L2 and tap specific header buffer + * @taph: Pointer to tap specific header buffer * * Returns: pointer to the start of tap frame - suitable for an * iov_base to be passed to tap_send_frames()) @@ -43,17 +41,16 @@ static inline void *tap_frame_base(const struct ctx *c, struct tap_hdr *taph) * tap_frame_len() - Finalize tap frame and return total length * @c: Execution context * @taph: Tap header to finalize - * @plen: L3 packet length (excludes L2 and tap specific headers) + * @plen: L2 packet length (includes L2, excludes tap specific headers) * - * Returns: length of the tap frame including L2 and tap specific - * headers - suitable for an iov_len to be passed to - * tap_send_frames() + * Returns: length of the tap frame including tap specific headers - suitable + * for an iov_len to be passed to tap_send_frames() */ static inline size_t tap_frame_len(const struct ctx *c, struct tap_hdr *taph, size_t plen) { if (c->mode == MODE_PASST) - taph->vnet_len = htonl(plen + sizeof(taph->eh)); + taph->vnet_len = htonl(plen); return plen + tap_hdr_len_(c); } |