armv7: useless global between cpufunc.c & locore.S

2017-11-01 Thread Artturi Alm
Hi,

i think V4 or higher can already be assumed, because we're protected by
EFI anyway, right? it can't be zero unless set_cpufuncs() does fail.

like can be seen from the diff below, only the unified TLB invalidation
was conditional anymore, not the instruction disabling the MMU, like
suggested by comment i also removed below.

-Artturi


diff --git a/sys/arch/arm/arm/cpufunc.c b/sys/arch/arm/arm/cpufunc.c
index f528e20662b..d813fac0c7a 100644
--- a/sys/arch/arm/arm/cpufunc.c
+++ b/sys/arch/arm/arm/cpufunc.c
@@ -140,7 +140,6 @@ struct cpu_functions armv7_cpufuncs = {
 
 struct cpu_functions cpufuncs;
 u_int cputype;
-u_int cpu_reset_needs_v4_MMU_disable;  /* flag used in locore.s */
 
 intarm_icache_min_line_size = 32;
 intarm_dcache_min_line_size = 32;
@@ -330,8 +329,6 @@ set_cpufuncs()
case VMSA_V7_PXN:
case VMSA_V7_LDT:
cpufuncs = armv7_cpufuncs;
-   /* V4 or higher */
-   cpu_reset_needs_v4_MMU_disable = 1;
arm_get_cachetype_cp15v7();
armv7_dcache_sets_inc = 1U << arm_dcache_l2_linesize;
armv7_dcache_sets_max = (1U << (arm_dcache_l2_linesize +
diff --git a/sys/arch/arm/arm/locore.S b/sys/arch/arm/arm/locore.S
index 9e393bc3e36..9bd4ef45de7 100644
--- a/sys/arch/arm/arm/locore.S
+++ b/sys/arch/arm/arm/locore.S
@@ -127,14 +127,6 @@ ENTRY_NP(cpu_reset)
mov lr, pc
ldr pc, [r0, #CF_IDCACHE_WBINV_ALL]
 
-   /*
-* Load the cpu_reset_needs_v4_MMU_disable flag to determine if it's
-* necessary.
-*/
-
-   ldr r1, .Lcpu_reset_needs_v4_MMU_disable
-   ldr r1, [r1]
-   cmp r1, #0
mov r2, #0
 
/*
@@ -143,7 +135,7 @@ ENTRY_NP(cpu_reset)
 */
mov r0, #(CPU_CONTROL_32BP_ENABLE | CPU_CONTROL_32BD_ENABLE)
mcr CP15_SCTLR(r0)  
-   mcrne   CP15_TLBIALL(r2)/* nail I+D TLB on ARMv4 and greater */
+   mcr CP15_TLBIALL(r2)/* nail I+D TLB */
mov pc, r4
 
/*
@@ -154,15 +146,6 @@ ENTRY_NP(cpu_reset)
 .Lcpu_reset_address:
.word   _C_LABEL(cpu_reset_address)
 
-   /*
-* cpu_reset_needs_v4_MMU_disable contains a flag that signals if the
-* v4 MMU disable instruction needs executing... it is an illegal 
instruction
-* on f.e. ARM6/7 that locks up the computer in an endless illegal
-* instruction / data-abort / reset loop.
-*/
-.Lcpu_reset_needs_v4_MMU_disable:
-   .word   _C_LABEL(cpu_reset_needs_v4_MMU_disable)
-
 #endif /* OFW */
 
 /*





if_ioctl & netinet{,6}

2017-11-01 Thread Martin Pieuchot
ifioctl() contains two fallthrough paths that end up in ifp->if_ioctl().
The diff below merges them.

But instead of calling ifp->if_ioctl() from inside in{,6}_ioctl(), I
changed the logic to return EOPNOTSUPP.  The idea is that if_ioctl()
is part of the driver and will need a different lock than the address
layers.

Along the way I unified the error codes returned when `ifp' is NULL.
Note that this should never happen in in{,6}_ioctl(), but that's a
different crusade.

Comments, oks?

Index: net/if.c
===
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.521
diff -u -p -r1.521 if.c
--- net/if.c31 Oct 2017 22:05:12 -  1.521
+++ net/if.c1 Nov 2017 17:13:26 -
@@ -1985,30 +1985,6 @@ ifioctl(struct socket *so, u_long cmd, c
rtm_ifchg(ifp);
break;
 
-   case SIOCDIFPHYADDR:
-   case SIOCSLIFPHYADDR:
-   case SIOCSLIFPHYRTABLE:
-   case SIOCSLIFPHYTTL:
-   case SIOCADDMULTI:
-   case SIOCDELMULTI:
-   case SIOCSIFMEDIA:
-   case SIOCSVNETID:
-   case SIOCSIFPAIR:
-   case SIOCSIFPARENT:
-   case SIOCDIFPARENT:
-   if ((error = suser(p, 0)) != 0)
-   break;
-   /* FALLTHROUGH */
-   case SIOCGLIFPHYADDR:
-   case SIOCGLIFPHYRTABLE:
-   case SIOCGLIFPHYTTL:
-   case SIOCGIFMEDIA:
-   case SIOCGVNETID:
-   case SIOCGIFPAIR:
-   case SIOCGIFPARENT:
-   error = (*ifp->if_ioctl)(ifp, cmd, data);
-   break;
-
case SIOCGIFDESCR:
strlcpy(ifdescrbuf, ifp->if_description, IFDESCRSIZE);
error = copyoutstr(ifdescrbuf, ifr->ifr_data, IFDESCRSIZE,
@@ -2138,10 +2114,26 @@ ifioctl(struct socket *so, u_long cmd, c
ifp->if_llprio = ifr->ifr_llprio;
break;
 
+   case SIOCDIFPHYADDR:
+   case SIOCSLIFPHYADDR:
+   case SIOCSLIFPHYRTABLE:
+   case SIOCSLIFPHYTTL:
+   case SIOCADDMULTI:
+   case SIOCDELMULTI:
+   case SIOCSIFMEDIA:
+   case SIOCSVNETID:
+   case SIOCSIFPAIR:
+   case SIOCSIFPARENT:
+   case SIOCDIFPARENT:
+   if ((error = suser(p, 0)) != 0)
+   break;
+   /* FALLTHROUGH */
default:
error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL,
(struct mbuf *) cmd, (struct mbuf *) data,
(struct mbuf *) ifp, p));
+   if (error == EOPNOTSUPP)
+   error = ((*ifp->if_ioctl)(ifp, cmd, data));
break;
}
 
Index: netinet/in.c
===
RCS file: /cvs/src/sys/netinet/in.c,v
retrieving revision 1.143
diff -u -p -r1.143 in.c
--- netinet/in.c24 Oct 2017 09:30:15 -  1.143
+++ netinet/in.c1 Nov 2017 17:13:26 -
@@ -213,7 +213,7 @@ in_ioctl(u_long cmd, caddr_t data, struc
int newifaddr;
 
if (ifp == NULL)
-   return (EOPNOTSUPP);
+   return (ENXIO);
 
NET_ASSERT_LOCKED();
 
@@ -393,8 +393,7 @@ in_ioctl(u_long cmd, caddr_t data, struc
break;
 
default:
-   error = ((*ifp->if_ioctl)(ifp, cmd, data));
-   return (error);
+   return (EOPNOTSUPP);
}
return (0);
 }
Index: netinet6/in6.c
===
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.216
diff -u -p -r1.216 in6.c
--- netinet6/in6.c  26 Oct 2017 15:05:41 -  1.216
+++ netinet6/in6.c  1 Nov 2017 17:13:26 -
@@ -207,10 +207,11 @@ in6_ioctl(u_long cmd, caddr_t data, stru
struct  in6_ifaddr *ia6 = NULL;
struct  in6_aliasreq *ifra = (struct in6_aliasreq *)data;
struct sockaddr_in6 *sa6;
-   int error;
 
if (ifp == NULL)
-   return (EOPNOTSUPP);
+   return (ENXIO);
+
+   NET_ASSERT_LOCKED();
 
switch (cmd) {
case SIOCGIFINFO_IN6:
@@ -249,7 +250,7 @@ in6_ioctl(u_long cmd, caddr_t data, stru
 * Do not pass those ioctl to driver handler since they are not
 * properly setup. Instead just error out.
 */
-   return (EOPNOTSUPP);
+   return (EINVAL);
default:
sa6 = NULL;
break;
@@ -311,7 +312,6 @@ in6_ioctl(u_long cmd, caddr_t data, stru
}
 
switch (cmd) {
-
case SIOCGIFDSTADDR_IN6:
if ((ifp->if_flags & IFF_POINTOPOINT) == 0)
return (EINVAL);
@@ -454,8 +454,7 @@ in6_ioctl(u_long cmd, caddr_t data, stru
break;
 
default:
-   error = ((*ifp->if_ioctl)(ifp, cmd, data));
-   return (error);
+   return (EOPNOTSUPP);
}
 
return (0);



Re: awk setlocale(LC_NUMERIC)

2017-11-01 Thread Christian Weisgerber
On 2017-11-01, Jan Stary  wrote:

> Why does awk need to fiddle with LC_NUMERIC?

You don't want to parse your awk program in a locale where the
decimal separator is a comma.

-- 
Christian "naddy" Weisgerber  na...@mips.inka.de



Re: pr(1) - ignore LC_TIME

2017-11-01 Thread Mark Kettenis
> From: Jeremie Courreges-Anglas 
> Date: Wed, 01 Nov 2017 17:25:45 +0100
> 
> On Wed, Nov 01 2017, Mark Kettenis  wrote:
> >> Date: Wed, 1 Nov 2017 17:04:44 +0100
> >> From: Jan Stary 
> >> 
> >> Doesn't OpenBSD strftime() ignore LC_TIME anyway?
> >
> > One day we will support it.  I see no reason to remove this call (or
> > any of the others you're proposing).
> 
> Maybe we'll support LC_TIME one day.  But this use of LC_TIME looks
> completely bogus to me: LC_TIME isn't supposed to be a strftime format
> string...  I'll commit this soon unless I hear objections.

Heh, right.

> >> Index: pr.c
> >> ===
> >> RCS file: /cvs/src/usr.bin/pr/pr.c,v
> >> retrieving revision 1.39
> >> diff -u -p -r1.39 pr.c
> >> --- pr.c   11 Nov 2015 02:52:46 -  1.39
> >> +++ pr.c   1 Nov 2017 15:58:48 -
> >> @@ -124,7 +124,6 @@ char   schar;  /* text column separation c
> >>  int   sflag;  /* -s option for multiple columns */
> >>  int   nohead; /* do not write head and trailer */
> >>  int   pgwd;   /* page width with multiple col output */
> >> -char  *timefrmt;  /* time conversion string */
> >>  
> >>  /*
> >>   * misc globals
> >> @@ -1546,7 +1545,7 @@ nxtfile(int argc, char *argv[], char **f
> >>  /*
> >>   * set up time field used in header
> >>   */
> >> -if (strftime(buf, HDBUF, timefrmt, timeptr) == 0) {
> >> +if (strftime(buf, HDBUF, TIMEFMT, timeptr) == 0) {
> >>++errcnt;
> >>if (inf != stdin)
> >>(void)fclose(inf);
> >> @@ -2006,7 +2005,5 @@ setup(int argc, char *argv[])
> >>}
> >>  }
> >>  
> >> -if ((timefrmt = getenv("LC_TIME")) == NULL)
> >> -  timefrmt = TIMEFMT;
> >>  return(0);
> >>  }
> >> 
> >> 
> >
> 
> 
> -- 
> jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE
> 
> 



Re: pr(1) - ignore LC_TIME

2017-11-01 Thread Jeremie Courreges-Anglas
On Wed, Nov 01 2017, Mark Kettenis  wrote:
>> Date: Wed, 1 Nov 2017 17:04:44 +0100
>> From: Jan Stary 
>> 
>> Doesn't OpenBSD strftime() ignore LC_TIME anyway?
>
> One day we will support it.  I see no reason to remove this call (or
> any of the others you're proposing).

Maybe we'll support LC_TIME one day.  But this use of LC_TIME looks
completely bogus to me: LC_TIME isn't supposed to be a strftime format
string...  I'll commit this soon unless I hear objections.

>> Index: pr.c
>> ===
>> RCS file: /cvs/src/usr.bin/pr/pr.c,v
>> retrieving revision 1.39
>> diff -u -p -r1.39 pr.c
>> --- pr.c 11 Nov 2015 02:52:46 -  1.39
>> +++ pr.c 1 Nov 2017 15:58:48 -
>> @@ -124,7 +124,6 @@ char schar;  /* text column separation c
>>  int sflag;  /* -s option for multiple columns */
>>  int nohead; /* do not write head and trailer */
>>  int pgwd;   /* page width with multiple col output */
>> -char*timefrmt;  /* time conversion string */
>>  
>>  /*
>>   * misc globals
>> @@ -1546,7 +1545,7 @@ nxtfile(int argc, char *argv[], char **f
>>  /*
>>   * set up time field used in header
>>   */
>> -if (strftime(buf, HDBUF, timefrmt, timeptr) == 0) {
>> +if (strftime(buf, HDBUF, TIMEFMT, timeptr) == 0) {
>>  ++errcnt;
>>  if (inf != stdin)
>>  (void)fclose(inf);
>> @@ -2006,7 +2005,5 @@ setup(int argc, char *argv[])
>>  }
>>  }
>>  
>> -if ((timefrmt = getenv("LC_TIME")) == NULL)
>> -timefrmt = TIMEFMT;
>>  return(0);
>>  }
>> 
>> 
>


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: pr(1) - ignore LC_TIME

2017-11-01 Thread Mark Kettenis
> Date: Wed, 1 Nov 2017 17:04:44 +0100
> From: Jan Stary 
> 
> Doesn't OpenBSD strftime() ignore LC_TIME anyway?

One day we will support it.  I see no reason to remove this call (or
any of the others you're proposing).

> Index: pr.c
> ===
> RCS file: /cvs/src/usr.bin/pr/pr.c,v
> retrieving revision 1.39
> diff -u -p -r1.39 pr.c
> --- pr.c  11 Nov 2015 02:52:46 -  1.39
> +++ pr.c  1 Nov 2017 15:58:48 -
> @@ -124,7 +124,6 @@ char  schar;  /* text column separation c
>  int  sflag;  /* -s option for multiple columns */
>  int  nohead; /* do not write head and trailer */
>  int  pgwd;   /* page width with multiple col output */
> -char *timefrmt;  /* time conversion string */
>  
>  /*
>   * misc globals
> @@ -1546,7 +1545,7 @@ nxtfile(int argc, char *argv[], char **f
>  /*
>   * set up time field used in header
>   */
> -if (strftime(buf, HDBUF, timefrmt, timeptr) == 0) {
> +if (strftime(buf, HDBUF, TIMEFMT, timeptr) == 0) {
>   ++errcnt;
>   if (inf != stdin)
>   (void)fclose(inf);
> @@ -2006,7 +2005,5 @@ setup(int argc, char *argv[])
>   }
>  }
>  
> -if ((timefrmt = getenv("LC_TIME")) == NULL)
> - timefrmt = TIMEFMT;
>  return(0);
>  }
> 
> 



Re: awk setlocale(LC_NUMERIC)

2017-11-01 Thread Jeremie Courreges-Anglas
On Wed, Nov 01 2017, Jan Stary  wrote:
> Why does awk need to fiddle with LC_NUMERIC?

awk is not developed in OpenBSD land[1].  Since LC_NUMERIC doesn't have
any effect on OpenBSD I'd rather just let this code be.

[1] https://www.cs.princeton.edu/~bwk/btl.mirror/

>   Jan
>
> Index: main.c
> ===
> RCS file: /cvs/src/usr.bin/awk/main.c,v
> retrieving revision 1.21
> diff -u -p -r1.21 main.c
> --- main.c9 Oct 2017 14:51:31 -   1.21
> +++ main.c1 Nov 2017 15:50:11 -
> @@ -28,7 +28,6 @@ const char  *version = "version 20110810"
>  #define DEBUG
>  #include 
>  #include 
> -#include 
>  #include 
>  #include 
>  #include 
> @@ -61,9 +60,6 @@ int main(int argc, char *argv[])
>  {
>   const char *fs = NULL;
>  
> - setlocale(LC_ALL, "");
> - setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
> -
>   cmdname = __progname;
>   if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) {
>   fprintf(stderr, "%s: pledge: incorrect arguments\n",
> @@ -185,7 +181,6 @@ int main(int argc, char *argv[])
>   if (!safe)
>   envinit(environ);
>   yyparse();
> - setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */
>   if (fs)
>   *FS = qstring(fs, '\0');
>  DPRINTF( ("errorflag=%d\n", errorflag) );
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



pr(1) - ignore LC_TIME

2017-11-01 Thread Jan Stary
Doesn't OpenBSD strftime() ignore LC_TIME anyway?

Jan

Index: pr.c
===
RCS file: /cvs/src/usr.bin/pr/pr.c,v
retrieving revision 1.39
diff -u -p -r1.39 pr.c
--- pr.c11 Nov 2015 02:52:46 -  1.39
+++ pr.c1 Nov 2017 15:58:48 -
@@ -124,7 +124,6 @@ charschar;  /* text column separation c
 intsflag;  /* -s option for multiple columns */
 intnohead; /* do not write head and trailer */
 intpgwd;   /* page width with multiple col output */
-char   *timefrmt;  /* time conversion string */
 
 /*
  * misc globals
@@ -1546,7 +1545,7 @@ nxtfile(int argc, char *argv[], char **f
 /*
  * set up time field used in header
  */
-if (strftime(buf, HDBUF, timefrmt, timeptr) == 0) {
+if (strftime(buf, HDBUF, TIMEFMT, timeptr) == 0) {
++errcnt;
if (inf != stdin)
(void)fclose(inf);
@@ -2006,7 +2005,5 @@ setup(int argc, char *argv[])
}
 }
 
-if ((timefrmt = getenv("LC_TIME")) == NULL)
-   timefrmt = TIMEFMT;
 return(0);
 }



zic.c does not need locale.h

2017-11-01 Thread Jan Stary
Index: zic.c
===
RCS file: /cvs/src/usr.sbin/zic/zic.c,v
retrieving revision 1.22
diff -u -p -r1.22 zic.c
--- zic.c   15 Mar 2016 19:50:47 -  1.22
+++ zic.c   1 Nov 2017 15:52:04 -
@@ -11,7 +11,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



awk setlocale(LC_NUMERIC)

2017-11-01 Thread Jan Stary
Why does awk need to fiddle with LC_NUMERIC?

Jan

Index: main.c
===
RCS file: /cvs/src/usr.bin/awk/main.c,v
retrieving revision 1.21
diff -u -p -r1.21 main.c
--- main.c  9 Oct 2017 14:51:31 -   1.21
+++ main.c  1 Nov 2017 15:50:11 -
@@ -28,7 +28,6 @@ const char*version = "version 20110810"
 #define DEBUG
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -61,9 +60,6 @@ int main(int argc, char *argv[])
 {
const char *fs = NULL;
 
-   setlocale(LC_ALL, "");
-   setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
-
cmdname = __progname;
if (pledge("stdio rpath wpath cpath proc exec", NULL) == -1) {
fprintf(stderr, "%s: pledge: incorrect arguments\n",
@@ -185,7 +181,6 @@ int main(int argc, char *argv[])
if (!safe)
envinit(environ);
yyparse();
-   setlocale(LC_NUMERIC, ""); /* back to whatever it is locally */
if (fs)
*FS = qstring(fs, '\0');
   DPRINTF( ("errorflag=%d\n", errorflag) );



Re: ksh alloc(): switch calloc back to malloc

2017-11-01 Thread Jeremie Courreges-Anglas
On Wed, Nov 01 2017, Theo Buehler  wrote:
> The plaintext history diff changed memory allocation in alloc() from
> malloc() to calloc(). At that point, some of the new code in history.c
> may (or may not) have depended on this. In the meantime, this code was
> removed by jca in his cleanup of history.c that happened shortly before
> the 6.2 release.
>
> I would like to switch this back because most of ksh shold not rely on
> calloc() being used, and malloc() allows us to use malloc's J feature to
> recognize use of uninitialized memory.
>
> I verified that none of the changes to ksh between 05/30/2017 (the day
> after the plaintext history diff) and now relies on calloc.

ok

> Index: bin/ksh//alloc.c
> ===
> RCS file: /var/cvs/src/bin/ksh/alloc.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 alloc.c
> --- bin/ksh//alloc.c  15 Aug 2017 17:57:57 -  1.17
> +++ bin/ksh//alloc.c  29 Aug 2017 02:10:11 -
> @@ -47,7 +47,7 @@ alloc(size_t size, Area *ap)
>   if (size > SIZE_MAX - sizeof(struct link))
>   internal_errorf(1, "unable to allocate memory");
>  
> - l = calloc(1, sizeof(struct link) + size);
> + l = malloc(sizeof(struct link) + size);
>   if (l == NULL)
>   internal_errorf(1, "unable to allocate memory");
>   l->next = ap->freelist;
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



ksh alloc(): switch calloc back to malloc

2017-11-01 Thread Theo Buehler
The plaintext history diff changed memory allocation in alloc() from
malloc() to calloc(). At that point, some of the new code in history.c
may (or may not) have depended on this. In the meantime, this code was
removed by jca in his cleanup of history.c that happened shortly before
the 6.2 release.

I would like to switch this back because most of ksh shold not rely on
calloc() being used, and malloc() allows us to use malloc's J feature to
recognize use of uninitialized memory.

I verified that none of the changes to ksh between 05/30/2017 (the day
after the plaintext history diff) and now relies on calloc.

Index: bin/ksh//alloc.c
===
RCS file: /var/cvs/src/bin/ksh/alloc.c,v
retrieving revision 1.17
diff -u -p -r1.17 alloc.c
--- bin/ksh//alloc.c15 Aug 2017 17:57:57 -  1.17
+++ bin/ksh//alloc.c29 Aug 2017 02:10:11 -
@@ -47,7 +47,7 @@ alloc(size_t size, Area *ap)
if (size > SIZE_MAX - sizeof(struct link))
internal_errorf(1, "unable to allocate memory");
 
-   l = calloc(1, sizeof(struct link) + size);
+   l = malloc(sizeof(struct link) + size);
if (l == NULL)
internal_errorf(1, "unable to allocate memory");
l->next = ap->freelist;



Re: NULL pointer dereference in ip*_send()

2017-11-01 Thread Theo Buehler
On Wed, Nov 01, 2017 at 01:14:44PM +0100, Alexandr Nedvedicky wrote:
> Hello,
> 
> the patch [1] I've committed yesterday needs a follow up commit below.
> the problem was found by Hrvoje. 

Already fixed by mpi a few hours ago:
https://marc.info/?l=openbsd-cvs=150951814421443=2



NULL pointer dereference in ip*_send()

2017-11-01 Thread Alexandr Nedvedicky
Hello,

the patch [1] I've committed yesterday needs a follow up commit below.
the problem was found by Hrvoje. 

my deep apologize

regards
sasha

[1] https://marc.info/?l=openbsd-tech=150944369215209=2

8<---8<---8<--8<
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 8bd258681f9..1ee32bd1847 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1839,5 +1839,5 @@ void
 ip_send(struct mbuf *m)
 {
mq_enqueue(_mq, m);
-   task_add(0, _task);
+   task_add(net_tq(0), _task);
 }
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index f52b78d6c28..f46aa475be7 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1477,5 +1477,5 @@ void
 ip6_send(struct mbuf *m)
 {
mq_enqueue(_mq, m);
-   task_add(0, _task);
+   task_add(net_tq(0), _task);
 }



Re: makefs: malloc -> emalloc

2017-11-01 Thread Jeremie Courreges-Anglas
On Wed, Nov 01 2017, "Michael W. Bombardieri"  wrote:
> Hello,
>
> makefs has an xmalloc.c with emalloc() function, but one thing
> was still using malloc() directly. This patch makes malloc()
> always happen through emalloc().

Fails to build, implicit emalloc decl.

> - Michael
>
>
> Index: msdos/mkfs_msdos.c
> ===
> RCS file: /cvs/src/usr.sbin/makefs/msdos/mkfs_msdos.c,v
> retrieving revision 1.4
> diff -u -p -u -r1.4 mkfs_msdos.c
> --- msdos/mkfs_msdos.c28 Mar 2017 00:08:39 -  1.4
> +++ msdos/mkfs_msdos.c1 Nov 2017 02:58:21 -
> @@ -592,8 +592,7 @@ mkfs_msdos(const char *fname, const char
>  gettimeofday(, NULL);
>  now = tv.tv_sec;
>  tm = localtime();
> -if (!(img = malloc(bpb.bps)))
> -err(1, NULL);
> +img = emalloc(bpb.bps);
>  dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft;
>  signal(SIGINFO, infohandler);
>  for (lsn = 0; lsn < dir + (o.fat_type == 32 ? bpb.spc : rds); lsn++) {
>

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: nsd(8): make ip-transparent option work on OpenBSD

2017-11-01 Thread Jeremie Courreges-Anglas
On Wed, Nov 01 2017, Florian Obser  wrote:
> OK?

ok jca@

btw the diff below has already been posted to tech@:

  https://marc.info/?l=openbsd-tech=147747266305927=2

> diff --git server.c server.c
> index c0835ce8c11..fe74f9a1b56 100644
> --- server.c
> +++ server.c
> @@ -567,7 +567,7 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
> int* reuseport_works)
>  {
>   struct addrinfo* addr;
>   size_t i;
> -#if defined(SO_REUSEPORT) || defined(SO_REUSEADDR) || (defined(INET6) && 
> (defined(IPV6_V6ONLY) || defined(IPV6_USE_MIN_MTU) || defined(IPV6_MTU) || 
> defined(IP_TRANSPARENT)) || defined(IP_FREEBIND))
> +#if defined(SO_REUSEPORT) || defined(SO_REUSEADDR) || (defined(INET6) && 
> (defined(IPV6_V6ONLY) || defined(IPV6_USE_MIN_MTU) || defined(IPV6_MTU) || 
> defined(IP_TRANSPARENT)) || defined(IP_FREEBIND) || defined(SO_BINDANY))
>   int on = 1;
>  #endif
>  
> @@ -757,6 +757,12 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
> int* reuseport_works)
>   strerror(errno));
>   }
>  #endif /* IP_TRANSPARENT */
> +#ifdef SO_BINDANY
> + if (setsockopt(nsd->udp[i].s, SOL_SOCKET, SO_BINDANY, 
> , sizeof(on)) < 0) {
> + log_msg(LOG_ERR, "setsockopt(...,SO_BINDANY, 
> ...) failed for udp: %s",
> + strerror(errno));
> + }
> +#endif /* SO_BINDANY */
>   }
>  
>   if (bind(nsd->udp[i].s, (struct sockaddr *) addr->ai_addr, 
> addr->ai_addrlen) != 0) {
> @@ -887,6 +893,12 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
> int* reuseport_works)
>   strerror(errno));
>   }
>  #endif /* IP_TRANSPARENT */
> +#ifdef SO_BINDANY
> + if (setsockopt(nsd->tcp[i].s, SOL_SOCKET, SO_BINDANY, 
> , sizeof(on)) < 0) {
> + log_msg(LOG_ERR, "setsockopt(...,SO_BINDANY, 
> ...) failed for tcp: %s",
> + strerror(errno));
> + }
> +#endif /* SO_BINDANY */
>   }
>  
>   if (bind(nsd->tcp[i].s, (struct sockaddr *) addr->ai_addr, 
> addr->ai_addrlen) != 0) {

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: nsd(8): make ip-transparent option work on OpenBSD

2017-11-01 Thread Sebastian Benoit
ok

Florian Obser(flor...@openbsd.org) on 2017.11.01 12:17:44 +0100:
> OK?
> 
> diff --git server.c server.c
> index c0835ce8c11..fe74f9a1b56 100644
> --- server.c
> +++ server.c
> @@ -567,7 +567,7 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
> int* reuseport_works)
>  {
>   struct addrinfo* addr;
>   size_t i;
> -#if defined(SO_REUSEPORT) || defined(SO_REUSEADDR) || (defined(INET6) && 
> (defined(IPV6_V6ONLY) || defined(IPV6_USE_MIN_MTU) || defined(IPV6_MTU) || 
> defined(IP_TRANSPARENT)) || defined(IP_FREEBIND))
> +#if defined(SO_REUSEPORT) || defined(SO_REUSEADDR) || (defined(INET6) && 
> (defined(IPV6_V6ONLY) || defined(IPV6_USE_MIN_MTU) || defined(IPV6_MTU) || 
> defined(IP_TRANSPARENT)) || defined(IP_FREEBIND) || defined(SO_BINDANY))
>   int on = 1;
>  #endif
>  
> @@ -757,6 +757,12 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
> int* reuseport_works)
>   strerror(errno));
>   }
>  #endif /* IP_TRANSPARENT */
> +#ifdef SO_BINDANY
> + if (setsockopt(nsd->udp[i].s, SOL_SOCKET, SO_BINDANY, 
> , sizeof(on)) < 0) {
> + log_msg(LOG_ERR, "setsockopt(...,SO_BINDANY, 
> ...) failed for udp: %s",
> + strerror(errno));
> + }
> +#endif /* SO_BINDANY */
>   }
>  
>   if (bind(nsd->udp[i].s, (struct sockaddr *) addr->ai_addr, 
> addr->ai_addrlen) != 0) {
> @@ -887,6 +893,12 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
> int* reuseport_works)
>   strerror(errno));
>   }
>  #endif /* IP_TRANSPARENT */
> +#ifdef SO_BINDANY
> + if (setsockopt(nsd->tcp[i].s, SOL_SOCKET, SO_BINDANY, 
> , sizeof(on)) < 0) {
> + log_msg(LOG_ERR, "setsockopt(...,SO_BINDANY, 
> ...) failed for tcp: %s",
> + strerror(errno));
> + }
> +#endif /* SO_BINDANY */
>   }
>  
>   if (bind(nsd->tcp[i].s, (struct sockaddr *) addr->ai_addr, 
> addr->ai_addrlen) != 0) {
> 
> 
> -- 
> I'm not entirely sure you are real.
> 



Re: unbound(8): make ip-transparent option work on OpenBSD

2017-11-01 Thread Sebastian Benoit
ok benno@

Florian Obser(flor...@openbsd.org) on 2017.11.01 12:00:45 +0100:
> This is useful on systems where IP addresses are dynamically
> configured (dhclient(8), slaacd(8)) and are not yet up when unbound
> starts.
> 
> To quote the man page:
> 
>ip-transparent: 
>   If yes, then use IP_TRANSPARENT socket option on sockets where
>   unbound is listening for incoming traffic.  Default no.  Allows
>   you to bind to non-local interfaces.  For example for
>   non-existant IP addresses that are going to exist later on, with
>   host failover configuration.  This is a lot like
>   interface-automatic, but that one services all interfaces and
>   with this option you can select which (future) interfaces
>   unbound provides service on.  This option needs unbound to be
>   started with root permissions on some systems.  The option uses
>   IP_BINDANY on FreeBSD systems and SO_BINDANY on OpenBSD systems.
> 
> I'm going to feed this to upstream.
> 
> OK?
> 
> diff --git doc/unbound.conf.5.in doc/unbound.conf.5.in
> index 153e4a2f921..fcad8017d73 100644
> --- doc/unbound.conf.5.in
> +++ doc/unbound.conf.5.in
> @@ -257,7 +257,8 @@ are going to exist later on, with host failover 
> configuration.  This is
>  a lot like interface\-automatic, but that one services all interfaces
>  and with this option you can select which (future) interfaces unbound
>  provides service on.  This option needs unbound to be started with root
> -permissions on some systems.  The option uses IP_BINDANY on FreeBSD systems.
> +permissions on some systems.  The option uses IP_BINDANY on FreeBSD systems
> +and SO_BINDANY on OpenBSD systems.
>  .TP
>  .B ip\-freebind: \fI
>  If yes, then use IP_FREEBIND socket option on sockets where unbound
> diff --git services/listen_dnsport.c services/listen_dnsport.c
> index 3b53676d0e0..d099ca9449b 100644
> --- services/listen_dnsport.c
> +++ services/listen_dnsport.c
> @@ -167,7 +167,7 @@ create_udp_sock(int family, int socktype, struct 
> sockaddr* addr,
>   int freebind, int use_systemd)
>  {
>   int s;
> -#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || 
> defined(IPV6_USE_MIN_MTU)  || defined(IP_TRANSPARENT) || defined(IP_BINDANY) 
> || defined(IP_FREEBIND)
> +#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || 
> defined(IPV6_USE_MIN_MTU)  || defined(IP_TRANSPARENT) || defined(IP_BINDANY) 
> || defined(IP_FREEBIND) || defined (SO_BINDANY)
>   int on=1;
>  #endif
>  #ifdef IPV6_MTU
> @@ -182,7 +182,7 @@ create_udp_sock(int family, int socktype, struct 
> sockaddr* addr,
>  #ifndef IPV6_V6ONLY
>   (void)v6only;
>  #endif
> -#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY)
> +#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY) && !defined(SO_BINDANY)
>   (void)transparent;
>  #endif
>  #if !defined(IP_FREEBIND)
> @@ -281,7 +281,14 @@ create_udp_sock(int family, int socktype, struct 
> sockaddr* addr,
>   log_warn("setsockopt(.. IP%s_BINDANY ..) failed: %s",
>   (family==AF_INET6?"V6":""), strerror(errno));
>   }
> -#endif /* IP_TRANSPARENT || IP_BINDANY */
> +#elif defined(SO_BINDANY)
> + if (transparent &&
> + setsockopt(s, SOL_SOCKET, SO_BINDANY, (void*),
> + (socklen_t)sizeof(on)) < 0) {
> + log_warn("setsockopt(.. SO_BINDANY ..) failed: %s",
> + strerror(errno));
> + }
> +#endif /* IP_TRANSPARENT || IP_BINDANY || SO_BINDANY */
>   }
>  #ifdef IP_FREEBIND
>   if(freebind &&
> @@ -592,7 +599,7 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, 
> int* noproto,
>   int* reuseport, int transparent, int mss, int freebind, int use_systemd)
>  {
>   int s;
> -#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || defined(IPV6_V6ONLY) 
> || defined(IP_TRANSPARENT) || defined(IP_BINDANY) || defined(IP_FREEBIND)
> +#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || defined(IPV6_V6ONLY) 
> || defined(IP_TRANSPARENT) || defined(IP_BINDANY) || defined(IP_FREEBIND) || 
> defined(SO_BINDANY)
>   int on = 1;
>  #endif
>  #ifdef HAVE_SYSTEMD
> @@ -601,7 +608,7 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, 
> int* noproto,
>  #ifdef USE_TCP_FASTOPEN
>   int qlen;
>  #endif
> -#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY)
> +#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY) && !defined(SO_BINDANY)
>   (void)transparent;
>  #endif
>  #if !defined(IP_FREEBIND)
> @@ -736,7 +743,14 @@ create_tcp_accept_sock(struct addrinfo *addr, int 
> v6only, int* noproto,
>   log_warn("setsockopt(.. IP%s_BINDANY ..) failed: %s",
>   (addr->ai_family==AF_INET6?"V6":""), strerror(errno));
>   }
> -#endif /* IP_TRANSPARENT || IP_BINDANY */
> +#elif defined(SO_BINDANY)
> + if (transparent &&
> + setsockopt(s, SOL_SOCKET, 

Re: unbound(8): make ip-transparent option work on OpenBSD

2017-11-01 Thread Jeremie Courreges-Anglas
On Wed, Nov 01 2017, Florian Obser  wrote:
> This is useful on systems where IP addresses are dynamically
> configured (dhclient(8), slaacd(8)) and are not yet up when unbound
> starts.
>
> To quote the man page:
>
>ip-transparent: 
>   If yes, then use IP_TRANSPARENT socket option on sockets where
>   unbound is listening for incoming traffic.  Default no.  Allows
>   you to bind to non-local interfaces.  For example for
>   non-existant IP addresses that are going to exist later on, with
>   host failover configuration.  This is a lot like
>   interface-automatic, but that one services all interfaces and
>   with this option you can select which (future) interfaces
>   unbound provides service on.  This option needs unbound to be
>   started with root permissions on some systems.  The option uses
>   IP_BINDANY on FreeBSD systems and SO_BINDANY on OpenBSD systems.
>
> I'm going to feed this to upstream.
>
> OK?

ok jca@

> diff --git doc/unbound.conf.5.in doc/unbound.conf.5.in
> index 153e4a2f921..fcad8017d73 100644
> --- doc/unbound.conf.5.in
> +++ doc/unbound.conf.5.in
> @@ -257,7 +257,8 @@ are going to exist later on, with host failover 
> configuration.  This is
>  a lot like interface\-automatic, but that one services all interfaces
>  and with this option you can select which (future) interfaces unbound
>  provides service on.  This option needs unbound to be started with root
> -permissions on some systems.  The option uses IP_BINDANY on FreeBSD systems.
> +permissions on some systems.  The option uses IP_BINDANY on FreeBSD systems
> +and SO_BINDANY on OpenBSD systems.
>  .TP
>  .B ip\-freebind: \fI
>  If yes, then use IP_FREEBIND socket option on sockets where unbound
> diff --git services/listen_dnsport.c services/listen_dnsport.c
> index 3b53676d0e0..d099ca9449b 100644
> --- services/listen_dnsport.c
> +++ services/listen_dnsport.c
> @@ -167,7 +167,7 @@ create_udp_sock(int family, int socktype, struct 
> sockaddr* addr,
>   int freebind, int use_systemd)
>  {
>   int s;
> -#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || 
> defined(IPV6_USE_MIN_MTU)  || defined(IP_TRANSPARENT) || defined(IP_BINDANY) 
> || defined(IP_FREEBIND)
> +#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || 
> defined(IPV6_USE_MIN_MTU)  || defined(IP_TRANSPARENT) || defined(IP_BINDANY) 
> || defined(IP_FREEBIND) || defined (SO_BINDANY)
>   int on=1;
>  #endif
>  #ifdef IPV6_MTU
> @@ -182,7 +182,7 @@ create_udp_sock(int family, int socktype, struct 
> sockaddr* addr,
>  #ifndef IPV6_V6ONLY
>   (void)v6only;
>  #endif
> -#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY)
> +#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY) && !defined(SO_BINDANY)
>   (void)transparent;
>  #endif
>  #if !defined(IP_FREEBIND)
> @@ -281,7 +281,14 @@ create_udp_sock(int family, int socktype, struct 
> sockaddr* addr,
>   log_warn("setsockopt(.. IP%s_BINDANY ..) failed: %s",
>   (family==AF_INET6?"V6":""), strerror(errno));
>   }
> -#endif /* IP_TRANSPARENT || IP_BINDANY */
> +#elif defined(SO_BINDANY)
> + if (transparent &&
> + setsockopt(s, SOL_SOCKET, SO_BINDANY, (void*),
> + (socklen_t)sizeof(on)) < 0) {
> + log_warn("setsockopt(.. SO_BINDANY ..) failed: %s",
> + strerror(errno));
> + }
> +#endif /* IP_TRANSPARENT || IP_BINDANY || SO_BINDANY */
>   }
>  #ifdef IP_FREEBIND
>   if(freebind &&
> @@ -592,7 +599,7 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, 
> int* noproto,
>   int* reuseport, int transparent, int mss, int freebind, int use_systemd)
>  {
>   int s;
> -#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || defined(IPV6_V6ONLY) 
> || defined(IP_TRANSPARENT) || defined(IP_BINDANY) || defined(IP_FREEBIND)
> +#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || defined(IPV6_V6ONLY) 
> || defined(IP_TRANSPARENT) || defined(IP_BINDANY) || defined(IP_FREEBIND) || 
> defined(SO_BINDANY)
>   int on = 1;
>  #endif
>  #ifdef HAVE_SYSTEMD
> @@ -601,7 +608,7 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, 
> int* noproto,
>  #ifdef USE_TCP_FASTOPEN
>   int qlen;
>  #endif
> -#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY)
> +#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY) && !defined(SO_BINDANY)
>   (void)transparent;
>  #endif
>  #if !defined(IP_FREEBIND)
> @@ -736,7 +743,14 @@ create_tcp_accept_sock(struct addrinfo *addr, int 
> v6only, int* noproto,
>   log_warn("setsockopt(.. IP%s_BINDANY ..) failed: %s",
>   (addr->ai_family==AF_INET6?"V6":""), strerror(errno));
>   }
> -#endif /* IP_TRANSPARENT || IP_BINDANY */
> +#elif defined(SO_BINDANY)
> + if (transparent &&
> + setsockopt(s, SOL_SOCKET, SO_BINDANY, 

nsd(8): make ip-transparent option work on OpenBSD

2017-11-01 Thread Florian Obser
OK?

diff --git server.c server.c
index c0835ce8c11..fe74f9a1b56 100644
--- server.c
+++ server.c
@@ -567,7 +567,7 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
int* reuseport_works)
 {
struct addrinfo* addr;
size_t i;
-#if defined(SO_REUSEPORT) || defined(SO_REUSEADDR) || (defined(INET6) && 
(defined(IPV6_V6ONLY) || defined(IPV6_USE_MIN_MTU) || defined(IPV6_MTU) || 
defined(IP_TRANSPARENT)) || defined(IP_FREEBIND))
+#if defined(SO_REUSEPORT) || defined(SO_REUSEADDR) || (defined(INET6) && 
(defined(IPV6_V6ONLY) || defined(IPV6_USE_MIN_MTU) || defined(IPV6_MTU) || 
defined(IP_TRANSPARENT)) || defined(IP_FREEBIND) || defined(SO_BINDANY))
int on = 1;
 #endif
 
@@ -757,6 +757,12 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
int* reuseport_works)
strerror(errno));
}
 #endif /* IP_TRANSPARENT */
+#ifdef SO_BINDANY
+   if (setsockopt(nsd->udp[i].s, SOL_SOCKET, SO_BINDANY, 
, sizeof(on)) < 0) {
+   log_msg(LOG_ERR, "setsockopt(...,SO_BINDANY, 
...) failed for udp: %s",
+   strerror(errno));
+   }
+#endif /* SO_BINDANY */
}
 
if (bind(nsd->udp[i].s, (struct sockaddr *) addr->ai_addr, 
addr->ai_addrlen) != 0) {
@@ -887,6 +893,12 @@ server_init_ifs(struct nsd *nsd, size_t from, size_t to, 
int* reuseport_works)
strerror(errno));
}
 #endif /* IP_TRANSPARENT */
+#ifdef SO_BINDANY
+   if (setsockopt(nsd->tcp[i].s, SOL_SOCKET, SO_BINDANY, 
, sizeof(on)) < 0) {
+   log_msg(LOG_ERR, "setsockopt(...,SO_BINDANY, 
...) failed for tcp: %s",
+   strerror(errno));
+   }
+#endif /* SO_BINDANY */
}
 
