From 04a51ef941f9c3a2c8a3137b8077b30239579781 Mon Sep 17 00:00:00 2001 From: Suhas Narreddy Date: Sun, 27 Feb 2022 15:23:39 -0600 Subject: [PATCH 1/6] Updated a bit of code to make mTCP netmap 15 compatible --- mtcp/src/Makefile.in | 9 +++++++-- mtcp/src/io_module.c | 12 ++++++++++-- mtcp/src/netmap_module.c | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/mtcp/src/Makefile.in b/mtcp/src/Makefile.in index f81a0c8d7..5a5853e67 100644 --- a/mtcp/src/Makefile.in +++ b/mtcp/src/Makefile.in @@ -75,7 +75,12 @@ INC += -DDISABLE_PSIO endif ifeq ($(NETMAP),1) -# do nothing +#if netmap we set the INC variable to netmap lib location +INC += -I ../../../netmap/libnetmap +#add location of netmap_user.h to INC +INC += -I ../../../netmap/sys +#and then we link LDFLAGS to libnetmap.a +LDFLAGS += ../../../netmap/libnetmap/libnetmap.a else INC += -DDISABLE_NETMAP endif @@ -153,7 +158,7 @@ endif $(OBJS): %.o: %.c Makefile $(MSG) " CC $<" - $(HIDE) $(GCC) $(CFLAGS) $(GCC_OPT) $(INC) -c $< -o $@ + $(HIDE) $(GCC) $(CFLAGS) $(GCC_OPT) $(INC) -c $< -o $@ $(LDFLAGS) $(DEPS): .%.d: %.c Makefile $(HIDE) $(GCC) $(GCC_OPT) $(INC) -MM $(CFLAGS) $< > $@ diff --git a/mtcp/src/io_module.c b/mtcp/src/io_module.c index 198a98874..5e71895cc 100644 --- a/mtcp/src/io_module.c +++ b/mtcp/src/io_module.c @@ -6,6 +6,14 @@ #include /* std io funcs */ #include +/* for I/O module def'ns */ +#include "io_module.h" +/* for num_devices decl */ +#include "config.h" +/* std lib funcs */ +#include +/* std io funcs */ +#include /* strcmp func etc. */ #include /* for ifreq struct */ @@ -44,7 +52,7 @@ #include #include /* for netmap macros */ -#include "netmap_user.h" +#include /*----------------------------------------------------------------------------*/ io_module_func *current_iomodule_func = &dpdk_module_func; #ifndef DISABLE_DPDK @@ -741,4 +749,4 @@ CheckIOModuleAccessPermissions() return 0; } -/*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ \ No newline at end of file diff --git a/mtcp/src/netmap_module.c b/mtcp/src/netmap_module.c index 38600b90f..6b260c94c 100644 --- a/mtcp/src/netmap_module.c +++ b/mtcp/src/netmap_module.c @@ -1,4 +1,3 @@ -/* for io_module_func def'ns */ #include "io_module.h" #ifndef DISABLE_NETMAP /* for mtcp related def'ns */ @@ -11,7 +10,8 @@ #include "config.h" /* for netmap definitions */ #define NETMAP_WITH_LIBS -#include "netmap_user.h" +#define LIBNETMAP_NOTHREADSAFE +#include /* for poll */ #include /* for ETHER_CRC_LEN */ From 28d8dec9f79a1c8d6488f0187fb8be7068560332 Mon Sep 17 00:00:00 2001 From: Suhas Narreddy Date: Sun, 27 Feb 2022 15:28:08 -0600 Subject: [PATCH 2/6] fixed some weird code in io_module --- mtcp/src/io_module.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/mtcp/src/io_module.c b/mtcp/src/io_module.c index 5e71895cc..a834f4143 100644 --- a/mtcp/src/io_module.c +++ b/mtcp/src/io_module.c @@ -6,14 +6,6 @@ #include /* std io funcs */ #include -/* for I/O module def'ns */ -#include "io_module.h" -/* for num_devices decl */ -#include "config.h" -/* std lib funcs */ -#include -/* std io funcs */ -#include /* strcmp func etc. */ #include /* for ifreq struct */ From 89507a0598fcf784dd22c77c4bd32472478fe3e1 Mon Sep 17 00:00:00 2001 From: sulaimansuhas Date: Sun, 27 Feb 2022 21:33:15 +0000 Subject: [PATCH 3/6] Updated README.netmap for modern netmap versions --- README.netmap | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.netmap b/README.netmap index b7dd46e12..cdb38f7c0 100644 --- a/README.netmap +++ b/README.netmap @@ -1,6 +1,10 @@ - NETMAP VERSION - ------------------ - +Addendum for more modern versions of netmap: +Given the change in the netmap library structure, I changed some code to let mTCP work with modern versions of netmap. To run it for Netmap API v >15 you will need +the netmap folder and mtcp folders to be located in the same directory/folder. Once this is done please go into netmap/libnetmap and run make. This should generate a +libnetmap.a file and everything should run fine after this. +------------------ -*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*--*-*-*-*-*-*- -A- Tested with linux-3.13.0-121-generic & netmap commit: 8f3f79e4ca168c6d3220e7a5198a5778b030445e, and, @@ -193,4 +197,4 @@ I/O by default. Most microbenchmarking applications (epserver/epwget) shows best performance with this setup in our testbed. In case the performance is sub-optimal in yours, we recommend that you try polling mode (by enabling CONST_POLLING in line 24). You can also try tweaking -IDLE_POLL_WAIT/IDLE_POLL_COUNT macros while testing blocking mode I/O. \ No newline at end of file +IDLE_POLL_WAIT/IDLE_POLL_COUNT macros while testing blocking mode I/O. From 0fa7e4afbe70fd2f83186f2ae6e1940853e76b59 Mon Sep 17 00:00:00 2001 From: Suhas Date: Tue, 1 Mar 2022 17:50:55 -0600 Subject: [PATCH 4/6] fixed affinity-netmap for python3 --- config/affinity-netmap.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/affinity-netmap.py b/config/affinity-netmap.py index 0e52edd5d..b33f4a25b 100755 --- a/config/affinity-netmap.py +++ b/config/affinity-netmap.py @@ -14,25 +14,25 @@ def execute(cmd): return None if os.getuid() != 0: - print 'You must be root!' + print('You must be root!') sys.exit(1) -num_cpus = len(execute('cat /proc/cpuinfo | grep processor').strip().split('\n')) +num_cpus = len(execute('cat /proc/cpuinfo | grep processor').strip().split(b'\n')) if len(sys.argv) < 2: - print 'usage: %s ' % sys.argv[0] + print('usage: %s ' % sys.argv[0]) sys.exit(1) ifname = sys.argv[1] -intrmap = execute('cat /proc/interrupts | grep %s-TxRx-' % ifname).strip().split('\n') +intrmap = execute('cat /proc/interrupts | grep %s-TxRx-' % ifname).strip().split(b'\n') for intr in intrmap: irq = int(intr.split()[0][:-1]) name = intr.split()[-1] - queue = int(name[name.rfind('-') + 1:]) + queue = int(name[name.rfind(b'-') + 1:]) cpu = queue - print 'echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq) + print ('echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq)) execute('echo %x > /proc/irq/%d/smp_affinity' % (1 << cpu, irq)) From fd93b765fb60f5c377a7de352ca58256af4a05d6 Mon Sep 17 00:00:00 2001 From: Suhas Date: Wed, 2 Mar 2022 11:27:39 -0600 Subject: [PATCH 5/6] fixed string truncation issue --- mtcp/src/config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mtcp/src/config.c b/mtcp/src/config.c index 38188bde4..c1aac8be0 100644 --- a/mtcp/src/config.c +++ b/mtcp/src/config.c @@ -560,6 +560,9 @@ ParseConfiguration(char *line) char *saveptr; + if(strlen(line) > sizeof(optstr) - 1){ + return -1; + } strncpy(optstr, line, MAX_OPTLINE_LEN - 1); saveptr = NULL; From ce1f13ec829b111f026fc26e0290cf756541f3ab Mon Sep 17 00:00:00 2001 From: Suhas Date: Thu, 3 Mar 2022 08:31:36 -0600 Subject: [PATCH 6/6] fixed sprintf overflow issue --- mtcp/src/netmap_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mtcp/src/netmap_module.c b/mtcp/src/netmap_module.c index 6b260c94c..a84ffdf49 100644 --- a/mtcp/src/netmap_module.c +++ b/mtcp/src/netmap_module.c @@ -49,7 +49,7 @@ netmap_init_handle(struct mtcp_thread_context *ctxt) { struct netmap_private_context *npc; char ifname[MAX_IFNAMELEN]; - char nifname[MAX_IFNAMELEN]; + char nifname[MAX_IFNAMELEN + 20]; int j; /* create and initialize private I/O module context */