only use SOCK_STREAM for TCP in bindany(), otherwise SOCK_DGRAM for UDP.
authorreyk <reyk@openbsd.org>
Wed, 9 Jul 2008 14:06:44 +0000 (14:06 +0000)
committerreyk <reyk@openbsd.org>
Wed, 9 Jul 2008 14:06:44 +0000 (14:06 +0000)
usr.sbin/relayd/relayd.c

index f1588bd..fad7f12 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: relayd.c,v 1.77 2008/06/11 18:21:20 reyk Exp $        */
+/*     $OpenBSD: relayd.c,v 1.78 2008/07/09 14:06:44 reyk Exp $        */
 
 /*
  * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -1181,7 +1181,8 @@ bindany(struct ctl_bindany *bnd)
 
        if (relay_socket_af(&bnd->bnd_ss, bnd->bnd_port) == -1)
                goto fail;
-       if ((s = socket(bnd->bnd_ss.ss_family, SOCK_STREAM,
+       if ((s = socket(bnd->bnd_ss.ss_family,
+           bnd->bnd_proto == IPPROTO_TCP ? SOCK_STREAM : SOCK_DGRAM,
            bnd->bnd_proto)) == -1)
                goto fail;
        if (setsockopt(s, SOL_SOCKET, SO_BINDANY,