Re: svn commit: r334671 - in head/sys: net netinet netinet6 netipsec

2018-06-05 Thread Matthew Macy
This appears to have broken the NOINET build.

--- ip6_gre.o ---
cc -target i386-unknown-freebsd12.0
--sysroot=/home/mmacy/devel/build/home/mmacy/networking/i386.i386/tmp
-B/home/mmacy/devel/build/home/mmacy/networking/i386.i386/tmp/usr/bin
-O2 -pipe  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE
-nostdinc   -DHAVE_KERNEL_OPTION_HEADERS -include
/home/mmacy/devel/build/home/mmacy/networking/i386.i386/sys/LINT-NOINET/opt_global.h
-I. -I/home/mmacy/networking/sys
-I/home/mmacy/networking/sys/contrib/ck/include -fno-common
-I/home/mmacy/devel/build/home/mmacy/networking/i386.i386/sys/LINT-NOINET
 -fno-builtin -MD  -MF.depend.ip6_gre.o -MTip6_gre.o -mno-mmx -mno-sse
-msoft-float -ffreestanding -fwrapv -fstack-protector -Wall
-Wredundant-decls -Wnested-externs -Wstrict-prototypes
-Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef
-Wno-pointer-sign -D__printf__=__freebsd_kprintf__
-Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas
-Wno-error-tautological-compare -Wno-error-empty-body
-Wno-error-parentheses-equality -Wno-error-unused-function
-Wno-error-pointer-sign -Wno-error-shift-negative-value
-Wno-address-of-packed-member  -mno-aes -mno-avx  -std=iso9899:1999 -c
/home/mmacy/networking/sys/netinet6/ip6_gre.c -o ip6_gre.o
/home/mmacy/networking/sys/netinet6/ip6_gre.c:125:40: error: invalid
application of 'sizeof' to an incomplete type 'struct ip'
.min_length = sizeof(struct greip6) + sizeof(struct ip),
  ^ ~~~
/home/mmacy/networking/sys/netinet6/ip6_gre.c:125:54: note: forward
declaration of 'struct ip'
.min_length = sizeof(struct greip6) + sizeof(struct ip),
^
1 error generated.
--- if_ath_led.o --

On Tue, Jun 5, 2018 at 1:51 PM, Andrey V. Elsukov  wrote:
> Author: ae
> Date: Tue Jun  5 20:51:01 2018
> New Revision: 334671
> URL: https://svnweb.freebsd.org/changeset/base/334671
>
> Log:
>   Rework IP encapsulation handling code.
>
>   Currently it has several disadvantages:
>   - it uses single mutex to protect internal structures. It is used by
> data- and control- path, thus there are no parallelism at all.
>   - it uses single list to keep encap handlers for both INET and INET6
> families.
>   - struct encaptab keeps unneeded information (src, dst, masks, protosw),
> that isn't used by code in the source tree.
>   - matches are prioritized and when many tunneling interfaces are
> registered, encapcheck handler of each interface is invoked for each
> packet. The search takes O(n) for n interfaces. All this work is done
> with exclusive lock held.
>
>   What this patch includes:
>   - the datapath is converted to be lockless using epoch(9) KPI.
>   - struct encaptab now linked using CK_LIST.
>   - all unused fields removed from struct encaptab. Several new fields
> addedr: min_length is the minimum packet length, that encapsulation
> handler expects to see; exact_match is maximum number of bits, that
> can return an encapsulation handler, when it wants to consume a packet.
>   - IPv6 and IPv4 handlers are stored in separate lists;
>   - added new "encap_lookup_t" method, that will be used later. It is
> targeted to speedup lookup of needed interface, when gif(4)/gre(4) have
> many interfaces.
>   - the need to use protosw structure is eliminated. The only pr_input
> method was used from this structure, so I don't see the need to keep
> using it.
>   - encap_input_t method changed to avoid using mbuf tags to store softc
> pointer. Now it is passed directly trough encap_input_t method.
> encap_getarg() funtions is removed.
>   - all sockaddr structures and code that uses them removed. We don't have
> any code in the tree that uses them. All consumers use encap_attach_func()
> method, that relies on invoking of encapcheck() to determine the needed
> handler.
>   - introduced struct encap_config, it contains parameters of encap handler
> that is going to be registered by encap_attach() function.
>   - encap handlers are stored in lists ordered by exact_match value, thus
> handlers that need more bits to match will be checked first, and if
> encapcheck method returns exact_match value, the search will be stopped.
>   - all current consumers changed to use new KPI.
>
>   Reviewed by:  mmacy
>   Sponsored by: Yandex LLC
>   Differential Revision:https://reviews.freebsd.org/D15617
>
> Modified:
>   head/sys/net/if_gif.c
>   head/sys/net/if_gre.c
>   head/sys/net/if_gre.h
>   head/sys/net/if_me.c
>   head/sys/net/if_stf.c
>   head/sys/netinet/in_gif.c
>   head/sys/netinet/ip_encap.c
>   head/sys/netinet/ip_encap.h
>   head/sys/netinet/ip_gre.c
>   head/sys/netinet/ip_mroute.c
>   head/sys/netinet/pim_var.h
>   head/sys/netinet6/in6_gif.c
>   head/sys/netinet6/ip6_gre.c
>   head/sys/netinet6/ip6_mroute.c
>   head/sys/netinet6/pim6_var.h
>   

