From owner-svn-src-user@FreeBSD.ORG Sat Feb 6 23:00:19 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DDB21065670; Sat, 6 Feb 2010 23:00:19 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F15AC8FC16; Sat, 6 Feb 2010 23:00:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o16N0I7S064489; Sat, 6 Feb 2010 23:00:18 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o16N0IoN064486; Sat, 6 Feb 2010 23:00:18 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <201002062300.o16N0IoN064486@svn.freebsd.org> From: Kip Macy Date: Sat, 6 Feb 2010 23:00:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203577 - user/kmacy/head_flowtable_v6/sys/net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Feb 2010 23:00:19 -0000 Author: kmacy Date: Sat Feb 6 23:00:18 2010 New Revision: 203577 URL: http://svn.freebsd.org/changeset/base/203577 Log: - remove stale ipv6 comment on flow lookup - add per-flowtable debug logging Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c user/kmacy/head_flowtable_v6/sys/net/flowtable.h Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.c ============================================================================== --- user/kmacy/head_flowtable_v6/sys/net/flowtable.c Sat Feb 6 22:57:24 2010 (r203576) +++ user/kmacy/head_flowtable_v6/sys/net/flowtable.c Sat Feb 6 23:00:18 2010 (r203577) @@ -187,12 +187,24 @@ static struct cv flowclean_cv; static struct mtx flowclean_lock; static uint32_t flowclean_cycles; +#ifdef FLOWTABLE_DEBUG +#define FLDPRINTF(ft, fmt, ...) \ +do { \ + if ((ft)->ft_flags & FL_DEBUG) \ + printf((fmt), __VA_ARGS__); \ +} while (0); \ + +#else +#define FLDPRINTF(ft, fmt, ...) + +#endif + + /* * TODO: * - Make flowtable stats per-cpu, aggregated at sysctl call time, * to avoid extra cache evictions caused by incrementing a shared * counter - * - add IPv6 support to flow lookup * - add sysctls to resize && flush flow tables * - Add per flowtable sysctls for statistics and configuring timeouts * - add saturation counter to rtentry to support per-packet load-balancing @@ -441,8 +453,8 @@ flow_to_route(struct flentry *fle, struc #ifdef INET static int -ipv4_mbuf_demarshal(struct mbuf *m, struct sockaddr_in *ssin, - struct sockaddr_in *dsin, uint16_t *flags) +ipv4_mbuf_demarshal(struct flowtable *ft, struct mbuf *m, + struct sockaddr_in *ssin, struct sockaddr_in *dsin, uint16_t *flags) { struct ip *ip; uint8_t proto; @@ -461,8 +473,11 @@ ipv4_mbuf_demarshal(struct mbuf *m, stru ssin->sin_len = sizeof(*dsin); ssin->sin_addr = ip->ip_dst; - if ((*flags & FL_HASH_ALL) == 0) + if ((*flags & FL_HASH_ALL) == 0) { + FLDPRINTF(ft, "skip port check flags=0x%x ", + *flags); goto skipports; + } proto = ip->ip_p; iphlen = ip->ip_hl << 2; /* XXX options? */ @@ -487,6 +502,7 @@ ipv4_mbuf_demarshal(struct mbuf *m, stru dport = sh->dest_port; break; default: + FLDPRINTF(ft, "proto=0x%x not supported\n", proto); return (ENOTSUP); /* no port - hence not a protocol we care about */ break; @@ -497,6 +513,19 @@ ipv4_mbuf_demarshal(struct mbuf *m, stru skipports: ssin->sin_port = sport; dsin->sin_port = dport; +#ifdef FLOWTABLE_DEBUG + if (*flags & FL_HASH_ALL) { + char saddr[4*sizeof "123"], daddr[4*sizeof "123"]; + inet_ntoa_r(*(struct in_addr *) &ip->ip_dst, daddr); + inet_ntoa_r(*(struct in_addr *) &ip->ip_src, saddr); + FLDPRINTF(ft, "proto=%d %s:%d->%s:%d\n", + proto, saddr, ntohs(sport), daddr, ntohs(dport)); + } else { + char daddr[4*sizeof "123"]; + inet_ntoa_r(*(struct in_addr *) &ip->ip_dst, daddr); + FLDPRINTF(ft, "proto=%d %s\n", proto, daddr); + } +#endif return (0); } @@ -539,7 +568,7 @@ flowtable_lookup_mbuf4(struct flowtable dsin = (struct sockaddr_in *)&dsa; ssin = (struct sockaddr_in *)&ssa; flags = 0; - if (ipv4_mbuf_demarshal(m, ssin, dsin, &flags) != 0) + if (ipv4_mbuf_demarshal(ft, m, ssin, dsin, &flags) != 0) return (NULL); return (flowtable_lookup(ft, &ssa, &dsa, M_GETFIB(m), flags)); @@ -567,8 +596,8 @@ do { \ #define UDP(p) ((struct udphdr *)(p)) static int -ipv6_mbuf_demarshal(struct mbuf *m, struct sockaddr_in6 *ssin6, - struct sockaddr_in6 *dsin6, uint16_t *flags) +ipv6_mbuf_demarshal(struct flowtable *ft, struct mbuf *m, + struct sockaddr_in6 *ssin6, struct sockaddr_in6 *dsin6, uint16_t *flags) { struct ip6_hdr *ip6; uint8_t proto; @@ -725,7 +754,7 @@ flowtable_lookup_mbuf6(struct flowtable dsin6 = (struct sockaddr_in6 *)&dsa; ssin6 = (struct sockaddr_in6 *)&ssa; flags = 0; - if (ipv6_mbuf_demarshal(m, ssin6, dsin6, &flags) != 0) + if (ipv6_mbuf_demarshal(ft, m, ssin6, dsin6, &flags) != 0) return (NULL); return (flowtable_lookup(ft, &ssa, &dsa, M_GETFIB(m), flags)); @@ -921,10 +950,9 @@ kern_flowtable_insert(struct flowtable * #endif if (ro->ro_rt == NULL || ro->ro_lle == NULL) return (EINVAL); -#ifdef FLOWTABLE_DEBUG - printf("kern_flowtable_insert: hash=0x%x fibnum=%d flags=0x%x\n", + + FLDPRINTF(ft, "kern_flowtable_insert: hash=0x%x fibnum=%d flags=0x%x\n", hash, fibnum, flags); -#endif return (flowtable_insert(ft, hash, key, fibnum, ro, flags)); } @@ -941,7 +969,7 @@ flowtable_key_equal(struct flentry *fle, nwords = 3; hashkey = ((struct flentry_v6 *)fle)->fl_flow.ipf_key; } - + for (i = 0; i < nwords; i++) if (hashkey[i] != key[i]) return (0); @@ -1007,9 +1035,6 @@ flowtable_lookup(struct flowtable *ft, s hash = ipv6_flow_lookup_hash_internal(ssin6, dsin6, key, flags); } #endif - if (hash == 0) - return (NULL); - /* * Ports are zero and this isn't a transmit cache * - thus not a protocol for which we need to keep @@ -1026,6 +1051,8 @@ flowtable_lookup(struct flowtable *ft, s goto uncached; } keycheck: + FLDPRINTF(ft, "doing keycheck on fle=%p hash=0x%x\n", + fle, fle->f_fhash); proto = flags_to_proto(flags); rt = __DEVOLATILE(struct rtentry *, fle->f_rt); lle = __DEVOLATILE(struct llentry *, fle->f_lle); Modified: user/kmacy/head_flowtable_v6/sys/net/flowtable.h ============================================================================== --- user/kmacy/head_flowtable_v6/sys/net/flowtable.h Sat Feb 6 22:57:24 2010 (r203576) +++ user/kmacy/head_flowtable_v6/sys/net/flowtable.h Sat Feb 6 23:00:18 2010 (r203577) @@ -41,6 +41,7 @@ $FreeBSD$ #define FL_TCP (1<<11) #define FL_SCTP (1<<12) #define FL_UDP (1<<13) +#define FL_DEBUG (1<<14) struct flowtable; struct flentry;