If you're trying to utilize multiple links for aggregation, etc., you have to
ensure that the packets get hashed differently. Currently we use MAC address
and IP address, but not port numbers. This makes it challenging to connect two
servers unless you jump through some hoops and assign multiple IPs, and
you're still left with the challenge of balancing across IPs, which will not
be the default behavior for most clients. Adding the port numbers into the mix
means each connection still goes over a single link, but at least if I use ftp
to download two files, there's a chance they will be on separate links.

As far as I know, this is mostly within spec. There's some question of how it
handles fragments, but practically speaking I expect fragments to be rare? I
didn't find previous discussion of adding this to trunk, so I thought I'd
bring it up. Diff below is poc, could also do udp/ipv6/etc.


Index: if_trunk.c
===================================================================
RCS file: /cvs/src/sys/net/if_trunk.c,v
retrieving revision 1.125
diff -u -p -r1.125 if_trunk.c
--- if_trunk.c  21 Nov 2015 11:02:23 -0000      1.125
+++ if_trunk.c  1 Jan 2016 16:15:21 -0000
@@ -994,6 +994,16 @@ trunk_hashmbuf(struct mbuf *m, SIPHASH_K
                        return (p);
                SipHash24_Update(&ctx, &ip->ip_src, sizeof(struct in_addr));
                SipHash24_Update(&ctx, &ip->ip_dst, sizeof(struct in_addr));
+               if (ip->ip_p == IPPROTO_TCP) {
+                       struct tcpiphdr *tp, tcpbuf;
+                       if ((tp = (struct tcpiphdr *)
+                           trunk_gethdr(m, off, sizeof(*tp), &tcpbuf))) {
+                               SipHash24_Update(&ctx, &tp->ti_sport,
+                                   sizeof(uint16_t));
+                               SipHash24_Update(&ctx, &tp->ti_dport,
+                                   sizeof(uint16_t));
+                       }
+               }
                break;
 #ifdef INET6
        case ETHERTYPE_IPV6:

Reply via email to