Skip to content

Commit

Permalink
tools: fix vif-netmap init issue of order
Browse files Browse the repository at this point in the history
initializtion order of vif instance depends on the order of linking of
libnuse-linux.so. nuse-vif-netmap.o was linked _after_ nuse.o, and
nuse_vif_netmap_init() wasn't called before nuse_init. This brought an
core dump as issue #15 reported.

Signed-off-by: Hajime Tazaki <[email protected]>
  • Loading branch information
thehajime committed May 4, 2015
1 parent 7235e6f commit fced07a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ ifeq ($(NETMAP), yes)
endif

# sources and objects
NUSE_SRC=\
nuse-fiber.c nuse-vif.c nuse-hostcalls.c nuse-config.c \
nuse-vif-rawsock.c nuse-vif-tap.c nuse-vif-pipe.c nuse-glue.c nuse.c

NUSE_SRC=
ifeq "$(DPDK)" "yes"
include Makefile.dpdk
DPDK_LDFLAGS=-L$(RTE_SDK)/$(RTE_TARGET)/lib
Expand All @@ -49,6 +46,10 @@ ifeq "$(NETMAP)" "yes"
CFLAGS+= -Inetmap/sys
endif

NUSE_SRC+=\
nuse-fiber.c nuse-vif.c nuse-hostcalls.c nuse-config.c \
nuse-vif-rawsock.c nuse-vif-tap.c nuse-vif-pipe.c nuse-glue.c nuse.c


SIM_SRC=sim.c

Expand Down
6 changes: 3 additions & 3 deletions nuse-vif-netmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ netmap_get_nifp(const char *ifname, struct netmap_if **_nifp)

fd = open("/dev/netmap", O_RDWR);
if (fd < 0) {
printf("unable to open /dev/netmap");
printf("unable to open /dev/netmap\n");
return 0;
}

Expand All @@ -74,7 +74,7 @@ netmap_get_nifp(const char *ifname, struct netmap_if **_nifp)
nmr.nr_flags |= NR_REG_ALL_NIC;

if (ioctl(fd, NIOCREGIF, &nmr) < 0) {
printf("unable to register interface %s", ifname);
printf("unable to register interface %s\n", ifname);
return 0;
}

Expand All @@ -86,7 +86,7 @@ netmap_get_nifp(const char *ifname, struct netmap_if **_nifp)
mem = mmap(NULL, nmr.nr_memsize,
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mem == MAP_FAILED) {
printf("unable to mmap");
printf("unable to mmap\n");
return 0;
}

Expand Down

0 comments on commit fced07a

Please sign in to comment.