Re: pcb inet6ctlerrmap

2018-09-12 Thread Claudio Jeker
On Wed, Sep 12, 2018 at 01:08:35PM +0200, Alexander Bluhm wrote:
> On Wed, Sep 12, 2018 at 09:01:41AM +0200, Claudio Jeker wrote:
> > Why u_char instead of int? The errors in that list are used in errno which
> > is an int. So my usual feeling is to use the type which is naturally used
> > and don't try to optimize for space.
> 
> Basically I want to have it the same for inet and inet6.  The numbers
> fit, FreeBSD uses u_char for both, so why not save some memory?

My main concern is that some day someone adds a errno that is > 255 and
causes an overflow. Probability for that is close to 0 but I start to
don't like these optimisations that are gone shoot you in the foot later
on.
 
> I have already commited it with mpi@'s ok.  I don't insist on u_char,
> you can change it to int if you want.

Have seen it. Will think about it.

-- 
:wq Claudio



Re: pcb inet6ctlerrmap

2018-09-12 Thread Alexander Bluhm
On Wed, Sep 12, 2018 at 09:01:41AM +0200, Claudio Jeker wrote:
> Why u_char instead of int? The errors in that list are used in errno which
> is an int. So my usual feeling is to use the type which is naturally used
> and don't try to optimize for space.

Basically I want to have it the same for inet and inet6.  The numbers
fit, FreeBSD uses u_char for both, so why not save some memory?

I have already commited it with mpi@'s ok.  I don't insist on u_char,
you can change it to int if you want.

bluhm



Re: pcb inet6ctlerrmap

2018-09-12 Thread Claudio Jeker
On Tue, Sep 11, 2018 at 06:12:03PM +0200, Alexander Bluhm wrote:
> On Sun, Sep 09, 2018 at 09:53:59PM +0200, Alexander Bluhm wrote:
> > My goal is to get in6_pcb and in_pcb in sync.
> > 
> > Let's make both inetctlerrmap and inet6ctlerrmap u_char.  That is
> > what FreeBSD does.  There it is also in in6?_input.c.
> > 
> > FreeBSD and NetBSD have the declaration in in6?_var.h, we have it
> > in in6?.h, but I don't bother enough to move it.
> > 
> > ok?
> 
> Merged to -current.  Anyone?

Why u_char instead of int? The errors in that list are used in errno which
is an int. So my usual feeling is to use the type which is naturally used
and don't try to optimize for space.

Diff itself is OK claudio@

-- 
:wq Claudio
 
