mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-02 01:20:49 +00:00
BUG/MEDIUM: namespaces: don't fail if no namespace is used
Susheel Jalali reported a confusing bug in namespaces implementation. If namespaces are enabled at build time (USE_NS=1) and *no* namespace is used at all in the whole config file, my_socketat() returns -1 and all socket bindings fail. This is because of a wrong condition in this function. A possible workaround consists in creating some namespaces.
This commit is contained in:
parent
5d681ba976
commit
70f289cf8d
@ -97,14 +97,13 @@ int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol
|
|||||||
int sock;
|
int sock;
|
||||||
|
|
||||||
#ifdef CONFIG_HAP_NS
|
#ifdef CONFIG_HAP_NS
|
||||||
if (default_namespace < 0 ||
|
if (default_namespace >= 0 && ns && setns(ns->fd, CLONE_NEWNET) == -1)
|
||||||
(ns && setns(ns->fd, CLONE_NEWNET) == -1))
|
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
sock = socket(domain, type, protocol);
|
sock = socket(domain, type, protocol);
|
||||||
|
|
||||||
#ifdef CONFIG_HAP_NS
|
#ifdef CONFIG_HAP_NS
|
||||||
if (ns && setns(default_namespace, CLONE_NEWNET) == -1) {
|
if (default_namespace >= 0 && ns && setns(default_namespace, CLONE_NEWNET) == -1) {
|
||||||
close(sock);
|
close(sock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user