svn commit: r334671 - in head/sys: net netinet netinet6 netipsec

2018-06-05 Thread Andrey V. Elsukov
Author: ae
Date: Tue Jun  5 20:51:01 2018
New Revision: 334671
URL: https://svnweb.freebsd.org/changeset/base/334671

Log:
  Rework IP encapsulation handling code.
  
  Currently it has several disadvantages:
  - it uses single mutex to protect internal structures. It is used by
data- and control- path, thus there are no parallelism at all.
  - it uses single list to keep encap handlers for both INET and INET6
families.
  - struct encaptab keeps unneeded information (src, dst, masks, protosw),
that isn't used by code in the source tree.
  - matches are prioritized and when many tunneling interfaces are
registered, encapcheck handler of each interface is invoked for each
packet. The search takes O(n) for n interfaces. All this work is done
with exclusive lock held.
  
  What this patch includes:
  - the datapath is converted to be lockless using epoch(9) KPI.
  - struct encaptab now linked using CK_LIST.
  - all unused fields removed from struct encaptab. Several new fields
addedr: min_length is the minimum packet length, that encapsulation
handler expects to see; exact_match is maximum number of bits, that
can return an encapsulation handler, when it wants to consume a packet.
  - IPv6 and IPv4 handlers are stored in separate lists;
  - added new "encap_lookup_t" method, that will be used later. It is
targeted to speedup lookup of needed interface, when gif(4)/gre(4) have
many interfaces.
  - the need to use protosw structure is eliminated. The only pr_input
method was used from this structure, so I don't see the need to keep
using it.
  - encap_input_t method changed to avoid using mbuf tags to store softc
pointer. Now it is passed directly trough encap_input_t method.
encap_getarg() funtions is removed.
  - all sockaddr structures and code that uses them removed. We don't have
any code in the tree that uses them. All consumers use encap_attach_func()
method, that relies on invoking of encapcheck() to determine the needed
handler.
  - introduced struct encap_config, it contains parameters of encap handler
that is going to be registered by encap_attach() function.
  - encap handlers are stored in lists ordered by exact_match value, thus
handlers that need more bits to match will be checked first, and if
encapcheck method returns exact_match value, the search will be stopped.
  - all current consumers changed to use new KPI.
  
  Reviewed by:  mmacy
  Sponsored by: Yandex LLC
  Differential Revision:https://reviews.freebsd.org/D15617

Modified:
  head/sys/net/if_gif.c
  head/sys/net/if_gre.c
  head/sys/net/if_gre.h
  head/sys/net/if_me.c
  head/sys/net/if_stf.c
  head/sys/netinet/in_gif.c
  head/sys/netinet/ip_encap.c
  head/sys/netinet/ip_encap.h
  head/sys/netinet/ip_gre.c
  head/sys/netinet/ip_mroute.c
  head/sys/netinet/pim_var.h
  head/sys/netinet6/in6_gif.c
  head/sys/netinet6/ip6_gre.c
  head/sys/netinet6/ip6_mroute.c
  head/sys/netinet6/pim6_var.h
  head/sys/netipsec/xform_ipcomp.c

Modified: head/sys/net/if_gif.c
==
--- head/sys/net/if_gif.c   Tue Jun  5 20:41:06 2018(r334670)
+++ head/sys/net/if_gif.c   Tue Jun  5 20:51:01 2018(r334671)
@@ -923,12 +923,24 @@ bad:
 }
 
 static void
-gif_detach(struct gif_softc *sc)
+gif_detach(struct gif_softc *sc, int family)
 {
 
sx_assert(_ioctl_sx, SA_XLOCKED);
-   if (sc->gif_ecookie != NULL)
-   encap_detach(sc->gif_ecookie);
+   if (sc->gif_ecookie != NULL) {
+   switch (family) {
+#ifdef INET
+   case AF_INET:
+   ip_encap_detach(sc->gif_ecookie);
+   break;
+#endif
+#ifdef INET6
+   case AF_INET6:
+   ip6_encap_detach(sc->gif_ecookie);
+   break;
+#endif
+   }
+   }
sc->gif_ecookie = NULL;
 }
 
@@ -1020,7 +1032,7 @@ gif_set_tunnel(struct ifnet *ifp, struct sockaddr *src
}
 
if (sc->gif_family != src->sa_family)
-   gif_detach(sc);
+   gif_detach(sc, sc->gif_family);
if (sc->gif_family == 0 ||
sc->gif_family != src->sa_family)
error = gif_attach(sc, src->sa_family);
@@ -1058,7 +1070,7 @@ gif_delete_tunnel(struct ifnet *ifp)
sc->gif_family = 0;
GIF_WUNLOCK(sc);
if (family != 0) {
-   gif_detach(sc);
+   gif_detach(sc, family);
free(sc->gif_hdr, M_GIF);
}
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;

Modified: head/sys/net/if_gre.c
==
--- head/sys/net/if_gre.c   Tue Jun  5 20:41:06 2018(r334670)
+++ head/sys/net/if_gre.c   Tue Jun  5 20:51:01 2018(r334671)
@@ -551,12 +551,24 @@ gre_updatehdr(struct gre_softc *sc)
 }
 
 static void
-gre_detach(struct gre_softc