> bluhm
> 
> Index: netinet/in.h
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in.h,v
> retrieving revision 1.131
> diff -u -p -r1.131 in.h
> --- netinet/in.h  10 Jul 2018 11:34:12 -  1.131
> +++ netinet/in.h  11 Sep 2018 16:00:39 -
> @@ -795,8 +795,8 @@ __END_DECLS
>  #endif /* !_KERNEL */
>  
>  #ifdef _KERNEL
> -extern  const int inetctlerrmap[];
> -extern  const struct in_addr zeroin_addr;
> +extern const u_char inetctlerrmap[];
> +extern const struct in_addr zeroin_addr;
>  
>  struct mbuf;
>  struct sockaddr;
> Index: netinet/ip_input.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
> retrieving revision 1.340
> diff -u -p -r1.340 ip_input.c
> --- netinet/ip_input.c10 Sep 2018 16:14:07 -  1.340
> +++ netinet/ip_input.c11 Sep 2018 16:00:39 -
> @@ -1379,7 +1379,7 @@ ip_stripoptions(struct mbuf *m)
>   ip->ip_len = htons(ntohs(ip->ip_len) - olen);
>  }
>  
> -const int inetctlerrmap[PRC_NCMDS] = {
> +const u_char inetctlerrmap[PRC_NCMDS] = {
>   0,  0,  0,  0,
>   0,  EMSGSIZE,   EHOSTDOWN,  EHOSTUNREACH,
>   EHOSTUNREACH,   EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
> Index: netinet6/in6.h
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6.h,v
> retrieving revision 1.102
> diff -u -p -r1.102 in6.h
> --- netinet6/in6.h7 Jun 2018 08:46:24 -   1.102
> +++ netinet6/in6.h11 Sep 2018 16:00:39 -
> @@ -404,8 +404,8 @@ typedef   __socklen_t socklen_t;  /* length
>  #endif /* __BSD_VISIBLE */
>  
>  #ifdef _KERNEL
> -extern   const u_char inet6ctlerrmap[];
> -extern   const struct in6_addr zeroin6_addr;
> +extern const u_char inet6ctlerrmap[];
> +extern const struct in6_addr zeroin6_addr;
>  
>  struct mbuf;
>  struct ifnet;
> Index: netinet6/in6_pcb.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_pcb.c,v
> retrieving revision 1.105
> diff -u -p -r1.105 in6_pcb.c
> --- netinet6/in6_pcb.c11 Sep 2018 14:34:49 -  1.105
> +++ netinet6/in6_pcb.c11 Sep 2018 16:00:39 -
> @@ -119,31 +119,7 @@
>  
>  #include 
>  
> -/*
> - * External globals
> - */
> -
> -/*
> - * Globals
> - */
> -
>  const struct in6_addr zeroin6_addr;
> -
> -/*
> - * Keep separate inet6ctlerrmap, because I may remap some of these.
> - * I also put it here, because, quite frankly, it belongs here, not in
> - * ip{v6,}_input().
> - */
> -#if 0
> -u_char inet6ctlerrmap[PRC_NCMDS] = {
> - 0,  0,  0,  0,
> - 0,  EMSGSIZE,   EHOSTDOWN,  EHOSTUNREACH,
> - EHOSTUNREACH,   EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
> - EMSGSIZE,   EHOSTUNREACH,   0,  0,
> - 0,  0,  0,  0,
> - ENOPROTOOPT
> -};
> -#endif
>  
>  struct inpcbhead *
>  in6_pcbhash(struct inpcbtable *table, int rdom,
> 



Re: pcb inet6ctlerrmap

2018-09-11 Thread Alexander Bluhm
On Sun, Sep 09, 2018 at 09:53:59PM +0200, Alexander Bluhm wrote:
> My goal is to get in6_pcb and in_pcb in sync.
> 
> Let's make both inetctlerrmap and inet6ctlerrmap u_char.  That is
> what FreeBSD does.  There it is also in in6?_input.c.
> 
> FreeBSD and NetBSD have the declaration in in6?_var.h, we have it
> in in6?.h, but I don't bother enough to move it.
> 
> ok?

Merged to -current.  Anyone?

bluhm

Index: netinet/in.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in.h,v
retrieving revision 1.131
diff -u -p -r1.131 in.h
--- netinet/in.h10 Jul 2018 11:34:12 -  1.131
+++ netinet/in.h11 Sep 2018 16:00:39 -
@@ -795,8 +795,8 @@ __END_DECLS
 #endif /* !_KERNEL */
 
 #ifdef _KERNEL
-externconst int inetctlerrmap[];
-externconst struct in_addr zeroin_addr;
+extern const u_char inetctlerrmap[];
+extern const struct in_addr zeroin_addr;
 
 struct mbuf;
 struct sockaddr;
Index: netinet/ip_input.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.340
diff -u -p -r1.340 ip_input.c
--- netinet/ip_input.c  10 Sep 2018 16:14:07 -  1.340
+++ netinet/ip_input.c  11 Sep 2018 16:00:39 -
@@ -1379,7 +1379,7 @@ ip_stripoptions(struct mbuf *m)
ip->ip_len = htons(ntohs(ip->ip_len) - olen);
 }
 
-const int inetctlerrmap[PRC_NCMDS] = {
+const u_char inetctlerrmap[PRC_NCMDS] = {
0,  0,  0,  0,
0,  EMSGSIZE,   EHOSTDOWN,  EHOSTUNREACH,
EHOSTUNREACH,   EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
Index: netinet6/in6.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6.h,v
retrieving revision 1.102
diff -u -p -r1.102 in6.h
--- netinet6/in6.h  7 Jun 2018 08:46:24 -   1.102
+++ netinet6/in6.h  11 Sep 2018 16:00:39 -
@@ -404,8 +404,8 @@ typedef __socklen_t socklen_t;  /* length
 #endif /* __BSD_VISIBLE */
 
 #ifdef _KERNEL
-extern const u_char inet6ctlerrmap[];
-extern const struct in6_addr zeroin6_addr;
+extern const u_char inet6ctlerrmap[];
+extern const struct in6_addr zeroin6_addr;
 
 struct mbuf;
 struct ifnet;
Index: netinet6/in6_pcb.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_pcb.c,v
retrieving revision 1.105
diff -u -p -r1.105 in6_pcb.c
--- netinet6/in6_pcb.c  11 Sep 2018 14:34:49 -  1.105
+++ netinet6/in6_pcb.c  11 Sep 2018 16:00:39 -
@@ -119,31 +119,7 @@
 
 #include 
 
-/*
- * External globals
- */
-
-/*
- * Globals
- */
-
 const struct in6_addr zeroin6_addr;
-
-/*
- * Keep separate inet6ctlerrmap, because I may remap some of these.
- * I also put it here, because, quite frankly, it belongs here, not in
- * ip{v6,}_input().
- */
-#if 0
-u_char inet6ctlerrmap[PRC_NCMDS] = {
-   0,  0,  0,  0,
-   0,  EMSGSIZE,   EHOSTDOWN,  EHOSTUNREACH,
-   EHOSTUNREACH,   EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
-   EMSGSIZE,   EHOSTUNREACH,   0,  0,
-   0,  0,  0,  0,
-   ENOPROTOOPT
-};
-#endif
 
 struct inpcbhead *
 in6_pcbhash(struct inpcbtable *table, int rdom,



pcb inet6ctlerrmap

2018-09-09 Thread Alexander Bluhm
Hi,

My goal is to get in6_pcb and in_pcb in sync.

Let's make both inetctlerrmap and inet6ctlerrmap u_char.  That is
what FreeBSD does.  There it is also in in6?_input.c.

FreeBSD and NetBSD have the declaration in in6?_var.h, we have it
in in6?.h, but I don't bother enough to move it.

ok?

bluhm

Index: netinet/in.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in.h,v
retrieving revision 1.131
diff -u -p -r1.131 in.h
--- netinet/in.h10 Jul 2018 11:34:12 -  1.131
+++ netinet/in.h9 Sep 2018 15:39:32 -
@@ -795,8 +795,8 @@ __END_DECLS
 #endif /* !_KERNEL */
 
 #ifdef _KERNEL
-externconst int inetctlerrmap[];
-externconst struct in_addr zeroin_addr;
+extern const u_char inetctlerrmap[];
+extern const struct in_addr zeroin_addr;
 
 struct mbuf;
 struct sockaddr;
Index: netinet/in_pcb.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.c,v
retrieving revision 1.241
diff -u -p -r1.241 in_pcb.c
--- netinet/in_pcb.c7 Sep 2018 10:55:35 -   1.241
+++ netinet/in_pcb.c9 Sep 2018 15:21:24 -
@@ -98,7 +98,6 @@
 
 #ifdef INET6
 #include 
-#include 
 #endif /* INET6 */
 #ifdef IPSEC
 #include 
Index: netinet/ip_input.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.338
diff -u -p -r1.338 ip_input.c
--- netinet/ip_input.c  10 Jul 2018 11:34:12 -  1.338
+++ netinet/ip_input.c  9 Sep 2018 15:40:38 -
@@ -1384,7 +1384,7 @@ ip_stripoptions(struct mbuf *m)
ip->ip_len = htons(ntohs(ip->ip_len) - olen);
 }
 
-const int inetctlerrmap[PRC_NCMDS] = {
+const u_char inetctlerrmap[PRC_NCMDS] = {
0,  0,  0,  0,
0,  EMSGSIZE,   EHOSTDOWN,  EHOSTUNREACH,
EHOSTUNREACH,   EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
Index: netinet6/in6.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6.h,v
retrieving revision 1.102
diff -u -p -r1.102 in6.h
--- netinet6/in6.h  7 Jun 2018 08:46:24 -   1.102
+++ netinet6/in6.h  9 Sep 2018 15:39:16 -
@@ -404,8 +404,8 @@ typedef __socklen_t socklen_t;  /* length
 #endif /* __BSD_VISIBLE */
 
 #ifdef _KERNEL
-extern const u_char inet6ctlerrmap[];
-extern const struct in6_addr zeroin6_addr;
+extern const u_char inet6ctlerrmap[];
+extern const struct in6_addr zeroin6_addr;
 
 struct mbuf;
 struct ifnet;
Index: netinet6/in6_pcb.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_pcb.c,v
retrieving revision 1.104
diff -u -p -r1.104 in6_pcb.c
--- netinet6/in6_pcb.c  14 Jun 2018 17:00:58 -  1.104
+++ netinet6/in6_pcb.c  9 Sep 2018 15:39:58 -
@@ -124,31 +124,7 @@
 #include 
 #include 
 
-/*
- * External globals
- */
-
-/*
- * Globals
- */
-
 const struct in6_addr zeroin6_addr;
-
-/*
- * Keep separate inet6ctlerrmap, because I may remap some of these.
- * I also put it here, because, quite frankly, it belongs here, not in
- * ip{v6,}_input().
- */
-#if 0
-u_char inet6ctlerrmap[PRC_NCMDS] = {
-   0,  0,  0,  0,
-   0,  EMSGSIZE,   EHOSTDOWN,  EHOSTUNREACH,
-   EHOSTUNREACH,   EHOSTUNREACH,   ECONNREFUSED,   ECONNREFUSED,
-   EMSGSIZE,   EHOSTUNREACH,   0,  0,
-   0,  0,  0,  0,
-   ENOPROTOOPT
-};
-#endif
 
 int
 in6_pcbaddrisavail(struct inpcb *inp, struct sockaddr_in6 *sin6, int wild,