From owner-freebsd-net@FreeBSD.ORG Thu May 16 11:56:06 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D67FF89C for ; Thu, 16 May 2013 11:56:06 +0000 (UTC) (envelope-from julian@vps1.elischer.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id 9E439E9 for ; Thu, 16 May 2013 11:56:06 +0000 (UTC) Received: from vps1.elischer.org (localhost [127.0.0.1]) by vps1.elischer.org (8.14.5/8.14.5) with ESMTP id r4GBu0UI018201 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 16 May 2013 04:56:00 -0700 (PDT) (envelope-from julian@vps1.elischer.org) Received: (from julian@localhost) by vps1.elischer.org (8.14.5/8.14.5/Submit) id r4GBu0HQ018200 for freebsd-net@freebsd.org; Thu, 16 May 2013 04:56:00 -0700 (PDT) (envelope-from julian) Date: Thu, 16 May 2013 04:56:00 -0700 (PDT) From: Julian Elischer Message-Id: <201305161156.r4GBu0HQ018200@vps1.elischer.org> To: freebsd-net@freebsd.org Subject: more FIBs patch for review X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 May 2013 11:56:06 -0000 Index: sys/conf/NOTES =================================================================== --- sys/conf/NOTES (revision 250696) +++ sys/conf/NOTES (working copy) @@ -571,7 +571,8 @@ options INET #Internet communications protocols options INET6 #IPv6 communications protocols -options ROUTETABLES=2 # max 16. 1 is back compatible. +options ROUTETABLES=2 # allocated fibs up to 65536. default is 1. + # but that would be a bad idea as they are large. options TCP_OFFLOAD # TCP offload support. Index: sys/net/route.c =================================================================== --- sys/net/route.c (revision 250696) +++ sys/net/route.c (working copy) @@ -68,8 +68,7 @@ #include -/* We use 4 bits in the mbuf flags, thus we are limited to 16 FIBS. */ -#define RT_MAXFIBS 16 +#define RT_MAXFIBS UINT16_MAX /* Kernel config default option. */ #ifdef ROUTETABLES @@ -86,17 +85,10 @@ #define RT_NUMFIBS 1 #endif +/* This is read-only.. */ u_int rt_numfibs = RT_NUMFIBS; SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RD, &rt_numfibs, 0, ""); -/* - * Allow the boot code to allow LESS than RT_MAXFIBS to be used. - * We can't do more because storage is statically allocated for now. - * (for compatibility reasons.. this will change. When this changes, code should - * be refactored to protocol independent parts and protocol dependent parts, - * probably hanging of domain(9) specific storage to not need the full - * fib * af RNH allocation etc. but allow tuning the number of tables per - * address family). - */ +/* and this can be set too big but will be fixed before it is used */ TUNABLE_INT("net.fibs", &rt_numfibs); /* Index: sys/netinet6/ip6_output.c =================================================================== --- sys/netinet6/ip6_output.c (revision 250696) +++ sys/netinet6/ip6_output.c (working copy) @@ -1126,7 +1126,7 @@ IP6STAT_INC(ip6s_odropped); goto sendorfree; } - m->m_flags = m0->m_flags & M_COPYFLAGS; /* incl. FIB */ + m->m_flags = m0->m_flags & M_COPYFLAGS; *mnext = m; mnext = &m->m_nextpkt; m->m_data += max_linkhdr; @@ -1152,6 +1152,7 @@ } m_cat(m, m_frgpart); m->m_pkthdr.len = len + hlen + sizeof(*ip6f); + m->m_pkthdr.fibnum = m0->m_pkthdr.fibnum; m->m_pkthdr.rcvif = NULL; ip6f->ip6f_reserved = 0; ip6f->ip6f_ident = id; Index: sys/sys/mbuf.h =================================================================== --- sys/sys/mbuf.h (revision 250696) +++ sys/sys/mbuf.h (working copy) @@ -129,6 +129,8 @@ u_int16_t vt_vtag; /* Ethernet 802.1p+q vlan tag */ u_int16_t vt_nrecs; /* # of IGMPv3 records in this chain */ } PH_vt; + u_int16_t fibnum; /* this packet should use this fib */ + u_int16_t pad2; /* align to 32 bits */ SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ }; #define ether_vtag PH_vt.vt_vtag @@ -171,6 +173,7 @@ #define m_type m_hdr.mh_type #define m_flags m_hdr.mh_flags #define m_nextpkt m_hdr.mh_nextpkt +#define m_fibnum m_hdr.mh_nextpkt #define m_act m_nextpkt #define m_pkthdr M_dat.MH.MH_pkthdr #define m_ext M_dat.MH.MH_dat.MH_ext @@ -205,12 +208,6 @@ #define M_FLOWID 0x00400000 /* deprecated: flowid is valid */ #define M_HASHTYPEBITS 0x0F000000 /* mask of bits holding flowid hash type */ -/* - * For RELENG_{6,7} steal these flags for limited multiple routing table - * support. In RELENG_8 and beyond, use just one flag and a tag. - */ -#define M_FIB 0xF0000000 /* steal some bits to store fib number. */ - #define M_NOTIFICATION M_PROTO5 /* SCTP notification */ /* @@ -258,7 +255,7 @@ */ #define M_COPYFLAGS \ (M_PKTHDR|M_EOR|M_RDONLY|M_PROTOFLAGS|M_SKIP_FIREWALL|M_BCAST|M_MCAST|\ - M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_PROMISC|M_FIB|M_HASHTYPEBITS) + M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_PROMISC|M_HASHTYPEBITS) /* * External buffer types: identify ext_buf type. @@ -1010,17 +1007,18 @@ m_tag_locate(m, MTAG_ABI_COMPAT, type, start)); } -/* XXX temporary FIB methods probably eventually use tags.*/ -#define M_FIBSHIFT 28 -#define M_FIBMASK 0x0F +static int inline +rt_m_getfib(struct mbuf *m) +{ + KASSERT(m->m_flags & M_EXT , ("attempt to set FIB on non header mbuf")); + return (m->m_pkthdr.fibnum); +} -/* get the fib from an mbuf and if it is not set, return the default */ -#define M_GETFIB(_m) \ - ((((_m)->m_flags & M_FIB) >> M_FIBSHIFT) & M_FIBMASK) +#define M_GETFIB(_m) rt_m_getfib(_m) #define M_SETFIB(_m, _fib) do { \ - _m->m_flags &= ~M_FIB; \ - _m->m_flags |= (((_fib) << M_FIBSHIFT) & M_FIB); \ + KASSERT((_m)->m_flags & M_EXT, ("No FIB on non header mbuf")); \ + ((_m)->m_pkthdr.fibnum) = (_fib); \ } while (0) #endif /* _KERNEL */