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

2016-08-31 Thread Slawa Olhovchenkov
On Thu, Mar 24, 2016 at 07:54:56AM +, George V. Neville-Neil wrote:

> Author: gnn
> Date: Thu Mar 24 07:54:56 2016
> New Revision: 297225
> URL: https://svnweb.freebsd.org/changeset/base/297225
> 
> Log:
>   FreeBSD previously provided route caching for TCP (and UDP). Re-add
>   route caching for TCP, with some improvements. In particular, invalidate
>   the route cache if a new route is added, which might be a better match.
>   The cache is automatically invalidated if the old route is deleted.
>   
>   Submitted by:   Mike Karels
>   Reviewed by:gnn
>   Differential Revision:  https://reviews.freebsd.org/D4306

Can this mergered to stable/10 (in private branch, I mean ABI breakage)?
Have any dependecis of this commit?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2016-03-25 Thread Adrian Chadd
[snip]

The thing flowtable gave you is the ability to set a per connection
(L4 match) to be able to set a destination MAC to forward to - so you
COULD build a complete load balancer in kernel.

Gleb stripped out the L4 bits to simplify it for netflix, which
removed that functionality.

I'd love to see it re-added back in and a userland API to let us do
that - then yes, we can build kernel load balancers for this stuff.

-a
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2016-03-25 Thread Bjoern A. Zeeb

On Thu, 24 Mar 2016, Gleb Smirnoff wrote:


On Thu, Mar 24, 2016 at 07:54:56AM +, George V. Neville-Neil wrote:
G> Author: gnn
G> Date: Thu Mar 24 07:54:56 2016
G> New Revision: 297225
G> URL: https://svnweb.freebsd.org/changeset/base/297225
G>
G> Log:
G>   FreeBSD previously provided route caching for TCP (and UDP). Re-add
G>   route caching for TCP, with some improvements. In particular, invalidate
G>   the route cache if a new route is added, which might be a better match.
G>   The cache is automatically invalidated if the old route is deleted.
G>
G>   Submitted by:   Mike Karels
G>   Reviewed by:gnn
G>   Differential Revision:  https://reviews.freebsd.org/D4306

I'm quite surprised to see this checked in, taking into account that the
D4306 has strong disagreement from melifaro@.

So, now we got two aids for poor routing: TCP route caching & flowtable.


I am uncertain by what you mean when you say "routing".

For as forwarding is concerned, this doesn't matter.

For as local connections are concerned, this is the start to scale
again.  You are saving 1-2 route lookups per first packet and 2-3
route lookups for any subsequent packet.  Worst case scenario your FIB
changes for each packet still improves the situation as in the first
packet situation.

Every lookup I don't have to do I don't have optimize a system for as
badly as I would otherwise have to.

Flowtable in my view, once this is fully flashed out, has no real
reason to be used anymore.

Everything else I think my initial reply and gnn's reply has covered.

/bz
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2016-03-24 Thread George V. Neville-Neil


On 03/24/16 04:31 PM, Gleb Smirnoff wrote:
> On Thu, Mar 24, 2016 at 07:54:56AM +, George V. Neville-Neil wrote:
> G> Author: gnn
> G> Date: Thu Mar 24 07:54:56 2016
> G> New Revision: 297225
> G> URL: https://svnweb.freebsd.org/changeset/base/297225
> G> 
> G> Log:
> G>   FreeBSD previously provided route caching for TCP (and UDP). Re-add
> G>   route caching for TCP, with some improvements. In particular, invalidate
> G>   the route cache if a new route is added, which might be a better match.
> G>   The cache is automatically invalidated if the old route is deleted.
> G>   
> G>   Submitted by:Mike Karels
> G>   Reviewed by: gnn
> G>   Differential Revision:   https://reviews.freebsd.org/D4306
>
> I'm quite surprised to see this checked in, taking into account that the
> D4306 has strong disagreement from melifaro@.
>
> So, now we got two aids for poor routing: TCP route caching & flowtable.
>
Given that melifaro@ has not responded to emails from several folks for
several weeks I pushed this in so that we could a) break the tie and b)
have a place to start for improvement.  The status quo was unacceptable.

Best,
George

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2016-03-24 Thread Gleb Smirnoff
On Thu, Mar 24, 2016 at 07:54:56AM +, George V. Neville-Neil wrote:
G> Author: gnn
G> Date: Thu Mar 24 07:54:56 2016
G> New Revision: 297225
G> URL: https://svnweb.freebsd.org/changeset/base/297225
G> 
G> Log:
G>   FreeBSD previously provided route caching for TCP (and UDP). Re-add
G>   route caching for TCP, with some improvements. In particular, invalidate
G>   the route cache if a new route is added, which might be a better match.
G>   The cache is automatically invalidated if the old route is deleted.
G>   
G>   Submitted by:  Mike Karels
G>   Reviewed by:   gnn
G>   Differential Revision: https://reviews.freebsd.org/D4306

I'm quite surprised to see this checked in, taking into account that the
D4306 has strong disagreement from melifaro@.

So, now we got two aids for poor routing: TCP route caching & flowtable.

-- 
Totus tuus, Glebius.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2016-03-24 Thread Bjoern A. Zeeb

On Thu, 24 Mar 2016, George V. Neville-Neil wrote:


Author: gnn
Date: Thu Mar 24 07:54:56 2016
New Revision: 297225
URL: https://svnweb.freebsd.org/changeset/base/297225

