From: dlg Date: Thu, 8 Oct 2015 11:36:15 +0000 (+0000) Subject: steal some padding in mbuf pkthdrs to store a flow id. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0ce39dfb1b1eb601eab9b925dffcdef4dc14fa7d;p=openbsd steal some padding in mbuf pkthdrs to store a flow id. the flowid roughly identifies a flow or connection that the mbuf is a part of, and can be used instead of hashing contents of the packet (like src+dst mac and ip addresses) to decide which path a packet should take. ok mpi@ mikeb@ sthen@ --- diff --git a/share/man/man9/mbuf.9 b/share/man/man9/mbuf.9 index 9ea87e2672f..75cf89ecc14 100644 --- a/share/man/man9/mbuf.9 +++ b/share/man/man9/mbuf.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mbuf.9,v 1.89 2015/09/21 11:30:50 mpi Exp $ +.\" $OpenBSD: mbuf.9,v 1.90 2015/10/08 11:36:15 dlg Exp $ .\" .\" Copyright (c) 2001 Jean-Jacques Bernard-Gundol .\" All rights reserved. @@ -25,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: September 21 2015 $ +.Dd $Mdocdate: October 8 2015 $ .Dt MBUF 9 .Os .Sh NAME @@ -122,7 +122,7 @@ struct pkthdr { SLIST_HEAD(packet_tags, m_tag) tags; int len; u_int16_t tagsset; - u_int16_t pad; + u_int16_t flowid; u_int16_t csum_flags; u_int16_t ether_vtag; u_int ph_rtableid; @@ -335,6 +335,21 @@ ICMP/ICMPv6 checksum verified. ICMP/ICMPv6 checksum bad. .El .Pp +The +.Fa m_pkthdr.flowid +variable can contain a low resolution (15 bit) classification of a +flow or connection that the current mbuf is part of. +If the flowid is valid, it may be used as an alternative to hashing +the packets content to pick between different paths for the traffic. +The following masks can be ORed with the flowid: +.Pp +.Bl -tag -compact -offset indent -width XXXXXXXXXXXXXXXXXX +.It Dv M_FLOWID_VALID +The flow id has been set. +.It Dv M_FLOWID_MASK +The flow id. +.El +.Pp When only M_EXT flag is set, an external storage buffer is being used to hold the data, which is no longer stored in the mbuf. The data part of the mbuf has now the following elements: diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index dfca8c1b4cc..3d8082b35e1 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.196 2015/08/14 05:25:29 dlg Exp $ */ +/* $OpenBSD: mbuf.h,v 1.197 2015/10/08 11:36:15 dlg Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -125,7 +125,7 @@ struct pkthdr { SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ int len; /* total packet length */ u_int16_t tagsset; /* mtags attached */ - u_int16_t pad; + u_int16_t flowid; /* pseudo unique flow id */ u_int16_t csum_flags; /* checksum flags */ u_int16_t ether_vtag; /* Ethernet 802.1p+Q vlan tag */ u_int ph_rtableid; /* routing table id */ @@ -237,6 +237,10 @@ struct mbuf { #define MT_CONTROL 6 /* extra-data protocol message */ #define MT_OOBDATA 7 /* expedited data */ +/* flowid field */ +#define M_FLOWID_VALID 0x8000 /* is the flowid set */ +#define M_FLOWID_MASK 0x7fff /* flow id to map to path */ + /* flags to m_get/MGET */ #define M_DONTWAIT M_NOWAIT #define M_WAIT M_WAITOK