ee677e0a42
This makes several tweaks to improve the logic which decides whether we're able to use the splice method for a new connection. * Rather than only calling tcp_splice_conn_from_sock() in pasta mode, we check for pasta mode within it, better localising the checks. * Previously if we got a connection from a non-loopback address we'd always fall back to the "tap" path, even if the connection was on a socket in the namespace. If we did get a non-loopback address on a namespace socket, something has gone wrong and the "tap" path certainly won't be able to handle it. Report the error and close, rather than passing it along to tap. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright Red Hat
|
|
* Author: David Gibson <david@gibson.dropbear.id.au>
|
|
*
|
|
* inany.c - Types and helpers for handling addresses which could be
|
|
* IPv6 or IPv4 (encoded as IPv4-mapped IPv6 addresses)
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <stdbool.h>
|
|
#include <assert.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/inet.h>
|
|
|
|
#include "util.h"
|
|
#include "siphash.h"
|
|
#include "inany.h"
|
|
|
|
const union inany_addr inany_loopback4 = {
|
|
.v4mapped = {
|
|
.zero = { 0 },
|
|
.one = { 0xff, 0xff, },
|
|
.a4 = IN4ADDR_LOOPBACK_INIT,
|
|
},
|
|
};
|
|
|
|
const union inany_addr inany_any4 = {
|
|
.v4mapped = {
|
|
.zero = { 0 },
|
|
.one = { 0xff, 0xff, },
|
|
.a4 = IN4ADDR_ANY_INIT,
|
|
},
|
|
};
|
|
|
|
/** inany_ntop - Convert an IPv[46] address to text format
|
|
* @src: IPv[46] address
|
|
* @dst: output buffer, minimum INANY_ADDRSTRLEN bytes
|
|
* @size: size of buffer at @dst
|
|
*
|
|
* Return: On success, a non-null pointer to @dst, NULL on failure
|
|
*/
|
|
const char *inany_ntop(const union inany_addr *src, char *dst, socklen_t size)
|
|
{
|
|
const struct in_addr *v4 = inany_v4(src);
|
|
|
|
if (v4)
|
|
return inet_ntop(AF_INET, v4, dst, size);
|
|
|
|
return inet_ntop(AF_INET6, &src->a6, dst, size);
|
|
}
|