Log:
 FreeBSD previously provided route caching for TCP (and UDP). Re-add
 route caching for TCP, with some improvements. In particular, invalidate
 the route cache if a new route is added, which might be a better match.
 The cache is automatically invalidated if the old route is deleted.

 Submitted by:  Mike Karels
 Reviewed by:   gnn
 Differential Revision: https://reviews.freebsd.org/D4306


I'll try to fix at least the compiler errors for you now ...

For everything else we'll see how to go from here.  I guess this
commit will at least unbreak the tie ;-)

--
Bjoern A. Zeeb "Come on. Learn, goddamn it.", WarGames, 1983
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r297225 - in head/sys: net netinet netinet6

2016-03-24 Thread George V. Neville-Neil
Author: gnn
Date: Thu Mar 24 07:54:56 2016
New Revision: 297225
URL: https://svnweb.freebsd.org/changeset/base/297225

Log:
  FreeBSD previously provided route caching for TCP (and UDP). Re-add
  route caching for TCP, with some improvements. In particular, invalidate
  the route cache if a new route is added, which might be a better match.
  The cache is automatically invalidated if the old route is deleted.
  
  Submitted by: Mike Karels
  Reviewed by:  gnn
  Differential Revision:https://reviews.freebsd.org/D4306

Modified:
  head/sys/net/route.c
  head/sys/net/route.h
  head/sys/net/route_var.h
  head/sys/netinet/in_pcb.c
  head/sys/netinet/in_pcb.h
  head/sys/netinet/ip_output.c
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet6/in6_pcb.c
  head/sys/netinet6/ip6_output.c
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/net/route.c
==
--- head/sys/net/route.cThu Mar 24 07:24:33 2016(r297224)
+++ head/sys/net/route.cThu Mar 24 07:54:56 2016(r297225)
@@ -201,6 +201,16 @@ rt_tables_get_rnh(int table, int fam)
return (*rt_tables_get_rnh_ptr(table, fam));
 }
 
+rt_gen_t
+rt_tables_get_gen(int table, int fam)
+{
+   struct rib_head *rnh;
+
+   rnh = *rt_tables_get_rnh_ptr(table, fam);
+   return (rnh->rnh_gen);
+}
+
+
 /*
  * route initialization must occur before ip6_init2(), which happenas at
  * SI_ORDER_MIDDLE.
@@ -1754,6 +1764,7 @@ rtrequest1_fib(int req, struct rt_addrin
*ret_nrt = rt;
RT_ADDREF(rt);
}
+   rnh->rnh_gen++; /* Routing table updated */
RT_UNLOCK(rt);
break;
case RTM_CHANGE:

Modified: head/sys/net/route.h
==
--- head/sys/net/route.hThu Mar 24 07:24:33 2016(r297224)
+++ head/sys/net/route.hThu Mar 24 07:54:56 2016(r297225)
@@ -98,6 +98,14 @@ struct rt_metrics {
 /* lle state is exported in rmx_state rt_metrics field */
 #definermx_state   rmx_weight
 
+/*
+ * Keep a generation count of routing table, incremented on route addition,
+ * so we can invalidate caches.  This is accessed without a lock, as precision
+ * is not required.
+ */
+typedef volatile u_int rt_gen_t;   /* tree generation (for adds) */
+#define RT_GEN(fibnum, af) rt_tables_get_gen(fibnum, af)
+
 #defineRT_DEFAULT_FIB  0   /* Explicitly mark fib=0 restricted 
cases */
 #defineRT_ALL_FIBS -1  /* Announce event for every fib */
 #ifdef _KERNEL
@@ -398,6 +406,20 @@ struct rt_addrinfo {
}   \
 } while (0)
 
+/*
+ * Validate a cached route based on a supplied cookie.  If there is an
+ * out-of-date cache, simply free it.  Update the generation number
+ * for the new allocation
+ */
+#define RT_VALIDATE(ro, cookiep, fibnum) do {  \
+   rt_gen_t cookie = RT_GEN(fibnum, (ro)->ro_dst.sa_family);   \
+   if (*(cookiep) != cookie && (ro)->ro_rt != NULL) {  \
+   RTFREE((ro)->ro_rt);\
+   (ro)->ro_rt = NULL; \
+   *(cookiep) = cookie;\
+   }   \
+} while (0)
+
 struct ifmultiaddr;
 struct rib_head;
 
@@ -415,6 +437,7 @@ int  rt_setgate(struct rtentry *, struct
 voidrt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *);
 struct rib_head *rt_table_init(int);
 void   rt_table_destroy(struct rib_head *);
+rt_gen_t rt_tables_get_gen(int table, int fam);
 
 intrtsock_addrmsg(int, struct ifaddr *, int);
 intrtsock_routemsg(int, struct ifnet *ifp, int, struct rtentry *, int);

Modified: head/sys/net/route_var.h
==
--- head/sys/net/route_var.hThu Mar 24 07:24:33 2016(r297224)
+++ head/sys/net/route_var.hThu Mar 24 07:54:56 2016(r297225)
@@ -41,7 +41,7 @@ struct rib_head {
rn_walktree_t   *rnh_walktree;  /* traverse tree */
rn_walktree_from_t  *rnh_walktree_from; /* traverse tree below a */
rn_close_t  *rnh_close; /*do something when the last 
ref drops*/
-   u_int   rnh_gen;/* generation counter */
+   rt_gen_trnh_gen;/* generation counter */
int rnh_multipath;  /* multipath capable ? */
struct radix_node   rnh_nodes[3];   /* empty tree for common case */
struct rwlock   rib_lock;   /* config/data path lock */

Modified: head/sys/netinet/