Page MenuHomeFreeBSD

add libnetmap
ClosedPublic

Authored by vmaffione on Aug 24 2020, 3:05 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 6, 10:24 PM
Unknown Object (File)
Mar 22 2024, 7:54 PM
Unknown Object (File)
Mar 22 2024, 7:54 PM
Unknown Object (File)
Mar 8 2024, 7:24 AM
Unknown Object (File)
Jan 3 2024, 2:43 AM
Unknown Object (File)
Jan 3 2024, 2:43 AM
Unknown Object (File)
Dec 21 2023, 8:04 AM
Unknown Object (File)
Dec 20 2023, 7:01 AM

Details

Summary

This changeset introduces the new libnetmap library for writing netmap applications.
Before libnetmap, applications could either use the kernel API directly (e.g. NIOCREGIF/NIOCCTRL) or the simple header-only-library netmap_user.h (e.g. nm_open(), nm_close(), nm_mmap() etc.)

The new library offers more functionalities than netmap_user.h:

  • Support for complex netmap options, such as external memory allocators or per-buffer offsets. This opens the way to future extensions.
  • More flexibility in the netmap port bind options, such as non-numeric names for pipes, or the ability to specify the netmap allocator that must be used for a given port.
  • Automatic tracking of the netmap memory regions in use across the open ports.

At the moment there is no man page, but the libnetmap.h header file has in-depth documentation.

Next step would be to convert the applications to use the new library.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Could someone please review the Makefile and the change to share/mk/ ?

hrs requested changes to this revision.Aug 26 2020, 8:02 AM
  • You have to add libnetmap to lib/Makefile, too.
  • nmreq.c does not build on 32-bit platforms because nr_options is uint64_t and uintptr_t is not uint64_t in that case. I think the following casting is required at least:
@@ -587,11 +587,11 @@ nmreq_remove_option(struct nmreq_header *h, struct nmr
 {
        uintptr_t *scan;
 
-       for (scan = &h->nr_options; *scan;
-                       scan = &((struct nmreq_option *)*scan)->nro_next) {
+       for (scan = (uintptr_t *)&h->nr_options; *scan;
+                       scan = (uintptr_t *)&((struct nmreq_option *)*scan)->nro_next) {
                if (*scan == (uintptr_t)o) {
-                       *scan = o->nro_next;
-                       o->nro_next = 0;
+                       *((uint64_t *)scan) = o->nro_next;
+                       o->nro_next = (uint64_t)(uintptr_t)NULL;
                        break;
                }
        }
  • However, IMO the pointer arithmetic in nmreq_remove_option() should be done by using the specific type, not uintptr_t.
 void
 nmreq_remove_option(struct nmreq_header *h, struct nmreq_option *o)
 {
-       uintptr_t *scan;
+       struct nmreq_option **nmo;
 
-       for (scan = &h->nr_options; *scan;
-                       scan = &((struct nmreq_option *)*scan)->nro_next) {
-               if (*scan == (uintptr_t)o) {
-                       *scan = o->nro_next;
-                       o->nro_next = 0;
+       for (nmo = (struct nmreq_option **)&h->nr_options; *nmo != NULL;
+           nmo = (struct nmreq_option **)&(*nmo)->nro_next) {
+               if (*nmo == o) {
+                       *((uint64_t *)(*nmo)) = o->nro_next;
+                       o->nro_next = (uint64_t)(uintptr_t)NULL;
                        break;
                }
        }
This revision now requires changes to proceed.Aug 26 2020, 8:02 AM

Fixed nmreq_remove_option() as suggested.
Changed lib/Makefile

Looks good to me. Thanks!

This revision is now accepted and ready to land.Aug 27 2020, 7:48 PM
In D26171#582504, @hrs wrote:

Looks good to me. Thanks!

Thanks for taking the time to review this!

This revision was automatically updated to reflect the committed changes.