Skip to content

Latest commit

 

History

History
104 lines (77 loc) · 3.61 KB

rfd-0001.md

File metadata and controls

104 lines (77 loc) · 3.61 KB
authors state
George V. Neville-Neil <[email protected]>
draft

RFD 1 mbuf handling subroutine

Problem Statement

Data in BSD derived network stacks resides in mbuf chains. The D language does not currently have any routines for giving D programs access to chained mbuf data. The current RFD aims to add a new D subroutine for use by D programs in looking at data in an mbuf chain.

User Visibility

One new sub-routines will be defined to give access to data in mbuf chains. The interface is described in the following sections.

Public Interfaces

copyoutmbuf

copyoutmbuf(struct mbuf *m, size_t length, [size_t offset])

The copyoutmbuf subroutine operates in a similar manner to the currently existing copy interfaces in OpenDTrace It has two required arguments: a pointer to an mbuf structure (struct mbuf *) and a length. If the length is specified as 0 then the subroutine will attempt to copy out all of the data in the mbuf chain, starting from the beginning. It is possible for D's limited scratch space to run out during this operation and so the subroutine may fail with an out of memory condition. An optional third argument, offset, allows the caller to request data starting after the beginning of the mbuf chain, which can be used to skip over headers that are not of interest to the caller.

Example Usage

The following is an example of using the copyoutmbuf routine in a D one liner. Show the first 64 bytes of the data that arrives in an mbuf passed to tcp_input().

dtrace -n ':::tcp_input:entry { tracemem(copyoutmbuf(*args[0], 64), 64); }'
dtrace: description ':::tcp_input:entry ' matched 1 probe

CPU     ID                    FUNCTION:NAME
  3  34345                  tcp_input:entry
             0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  0123456789abcdef
         0: 45 10 00 34 46 f4 40 00 40 06 70 0a c0 a8 01 01  E..4F.@[email protected].....
        10: c0 a8 01 64 3d 3c 00 16 70 7d fa 57 c2 cc f1 4b  ...d=<..p}.W...K
        20: 80 10 04 10 b5 a5 00 00 01 01 08 0a 3a c8 04 ae  ............:...
        30: 94 3c 09 5f 00 00 00 00 00 00 00 00 00 00 00 00  .<._............

This second example skips the first 20 bytes of data, which should be the IPv4 header:

dtrace -n ':::tcp_input:entry { tracemem(copyoutmbuf(*args[0], 64, 20), 64); }'
dtrace: description ':::tcp_input:entry ' matched 1 probe

CPU     ID                    FUNCTION:NAME
  3  34345                  tcp_input:entry
             0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  0123456789abcdef
         0: 3d 3c 00 16 70 7d fd 03 c2 cd 25 33 80 10 04 10  =<..p}....%3....
        10: 1c a6 00 00 01 01 08 0a 3a c8 b5 e5 94 3c ba 92  ........:....<..
        20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

Private Interfaces

Both of the new public subroutines described above depend on a single, new, internal interface, dtrace_mbuf_copydata(), which operates in a similar manner to the FreeBSD kernel's mbuf_copydata() routine but which is implemented using the OpenDTrace safe copy routines.

Upgrade Impact

The new subroutine has no effect on existing systems as the they are completely new, and do not modify existing interfaces.

The version of DTrace will be increased once the new subroutine is added.

Security Impact

The new subroutine present no new security issues for the OpenDTrace system.

References