#include <haproxy/errors.h>
#include <haproxy/fd.h>
#include <haproxy/log.h>
+#include <haproxy/protocol.h>
#include <haproxy/sc_strm.h>
#include <haproxy/stconn.h>
#include <haproxy/stream.h>
static int dns_connect_nameserver(struct dns_nameserver *ns)
{
struct dgram_conn *dgram = &ns->dgram->conn;
+ const struct protocol *proto;
int fd;
/* Already connected */
return 0;
/* Create an UDP socket and connect it on the nameserver's IP/Port */
- if ((fd = socket(dgram->addr.to.ss_family, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
+ proto = protocol_lookup(dgram->addr.to.ss_family, PROTO_TYPE_DGRAM, 1);
+ BUG_ON(!proto);
+ if ((fd = socket(proto->fam->sock_domain, proto->sock_type, proto->sock_prot)) == -1) {
send_log(NULL, LOG_WARNING,
"DNS : section '%s': can't create socket for nameserver '%s'.\n",
ns->counters->pid, ns->id);
#include <haproxy/lb_map.h>
#include <haproxy/lb_ss.h>
#include <haproxy/log.h>
+#include <haproxy/protocol.h>
#include <haproxy/proxy.h>
#include <haproxy/sample.h>
#include <haproxy/sc_strm.h>
};
static THREAD_LOCAL int logfdunix = -1; /* syslog to AF_UNIX socket */
static THREAD_LOCAL int logfdinet = -1; /* syslog to AF_INET socket */
+ const struct protocol *proto;
int *plogfd;
int sent;
size_t nbelem;
if (plogfd && unlikely(*plogfd < 0)) {
/* socket not successfully initialized yet */
- if ((*plogfd = socket(target->addr->ss_family, SOCK_DGRAM,
- (target->addr->ss_family == AF_UNIX) ? 0 : IPPROTO_UDP)) < 0) {
+
+ /* WT: this is not compliant with AF_CUST_* usage but we don't use that
+ * with DNS at the moment.
+ */
+ proto = protocol_lookup(target->addr->ss_family, PROTO_TYPE_DGRAM, 1);
+ BUG_ON(!proto);
+ if ((*plogfd = socket(proto->fam->sock_domain, proto->sock_type, proto->sock_prot)) < 0) {
static char once;
if (!once) {
*/
static int resolvers_finalize_config(void)
{
+ const struct protocol *proto;
struct resolvers *resolvers;
struct proxy *px;
int err_code = 0;
if (ns->dgram) {
/* Check nameserver info */
- if ((fd = socket(ns->dgram->conn.addr.to.ss_family, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
+ proto = protocol_lookup(ns->dgram->conn.addr.to.ss_family, PROTO_TYPE_DGRAM, 1);
+ BUG_ON(!proto);
+ if ((fd = socket(proto->fam->sock_domain, proto->sock_type, proto->sock_prot)) == -1) {
if (!resolvers->conf.implicit) { /* emit a warning only if it was configured manually */
ha_alert("resolvers '%s': can't create socket for nameserver '%s'.\n",
resolvers->id, ns->id);
#include <haproxy/listener.h>
#include <haproxy/log.h>
#include <haproxy/namespace.h>
-#include <haproxy/protocol-t.h>
+#include <haproxy/protocol.h>
#include <haproxy/proto_sockpair.h>
#include <haproxy/sock.h>
#include <haproxy/sock_inet.h>
int sock_create_server_socket(struct connection *conn, struct proxy *be, int *stream_err)
{
const struct netns_entry *ns = NULL;
+ const struct protocol *proto;
int sock_fd;
#ifdef USE_NS
ns = __objt_server(conn->target)->netns;
}
#endif
- sock_fd = my_socketat(ns, conn->dst->ss_family, SOCK_STREAM, 0);
+ proto = protocol_lookup(conn->dst->ss_family, PROTO_TYPE_STREAM, 0);
+ BUG_ON(!proto);
+ sock_fd = my_socketat(ns, proto->fam->sock_domain, SOCK_STREAM, 0);
/* at first, handle common to all proto families system limits and permission related errors */
if (sock_fd == -1) {
const struct sockaddr_storage *orig)
{
struct sockaddr_storage addr;
+ const struct proto_fam *fam;
int result;
int fd;
memcpy(&addr, orig, sizeof(addr));
set_host_port(&addr, 0);
- fd = my_socketat(ns, addr.ss_family, SOCK_DGRAM, IPPROTO_UDP);
+ fam = proto_fam_lookup(addr.ss_family);
+ BUG_ON(!fam);
+
+ fd = my_socketat(ns, fam->sock_domain, SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0)
return -1;