mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-14 23:44:41 +00:00
b3e54fe387
This patch makes it possible to create binds and servers in separate namespaces. This can be used to proxy between multiple completely independent virtual networks (with possibly overlapping IP addresses) and a non-namespace-aware proxy implementation that supports the proxy protocol (v2). The setup is something like this: net1 on VLAN 1 (namespace 1) -\ net2 on VLAN 2 (namespace 2) -- haproxy ==== proxy (namespace 0) net3 on VLAN 3 (namespace 3) -/ The proxy is configured to make server connections through haproxy and sending the expected source/target addresses to haproxy using the proxy protocol. The network namespace setup on the haproxy node is something like this: = 8< = $ cat setup.sh ip netns add 1 ip link add link eth1 type vlan id 1 ip link set eth1.1 netns 1 ip netns exec 1 ip addr add 192.168.91.2/24 dev eth1.1 ip netns exec 1 ip link set eth1.$id up ... = 8< = = 8< = $ cat haproxy.cfg frontend clients bind 127.0.0.1:50022 namespace 1 transparent default_backend scb backend server mode tcp server server1 192.168.122.4:2222 namespace 2 send-proxy-v2 = 8< = A bind line creates the listener in the specified namespace, and connections originating from that listener also have their network namespace set to that of the listener. A server line either forces the connection to be made in a specified namespace or may use the namespace from the client-side connection if that was set. For more documentation please read the documentation included in the patch itself. Signed-off-by: KOVACS Tamas <ktamas@balabit.com> Signed-off-by: Sarkozi Laszlo <laszlo.sarkozi@balabit.com> Signed-off-by: KOVACS Krisztian <hidden@balabit.com>
25 lines
490 B
C
25 lines
490 B
C
#ifndef NAMESPACE_H
|
|
|
|
#include <stdlib.h>
|
|
#include <ebistree.h>
|
|
|
|
struct netns_entry;
|
|
int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol);
|
|
|
|
#ifdef CONFIG_HAP_NS
|
|
|
|
struct netns_entry
|
|
{
|
|
struct ebpt_node node;
|
|
size_t name_len;
|
|
int fd;
|
|
};
|
|
|
|
struct netns_entry* netns_store_insert(const char *ns_name);
|
|
const struct netns_entry* netns_store_lookup(const char *ns_name, size_t ns_name_len);
|
|
|
|
int netns_init(void);
|
|
#endif /* CONFIG_HAP_NS */
|
|
|
|
#endif /* NAMESPACE_H */
|