PR/47861: Fredrik Pettai: keep track of the address family for each socket
opened and don't send the a message to the wrong family type.
This commit is contained in:
parent
1fc3ba0182
commit
c68a8e00e8
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: syslogd.c,v 1.114 2013/01/17 18:54:28 christos Exp $ */
|
||||
/* $NetBSD: syslogd.c,v 1.115 2013/05/27 23:15:51 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1988, 1993, 1994
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993, 1994\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: syslogd.c,v 1.114 2013/01/17 18:54:28 christos Exp $");
|
||||
__RCSID("$NetBSD: syslogd.c,v 1.115 2013/05/27 23:15:51 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -2496,6 +2496,8 @@ udp_send(struct filed *f, char *line, size_t len)
|
||||
for (r = f->f_un.f_forw.f_addr; r; r = r->ai_next) {
|
||||
retry = 0;
|
||||
for (j = 0; j < finet->fd; j++) {
|
||||
if (finet[j+1].af != r->ai_family)
|
||||
continue;
|
||||
sendagain:
|
||||
lsent = sendto(finet[j+1].fd, line, len, 0,
|
||||
r->ai_addr, r->ai_addrlen);
|
||||
@ -3994,6 +3996,7 @@ socksetup(int af, const char *hostname)
|
||||
logerror("socket() failed");
|
||||
continue;
|
||||
}
|
||||
s->af = r->ai_family;
|
||||
if (r->ai_family == AF_INET6 && setsockopt(s->fd, IPPROTO_IPV6,
|
||||
IPV6_V6ONLY, &on, sizeof(on)) < 0) {
|
||||
logerror("setsockopt(IPV6_V6ONLY) failed");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: syslogd.h,v 1.3 2009/04/20 09:56:08 mschuett Exp $ */
|
||||
/* $NetBSD: syslogd.h,v 1.4 2013/05/27 23:15:51 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -302,6 +302,7 @@ STAILQ_HEAD(buf_queue_head, buf_queue);
|
||||
/* a pair of a socket and an associated event object */
|
||||
struct socketEvent {
|
||||
int fd;
|
||||
int af;
|
||||
struct event *ev;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tls.c,v 1.10 2012/06/06 00:33:45 christos Exp $ */
|
||||
/* $NetBSD: tls.c,v 1.11 2013/05/27 23:15:51 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -45,7 +45,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: tls.c,v 1.10 2012/06/06 00:33:45 christos Exp $");
|
||||
__RCSID("$NetBSD: tls.c,v 1.11 2013/05/27 23:15:51 christos Exp $");
|
||||
|
||||
#ifndef DISABLE_TLS
|
||||
#include "syslogd.h"
|
||||
@ -851,6 +851,7 @@ socksetup_tls(const int af, const char *bindhostname, const char *port)
|
||||
logerror("socket() failed: %s", strerror(errno));
|
||||
continue;
|
||||
}
|
||||
s->af = r->ai_family;
|
||||
if (r->ai_family == AF_INET6
|
||||
&& setsockopt(s->fd, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
&on, sizeof(on)) == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user