Fix keyboard related issues on Ubuntu 18.04 90/68190/2
authorXavier Simonart <xavier.simonart@intel.com>
Wed, 3 Jul 2019 22:04:17 +0000 (00:04 +0200)
committerXavier Simonart <xavier.simonart@intel.com>
Thu, 4 Jul 2019 12:08:27 +0000 (14:08 +0200)
On Ubuntu 18.04, the keyboard was not properly handled in PROX
For instance, many keys pressed were silently discarded.

The issue is related to a change in histedit/libedit version.
Recent libedit have (silently) changed the prototype of the get_char function
passed in el_set(el, EL_GETCFN, get_char), with some input parameters
changing from char to wchar_t.
As PROX used the old prototype (char based), this resulted in some
uninitialized field (= garbage) in the wchar_t, causing libedit to discard
the character.

PROX now uses different get_char prototypes, depending of the libedit version
being used.

If PROX was already compiled and a the OS is updated (e.g. from Ubuntu 16.04
to Ubuntu 18.04), this will require a 'make clean'.

Change-Id: Icb0e555a21e13cdaf98172bad17f2f838fb7bc3a
Signed-off-by: Xavier Simonart <xavier.simonart@intel.com>
VNFs/DPPD-PROX/Makefile
VNFs/DPPD-PROX/input_curses.c

index fe8e87d..b6cc603 100644 (file)
@@ -174,8 +174,10 @@ SRCS-y += handle_ipv6_tunnel.c
 SRCS-y += handle_read.c
 SRCS-$(CONFIG_RTE_LIBRTE_PMD_AESNI_MB) += handle_esp.c
 ifneq ($(CONFIG_RTE_LIBRTE_PMD_AESNI_MB),y)
+ifeq ($(FIRST_PROX_MAKE),)
 $(warning "Building w/o IPSEC support")
 endif
+endif
 SRCS-y += handle_cgnat.c
 SRCS-y += handle_nat.c
 SRCS-y += handle_dump.c
@@ -209,11 +211,33 @@ ifeq ($(FIRST_PROX_MAKE),)
 MAKEFLAGS += --no-print-directory
 FIRST_PROX_MAKE = 1
 export FIRST_PROX_MAKE
-all:
+all:   libedit_autoconf.h
        @./helper-scripts/trailing.sh
        @$(MAKE) $@
+clean:
+       $(Q) $(RM) -- 'libedit_autoconf.h'
+       @$(MAKE) $@
 %::
        @$(MAKE) $@
+
+ifeq ($(call rte_ver_LT,17,2,0,0),y)
+AUTO-CONFIG-SCRIPT = $(RTE_SDK)/scripts/auto-config-h.sh
+else
+AUTO-CONFIG-SCRIPT = $(RTE_SDK)/buildtools/auto-config-h.sh
+endif
+
+# DPDK CFLAGS prevents auto-conf program to properly compile
+export CFLAGS=
+# if el_rfunc_t exists, define HAVE_LIBEDIT_EL_RFUNC_T so that PROX knows it can use it
+libedit_autoconf.h: $(AUTO-CONFIG-SCRIPT)
+       $(Q) $(RM) -- '$@'
+       $(Q) sh -- '$(AUTO-CONFIG-SCRIPT)' '$@' \
+               HAVE_LIBEDIT_EL_RFUNC_T \
+               histedit.h \
+               type 'el_rfunc_t' \
+               > /dev/null
+# auto-conf adds empty line at the end of the file, considered as error by trailing.sh script
+       $(Q) sed -i '$$ d' '$@'
 else
 include $(RTE_SDK)/mk/rte.extapp.mk
 endif
index 6f79869..4ea2e4a 100644 (file)
@@ -27,6 +27,7 @@
 #include "cmd_parser.h"
 #include "input_curses.h"
 #include "histedit.h"
+#include "libedit_autoconf.h"
 
 static EditLine *el;
 static History *hist;
@@ -124,7 +125,11 @@ static int peek_stdin(void)
        return FD_ISSET(fileno(stdin), &in_fd);
 }
 
+#ifdef HAVE_LIBEDIT_EL_RFUNC_T
+static int do_get_char(EditLine *e, wchar_t *c)
+#else
 static int get_char(EditLine *e, char *c)
+#endif
 {
        *c = display_getch();
 
@@ -167,6 +172,10 @@ static int get_char(EditLine *e, char *c)
        return 1;
 }
 
+#ifdef HAVE_LIBEDIT_EL_RFUNC_T
+static el_rfunc_t get_char = &do_get_char;
+#endif
+
 static void proc_keyboard(struct input *input)
 {
        const char *line;