passt: Relicense to GPL 2.0, or any later version
In practical terms, passt doesn't benefit from the additional
protection offered by the AGPL over the GPL, because it's not
suitable to be executed over a computer network.
Further, restricting the distribution under the version 3 of the GPL
wouldn't provide any practical advantage either, as long as the passt
codebase is concerned, and might cause unnecessary compatibility
dilemmas.
Change licensing terms to the GNU General Public License Version 2,
or any later version, with written permission from all current and
past contributors, namely: myself, David Gibson, Laine Stump, Andrea
Bolognani, Paul Holzinger, Richard W.M. Jones, Chris Kuhn, Florian
Weimer, Giuseppe Scrivano, Stefan Hajnoczi, and Vasiliy Ulyanov.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2023-04-05 18:11:44 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
2021-10-19 10:43:28 +00:00
|
|
|
* Copyright (c) 2021 Red Hat GmbH
|
|
|
|
* Author: Stefano Brivio <sbrivio@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2022-03-25 23:05:31 +00:00
|
|
|
#ifndef TAP_H
|
|
|
|
#define TAP_H
|
|
|
|
|
2024-05-01 06:53:45 +00:00
|
|
|
#define ETH_HDR_INIT(proto) { .h_proto = htons_constant(proto) }
|
|
|
|
|
2023-01-06 00:43:17 +00:00
|
|
|
/**
|
2024-05-01 06:53:45 +00:00
|
|
|
* struct tap_hdr - tap backend specific headers
|
2023-01-06 00:43:17 +00:00
|
|
|
* @vnet_len: Frame length (for qemu socket transport)
|
|
|
|
*/
|
|
|
|
struct tap_hdr {
|
|
|
|
uint32_t vnet_len;
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
2024-05-01 06:53:51 +00:00
|
|
|
/**
|
|
|
|
* tap_hdr_iov() - struct iovec for a tap header
|
|
|
|
* @c: Execution context
|
|
|
|
* @taph: Pointer to tap specific header buffer
|
|
|
|
*
|
|
|
|
* Returns: A struct iovec covering the correct portion of @taph to use as the
|
|
|
|
* tap specific header in the current configuration.
|
|
|
|
*/
|
|
|
|
static inline struct iovec tap_hdr_iov(const struct ctx *c,
|
|
|
|
struct tap_hdr *thdr)
|
|
|
|
{
|
|
|
|
return (struct iovec){
|
|
|
|
.iov_base = thdr,
|
|
|
|
.iov_len = c->mode == MODE_PASST ? sizeof(*thdr) : 0,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* tap_hdr_update() - Update the tap specific header for a frame
|
|
|
|
* @taph: Tap specific header buffer to update
|
|
|
|
* @l2len: Frame length (including L2 headers)
|
|
|
|
*/
|
|
|
|
static inline void tap_hdr_update(struct tap_hdr *thdr, size_t l2len)
|
|
|
|
{
|
vhost-user: add vhost-user
add virtio and vhost-user functions to connect with QEMU.
$ ./passt --vhost-user
and
# qemu-system-x86_64 ... -m 4G \
-object memory-backend-memfd,id=memfd0,share=on,size=4G \
-numa node,memdev=memfd0 \
-chardev socket,id=chr0,path=/tmp/passt_1.socket \
-netdev vhost-user,id=netdev0,chardev=chr0 \
-device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \
...
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
[sbrivio: as suggested by lvivier, include <netinet/if_ether.h>
before including <linux/if_ether.h> as C libraries such as musl
__UAPI_DEF_ETHHDR in <netinet/if_ether.h> if they already have
a definition of struct ethhdr]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2024-11-22 16:43:34 +00:00
|
|
|
if (thdr)
|
|
|
|
thdr->vnet_len = htonl(l2len);
|
2024-05-01 06:53:51 +00:00
|
|
|
}
|
|
|
|
|
2022-11-04 03:10:35 +00:00
|
|
|
void tap_udp4_send(const struct ctx *c, struct in_addr src, in_port_t sport,
|
|
|
|
struct in_addr dst, in_port_t dport,
|
2024-05-01 06:53:49 +00:00
|
|
|
const void *in, size_t dlen);
|
2022-11-04 03:10:35 +00:00
|
|
|
void tap_icmp4_send(const struct ctx *c, struct in_addr src, struct in_addr dst,
|
2024-05-01 06:53:49 +00:00
|
|
|
const void *in, size_t l4len);
|
2022-10-19 00:43:49 +00:00
|
|
|
const struct in6_addr *tap_ip6_daddr(const struct ctx *c,
|
|
|
|
const struct in6_addr *src);
|
2022-10-19 00:43:53 +00:00
|
|
|
void tap_udp6_send(const struct ctx *c,
|
|
|
|
const struct in6_addr *src, in_port_t sport,
|
|
|
|
const struct in6_addr *dst, in_port_t dport,
|
2024-10-03 14:51:08 +00:00
|
|
|
uint32_t flow, void *in, size_t dlen);
|
2022-10-19 00:43:53 +00:00
|
|
|
void tap_icmp6_send(const struct ctx *c,
|
|
|
|
const struct in6_addr *src, const struct in6_addr *dst,
|
2024-05-01 06:53:49 +00:00
|
|
|
const void *in, size_t l4len);
|
|
|
|
void tap_send_single(const struct ctx *c, const void *data, size_t l2len);
|
2024-03-08 06:53:22 +00:00
|
|
|
size_t tap_send_frames(const struct ctx *c, const struct iovec *iov,
|
|
|
|
size_t bufs_per_frame, size_t nframes);
|
2024-03-06 05:58:37 +00:00
|
|
|
void eth_update_mac(struct ethhdr *eh,
|
2023-01-06 00:43:17 +00:00
|
|
|
const unsigned char *eth_d, const unsigned char *eth_s);
|
2023-08-11 05:12:28 +00:00
|
|
|
void tap_listen_handler(struct ctx *c, uint32_t events);
|
2023-08-11 05:12:29 +00:00
|
|
|
void tap_handler_pasta(struct ctx *c, uint32_t events,
|
|
|
|
const struct timespec *now);
|
|
|
|
void tap_handler_passt(struct ctx *c, uint32_t events,
|
|
|
|
const struct timespec *now);
|
2024-05-22 18:18:19 +00:00
|
|
|
int tap_sock_unix_open(char *sock_path);
|
vhost-user: add vhost-user
add virtio and vhost-user functions to connect with QEMU.
$ ./passt --vhost-user
and
# qemu-system-x86_64 ... -m 4G \
-object memory-backend-memfd,id=memfd0,share=on,size=4G \
-numa node,memdev=memfd0 \
-chardev socket,id=chr0,path=/tmp/passt_1.socket \
-netdev vhost-user,id=netdev0,chardev=chr0 \
-device virtio-net,mac=9a:2b:2c:2d:2e:2f,netdev=netdev0 \
...
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
[sbrivio: as suggested by lvivier, include <netinet/if_ether.h>
before including <linux/if_ether.h> as C libraries such as musl
__UAPI_DEF_ETHHDR in <netinet/if_ether.h> if they already have
a definition of struct ethhdr]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2024-11-22 16:43:34 +00:00
|
|
|
void tap_sock_reset(struct ctx *c);
|
|
|
|
void tap_sock_update_pool(void *base, size_t size);
|
2024-11-22 16:43:33 +00:00
|
|
|
void tap_backend_init(struct ctx *c);
|
2024-06-13 12:36:50 +00:00
|
|
|
void tap_flush_pools(void);
|
|
|
|
void tap_handler(struct ctx *c, const struct timespec *now);
|
|
|
|
void tap_add_packet(struct ctx *c, ssize_t l2len, char *p);
|
2022-03-25 23:05:31 +00:00
|
|
|
|
|
|
|
#endif /* TAP_H */
|