From 1f023b8af1877a89f046a7a08323052e039f3ff6 Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Wed, 13 Apr 2016 00:12:21 +0300 Subject: [PATCH 1/5] Use IF_NAMESIZE from libc --- src/netmap.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/netmap.rs b/src/netmap.rs index e8099bd..3f0b8ac 100644 --- a/src/netmap.rs +++ b/src/netmap.rs @@ -1,6 +1,5 @@ -use libc::{c_int, c_uint, c_ulong, c_char, timeval, ssize_t}; +use libc::{c_int, c_uint, c_ulong, c_char, timeval, ssize_t, IF_NAMESIZE}; -pub const IF_NAMESIZE: usize = 16; pub const IFNAMSIZ: usize = IF_NAMESIZE; pub const NETMAP_API: c_int = 11; From c2e7270e214be3be2021d72daab8d9b8e5bd5236 Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Wed, 13 Apr 2016 00:15:41 +0300 Subject: [PATCH 2/5] Kill unused SIZEOF_NR_NAME --- src/netmap.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/netmap.rs b/src/netmap.rs index 3f0b8ac..57fe17b 100644 --- a/src/netmap.rs +++ b/src/netmap.rs @@ -78,8 +78,6 @@ pub struct netmap_if { pub const NI_PRIV_MEM: c_int = 0x1; -pub const SIZEOF_NR_NAME: usize = IFNAMSIZ; - #[repr(C)] #[derive(Clone, Copy)] pub struct nmreq { From 26e91f585c41a749c74a876d1283cc4b6fd8762b Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Wed, 13 Apr 2016 00:17:45 +0300 Subject: [PATCH 3/5] Fix netmap_ring offsets --- src/netmap.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/netmap.rs b/src/netmap.rs index 57fe17b..4997459 100644 --- a/src/netmap.rs +++ b/src/netmap.rs @@ -46,6 +46,7 @@ pub struct netmap_ring { pub ts: timeval, + _padding: [u8; 72], pub sem: [u8; 128], // FIXME __attribute__((__aligned__(NM_CACHE_ALIGN))) pub slot: [netmap_slot; 0], // FIXME Check struct size/field alignment From 5bcb749570d9c51486cb09f87826284c41d9ffc2 Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Wed, 13 Apr 2016 00:19:01 +0300 Subject: [PATCH 4/5] Fix ioctl names --- src/netmap.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/netmap.rs b/src/netmap.rs index 4997459..718a1a1 100644 --- a/src/netmap.rs +++ b/src/netmap.rs @@ -140,9 +140,9 @@ pub const NIOCGINFO: c_ulong = 3225184657; #[cfg(target_os = "linux")] pub const NIOCREGIF: c_ulong = 3225184658; #[cfg(target_os = "linux")] -pub const NIOTXSYNC: c_uint = 27028; +pub const NIOCTXSYNC: c_uint = 27028; #[cfg(target_os = "linux")] -pub const NIORXSYNC: c_uint = 27029; +pub const NIOCRXSYNC: c_uint = 27029; #[cfg(target_os = "linux")] pub const NIOCCONFIG: c_ulong = 3239078294; From b35d33440ca9ce9ee171d3ec63e9e14e5e5e0a36 Mon Sep 17 00:00:00 2001 From: Alexander Polyakov Date: Wed, 13 Apr 2016 00:19:43 +0300 Subject: [PATCH 5/5] Fix NETMAP_{T,R}X_RING pointer types --- src/netmap_user.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/netmap_user.rs b/src/netmap_user.rs index bf1bcb5..d45e7b5 100644 --- a/src/netmap_user.rs +++ b/src/netmap_user.rs @@ -24,13 +24,13 @@ pub unsafe fn NETMAP_IF(_base: *mut U, _ofs: isize) -> *mut netmap_if { // FIXME It's possible the pointer arithmetic here uses the wrong integer types. #[inline(always)] pub unsafe fn NETMAP_TXRING(nifp: *mut netmap_if, index: isize) -> *mut netmap_ring { - let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut c_void; + let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut isize; _NETMAP_OFFSET(nifp, *(ptr.offset(index) as *mut isize)) } #[inline(always)] pub unsafe fn NETMAP_RXRING(nifp: *mut netmap_if, index: isize) -> *mut netmap_ring { - let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut c_void; + let ptr = (&mut (*nifp).ring_ofs as *mut [isize; 0]) as *mut isize; _NETMAP_OFFSET(nifp, *(ptr.offset(index + (*nifp).ni_tx_rings as isize + 1) as *mut isize)) }