docs/176645: The example in man page netmap is wrong

Paul Meng mirnshi at gmail.com
Mon Mar 4 18:40:02 UTC 2013


>Number:         176645
>Category:       docs
>Synopsis:       The example in man page netmap is wrong
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Mar 04 18:40:01 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Paul Meng
>Release:        9.1
>Organization:
>Environment:
FreeBSD bsd9 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012     root at farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
The example in man page netmap is wrong. Struct netmap_request can not be found, 'buf_index' is not a member of struct netmap_ring, etc.

     #include <net/netmap.h>
     #include <net/netmap_user.h>
     struct netmap_if *nifp;
     struct netmap_ring *ring;
     struct netmap_request nmr;

     fd = open("/dev/netmap", O_RDWR);
     bzero(&nmr, sizeof(nmr));
     strcpy(nmr.nm_name, "ix0");
     ioctl(fd, NIOCREG, &nmr);
     p = mmap(0, nmr.memsize, fd);
     nifp = NETMAP_IF(p, nmr.offset);
     ring = NETMAP_TXRING(nifp, 0);
     fds.fd = fd;
     fds.events = POLLOUT;
     for (;;) {
         poll(list, 1, -1);
         while (ring->avail-- > 0) {
             i = ring->cur;
             buf = NETMAP_BUF(ring, ring->slot[i].buf_index);
             ... prepare packet in buf ...
             ring->slot[i].len = ... packet length ...
             ring->cur = NETMAP_RING_NEXT(ring, i);
         }
     }

>How-To-Repeat:
man netmap
>Fix:
delete this example from the man page or copy from http://info.iet.unipi.it/~luigi/netmap/.

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-doc mailing list