netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: shemminger@vyatta.com
Cc: netdev@vger.kernel.org,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH iproute2] tc: fix bpf compilation with old glibc
Date: Wed, 22 Jul 2015 14:29:30 +0200	[thread overview]
Message-ID: <1437568170-16995-1-git-send-email-nicolas.dichtel@6wind.com> (raw)

Error was:
f_bpf.o: In function `bpf_parse_opt':
f_bpf.c:(.text+0x88f): undefined reference to `secure_getenv'
m_bpf.o: In function `parse_bpf':
m_bpf.c:(.text+0x587): undefined reference to `secure_getenv'
collect2: error: ld returned 1 exit status

CC: Daniel Borkmann <daniel@iogearbox.net>
Fixes: 88eea5395483 ("tc: {f,m}_bpf: allow to retrieve uds path from env")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 configure   | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
 tc/Makefile |  6 ++++++
 tc/tc_bpf.h |  9 +++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 3ae4c955ae8e..1eacdc67dbb9 100755
--- a/configure
+++ b/configure
@@ -289,12 +289,54 @@ check_mnl()
 	if ${PKG_CONFIG} libmnl --exists
 	then
 		echo "HAVE_MNL:=y" >>Config
-		echo -n "yes"
+		echo "yes"
 	else
-		echo -n "no"
+		echo "no"
 	fi
 }
 
+check_secure_getenv()
+{
+	#check if we have secure_getenv()
+	cat >$TMPDIR/secure_getenv_test.c <<EOF
+#include <stdlib.h>
+
+int main(int argc, char **argv)
+{
+	secure_getenv("foo");
+	return 0;
+}
+EOF
+
+	$CC -I$INCLUDE -o $TMPDIR/secure_getenv_test $TMPDIR/secure_getenv_test.c >/dev/null 2>&1
+	if [ $? -eq 0 ]
+	then
+		echo "HAVE_SECURE_GETENV:=y" >>Config
+		echo "yes"
+	else
+		#check if we have __secure_getenv()
+		cat >$TMPDIR/secure_getenv_test.c <<EOF
+#include <stdlib.h>
+
+int main(int argc, char **argv)
+{
+	__secure_getenv("foo");
+	return 0;
+}
+EOF
+
+		$CC -I$INCLUDE -o $TMPDIR/secure_getenv_test $TMPDIR/secure_getenv_test.c >/dev/null 2>&1
+		if [ $? -eq 0 ]
+		then
+			echo "HAVE___SECURE_GETENV:=y" >>Config
+			echo "yes"
+		else
+			echo "no"
+		fi
+	fi
+	rm -f $TMPDIR/secure_getenv_test.c $TMPDIR/secure_getenv_test
+}
+
 echo "# Generated config based on" $INCLUDE >Config
 check_toolchain
 
@@ -328,6 +370,9 @@ check_elf
 echo -n "libmnl support: "
 check_mnl
 
+echo -n "secure_getenv() support: "
+check_secure_getenv
+
 echo
 echo -n "docs:"
 check_docs
diff --git a/tc/Makefile b/tc/Makefile
index 56acbaa1ab13..d598fc29532f 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -7,6 +7,12 @@ include ../Config
 ifeq ($(IP_CONFIG_SETNS),y)
 	CFLAGS += -DHAVE_SETNS
 endif
+ifeq ($(HAVE_SECURE_GETENV),y)
+	CFLAGS += -DHAVE_SECURE_GETENV
+endif
+ifeq ($(HAVE___SECURE_GETENV),y)
+	CFLAGS += -DHAVE___SECURE_GETENV
+endif
 
 SHARED_LIBS ?= y
 
diff --git a/tc/tc_bpf.h b/tc/tc_bpf.h
index 2ad881219e68..2e4b1a985f05 100644
--- a/tc/tc_bpf.h
+++ b/tc/tc_bpf.h
@@ -21,12 +21,21 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <stdlib.h>
 
 #include "utils.h"
 #include "bpf_scm.h"
 
 #define BPF_ENV_UDS	"TC_BPF_UDS"
 
+#ifndef HAVE_SECURE_GETENV
+#  ifdef HAVE___SECURE_GETENV
+#    define secure_getenv __secure_getenv
+#  else
+#    error neither secure_getenv nor __secure_getenv is available
+#  endif
+#endif
+
 int bpf_parse_string(char *arg, bool from_file, __u16 *bpf_len,
 		     char **bpf_string, bool *need_release,
 		     const char separator);
-- 
2.4.2

             reply	other threads:[~2015-07-22 12:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 12:29 Nicolas Dichtel [this message]
2015-07-22 13:05 ` [PATCH iproute2] tc: fix bpf compilation with old glibc Daniel Borkmann
2015-07-22 13:18   ` Nicolas Dichtel
     [not found] ` <19c76849dd1f4a94875b0aa5d3d7e96c@HQ1WP-EXMB12.corp.brocade.com>
2015-07-22 16:47   ` Stephen Hemminger
2015-07-23  7:17     ` [PATCH v2 " Nicolas Dichtel
2015-07-23  7:25       ` Daniel Borkmann
2015-07-23 21:50       ` Alexei Starovoitov
2015-07-27  8:09         ` Yegor Yefremov
2015-07-27 21:36 ` [PATCH " Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437568170-16995-1-git-send-email-nicolas.dichtel@6wind.com \
    --to=nicolas.dichtel@6wind.com \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).