if (bind(nsd->tcp[i].s, (struct sockaddr *) addr->ai_addr, 
addr->ai_addrlen) != 0) {


-- 
I'm not entirely sure you are real.



unbound(8): make ip-transparent option work on OpenBSD

2017-11-01 Thread Florian Obser
This is useful on systems where IP addresses are dynamically
configured (dhclient(8), slaacd(8)) and are not yet up when unbound
starts.

To quote the man page:

   ip-transparent: 
  If yes, then use IP_TRANSPARENT socket option on sockets where
  unbound is listening for incoming traffic.  Default no.  Allows
  you to bind to non-local interfaces.  For example for
  non-existant IP addresses that are going to exist later on, with
  host failover configuration.  This is a lot like
  interface-automatic, but that one services all interfaces and
  with this option you can select which (future) interfaces
  unbound provides service on.  This option needs unbound to be
  started with root permissions on some systems.  The option uses
  IP_BINDANY on FreeBSD systems and SO_BINDANY on OpenBSD systems.

I'm going to feed this to upstream.

OK?

diff --git doc/unbound.conf.5.in doc/unbound.conf.5.in
index 153e4a2f921..fcad8017d73 100644
--- doc/unbound.conf.5.in
+++ doc/unbound.conf.5.in
@@ -257,7 +257,8 @@ are going to exist later on, with host failover 
configuration.  This is
 a lot like interface\-automatic, but that one services all interfaces
 and with this option you can select which (future) interfaces unbound
 provides service on.  This option needs unbound to be started with root
-permissions on some systems.  The option uses IP_BINDANY on FreeBSD systems.
+permissions on some systems.  The option uses IP_BINDANY on FreeBSD systems
+and SO_BINDANY on OpenBSD systems.
 .TP
 .B ip\-freebind: \fI
 If yes, then use IP_FREEBIND socket option on sockets where unbound
diff --git services/listen_dnsport.c services/listen_dnsport.c
index 3b53676d0e0..d099ca9449b 100644
--- services/listen_dnsport.c
+++ services/listen_dnsport.c
@@ -167,7 +167,7 @@ create_udp_sock(int family, int socktype, struct sockaddr* 
addr,
int freebind, int use_systemd)
 {
int s;
-#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || 
defined(IPV6_USE_MIN_MTU)  || defined(IP_TRANSPARENT) || defined(IP_BINDANY) || 
defined(IP_FREEBIND)
+#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || 
defined(IPV6_USE_MIN_MTU)  || defined(IP_TRANSPARENT) || defined(IP_BINDANY) || 
defined(IP_FREEBIND) || defined (SO_BINDANY)
int on=1;
 #endif
 #ifdef IPV6_MTU
@@ -182,7 +182,7 @@ create_udp_sock(int family, int socktype, struct sockaddr* 
addr,
 #ifndef IPV6_V6ONLY
(void)v6only;
 #endif
-#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY)
+#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY) && !defined(SO_BINDANY)
(void)transparent;
 #endif
 #if !defined(IP_FREEBIND)
@@ -281,7 +281,14 @@ create_udp_sock(int family, int socktype, struct sockaddr* 
addr,
log_warn("setsockopt(.. IP%s_BINDANY ..) failed: %s",
(family==AF_INET6?"V6":""), strerror(errno));
}
-#endif /* IP_TRANSPARENT || IP_BINDANY */
+#elif defined(SO_BINDANY)
+   if (transparent &&
+   setsockopt(s, SOL_SOCKET, SO_BINDANY, (void*),
+   (socklen_t)sizeof(on)) < 0) {
+   log_warn("setsockopt(.. SO_BINDANY ..) failed: %s",
+   strerror(errno));
+   }
+#endif /* IP_TRANSPARENT || IP_BINDANY || SO_BINDANY */
}
 #ifdef IP_FREEBIND
if(freebind &&
@@ -592,7 +599,7 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, 
int* noproto,
int* reuseport, int transparent, int mss, int freebind, int use_systemd)
 {
int s;
-#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || defined(IPV6_V6ONLY) || 
defined(IP_TRANSPARENT) || defined(IP_BINDANY) || defined(IP_FREEBIND)
+#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || defined(IPV6_V6ONLY) || 
defined(IP_TRANSPARENT) || defined(IP_BINDANY) || defined(IP_FREEBIND) || 
defined(SO_BINDANY)
int on = 1;
 #endif
 #ifdef HAVE_SYSTEMD
@@ -601,7 +608,7 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, 
int* noproto,
 #ifdef USE_TCP_FASTOPEN
int qlen;
 #endif
-#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY)
+#if !defined(IP_TRANSPARENT) && !defined(IP_BINDANY) && !defined(SO_BINDANY)
(void)transparent;
 #endif
 #if !defined(IP_FREEBIND)
@@ -736,7 +743,14 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, 
int* noproto,
log_warn("setsockopt(.. IP%s_BINDANY ..) failed: %s",
(addr->ai_family==AF_INET6?"V6":""), strerror(errno));
}
-#endif /* IP_TRANSPARENT || IP_BINDANY */
+#elif defined(SO_BINDANY)
+   if (transparent &&
+   setsockopt(s, SOL_SOCKET, SO_BINDANY, (void*), (socklen_t)
+   sizeof(on)) < 0) {
+   log_warn("setsockopt(.. SO_BINDANY ..) failed: %s",
+   strerror(errno));
+   }
+#endif /* IP_TRANSPARENT || IP_BINDANY || SO_BINDANY */
if(
 #ifdef