trinity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix build when USE_BPF is not defined
@ 2016-11-07 11:58 Jan Stancek
  2016-11-07 14:34 ` Dave Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2016-11-07 11:58 UTC (permalink / raw)
  To: trinity, davej; +Cc: jstancek

net/bpf.o: In function `bpf_gen_filter': bpf.c:852: undefined reference to `get_rand_bpf_fd'

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 net/bpf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bpf.c b/net/bpf.c
index 4fe941733016..bb07a777abe9 100644
--- a/net/bpf.c
+++ b/net/bpf.c
@@ -8,6 +8,7 @@
 #include <string.h>
 
 #include "bpf.h"
+#include "config.h"
 #include "debug.h"
 #include "log.h"
 #include "net.h"
@@ -849,8 +850,10 @@ void bpf_gen_filter(unsigned long **addr, unsigned long *addrlen)
 		switch (rnd() % 3) {
 		case 0:	bpf->filter[i].k = (uint32_t) rand32();
 			break;
+#ifdef USE_BPF
 		case 1:	bpf->filter[i].k = (uint32_t) get_rand_bpf_fd();
 			break;
+#endif
 		case 2:	break;
 		}
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix build when USE_BPF is not defined
  2016-11-07 11:58 [PATCH] fix build when USE_BPF is not defined Jan Stancek
@ 2016-11-07 14:34 ` Dave Jones
  2016-11-08 10:46   ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Jones @ 2016-11-07 14:34 UTC (permalink / raw)
  To: Jan Stancek; +Cc: trinity

On Mon, Nov 07, 2016 at 12:58:34PM +0100, Jan Stancek wrote:
 > net/bpf.o: In function `bpf_gen_filter': bpf.c:852: undefined reference to `get_rand_bpf_fd'
 > 
 > Signed-off-by: Jan Stancek <jstancek@redhat.com>
 > ---
 >  net/bpf.c | 3 +++
 >  1 file changed, 3 insertions(+)
 > 
 > diff --git a/net/bpf.c b/net/bpf.c
 > index 4fe941733016..bb07a777abe9 100644
 > --- a/net/bpf.c
 > +++ b/net/bpf.c
 > @@ -8,6 +8,7 @@
 >  #include <string.h>
 >  
 >  #include "bpf.h"
 > +#include "config.h"
 >  #include "debug.h"
 >  #include "log.h"
 >  #include "net.h"
 > @@ -849,8 +850,10 @@ void bpf_gen_filter(unsigned long **addr, unsigned long *addrlen)
 >  		switch (rnd() % 3) {
 >  		case 0:	bpf->filter[i].k = (uint32_t) rand32();
 >  			break;
 > +#ifdef USE_BPF
 >  		case 1:	bpf->filter[i].k = (uint32_t) get_rand_bpf_fd();
 >  			break;
 > +#endif

I think it might be better if we wrap all of net/bpf.c in this ifdef,
and then add additional ones wherever we call bpf_gen_filter.
(Right now only two places iirc)

	Dave

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix build when USE_BPF is not defined
  2016-11-07 14:34 ` Dave Jones
@ 2016-11-08 10:46   ` Jan Stancek
  2016-11-08 15:00     ` Dave Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2016-11-08 10:46 UTC (permalink / raw)
  To: Dave Jones; +Cc: trinity

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

On 11/07/2016 03:34 PM, Dave Jones wrote:
> I think it might be better if we wrap all of net/bpf.c in this ifdef,
> and then add additional ones wherever we call bpf_gen_filter.
> (Right now only two places iirc)

Attached is v2, that follows your suggestion.

Regards,
Jan


[-- Attachment #2: 0001-fix-build-when-USE_BPF-is-not-defined.patch --]
[-- Type: text/x-patch, Size: 2682 bytes --]

From 3b98782aa7c345a6d873dbc69764340777ef8e6c Mon Sep 17 00:00:00 2001
Message-Id: <3b98782aa7c345a6d873dbc69764340777ef8e6c.1478601616.git.jstancek@redhat.com>
From: Jan Stancek <jstancek@redhat.com>
Date: Mon, 7 Nov 2016 12:50:27 +0100
Subject: [PATCH v2] fix build when USE_BPF is not defined

net/bpf.o: In function `bpf_gen_filter': bpf.c:852: undefined reference to `get_rand_bpf_fd'

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 net/bpf.c             | 3 +++
 syscalls/bpf.c        | 2 ++
 syscalls/prctl.c      | 4 +++-
 syscalls/setsockopt.c | 2 ++
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/bpf.c b/net/bpf.c
index 4fe941733016..d6ca14bde6d3 100644
--- a/net/bpf.c
+++ b/net/bpf.c
@@ -8,6 +8,7 @@
 #include <string.h>
 
 #include "bpf.h"
+#include "config.h"
 #include "debug.h"
 #include "log.h"
 #include "net.h"
@@ -17,6 +18,7 @@
 #include "utils.h"
 #include "compat.h"
 
+#ifdef USE_BPF
 /**
  * BPF filters are used in networking such as in pf_packet, but also
  * in seccomp for application sand-boxing. Additionally, with arch
@@ -885,3 +887,4 @@ void bpf_gen_filter(unsigned long **addr, unsigned long *addrlen)
 	if (dump_bpf)
 		bpf_disasm_all(bpf->filter, bpf->len);
 }
+#endif
diff --git a/syscalls/bpf.c b/syscalls/bpf.c
index 476a2778d8a0..372ab6dc5376 100644
--- a/syscalls/bpf.c
+++ b/syscalls/bpf.c
@@ -29,9 +29,11 @@ static void bpf_prog_load(struct syscallrecord *rec)
 	attr->prog_type = RAND_ARRAY(bpf_prog_types);
 
 	switch (attr->prog_type) {
+#ifdef USE_BPF
 	case BPF_PROG_TYPE_SOCKET_FILTER:
 		bpf_gen_filter(&insns, &len);
 		break;
+#endif
 	default:
 		// this will go away when all the other cases are enumerated
 		insns = zmalloc(page_size);
diff --git a/syscalls/prctl.c b/syscalls/prctl.c
index 02d2dbc6d8ab..cdbcdc217075 100644
--- a/syscalls/prctl.c
+++ b/syscalls/prctl.c
@@ -45,9 +45,11 @@ static int prctl_opts[] = {
 #ifdef USE_SECCOMP
 static void do_set_seccomp(struct syscallrecord *rec)
 {
-	unsigned long *optval = NULL, optlen = 0;
+	unsigned long *optval = NULL, __unused__ optlen = 0;
 
+#ifdef USE_BPF
 	bpf_gen_seccomp(&optval, &optlen);
+#endif
 
 	rec->a2 = SECCOMP_MODE_FILTER;
 	rec->a3 = (unsigned long) optval;
diff --git a/syscalls/setsockopt.c b/syscalls/setsockopt.c
index 8189b7a8ce9b..d395e54e23b9 100644
--- a/syscalls/setsockopt.c
+++ b/syscalls/setsockopt.c
@@ -48,7 +48,9 @@ static void socket_setsockopt(struct sockopt *so, __unused__ struct socket_tripl
 	case SO_ATTACH_FILTER: {
 		unsigned long *optval = NULL, optlen = 0;
 
+#ifdef USE_BPF
 		bpf_gen_filter(&optval, &optlen);
+#endif
 
 		so->optval = (unsigned long) optval;
 		so->optlen = optlen;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix build when USE_BPF is not defined
  2016-11-08 10:46   ` Jan Stancek
@ 2016-11-08 15:00     ` Dave Jones
  2016-11-08 15:08       ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Jones @ 2016-11-08 15:00 UTC (permalink / raw)
  To: Jan Stancek; +Cc: trinity

On Tue, Nov 08, 2016 at 11:46:01AM +0100, Jan Stancek wrote:
 > On 11/07/2016 03:34 PM, Dave Jones wrote:
 > > I think it might be better if we wrap all of net/bpf.c in this ifdef,
 > > and then add additional ones wherever we call bpf_gen_filter.
 > > (Right now only two places iirc)
 > 
 > Attached is v2, that follows your suggestion.
 
 Close..
 
 > diff --git a/syscalls/bpf.c b/syscalls/bpf.c
 > index 476a2778d8a0..372ab6dc5376 100644
 > --- a/syscalls/bpf.c
 > +++ b/syscalls/bpf.c
 > @@ -29,9 +29,11 @@ static void bpf_prog_load(struct syscallrecord *rec)
 >  	attr->prog_type = RAND_ARRAY(bpf_prog_types);
 >  
 >  	switch (attr->prog_type) {
 > +#ifdef USE_BPF
 >  	case BPF_PROG_TYPE_SOCKET_FILTER:
 >  		bpf_gen_filter(&insns, &len);
 >  		break;
 > +#endif
 >  	default:
 >  		// this will go away when all the other cases are enumerated
 >  		insns = zmalloc(page_size);

This chunk isn't needed because the whole file is already wrapped.

	Dave

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix build when USE_BPF is not defined
  2016-11-08 15:00     ` Dave Jones
@ 2016-11-08 15:08       ` Jan Stancek
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Stancek @ 2016-11-08 15:08 UTC (permalink / raw)
  To: Dave Jones; +Cc: trinity

[-- Attachment #1: Type: text/plain, Size: 1132 bytes --]

On 11/08/2016 04:00 PM, Dave Jones wrote:
> On Tue, Nov 08, 2016 at 11:46:01AM +0100, Jan Stancek wrote:
>  > On 11/07/2016 03:34 PM, Dave Jones wrote:
>  > > I think it might be better if we wrap all of net/bpf.c in this ifdef,
>  > > and then add additional ones wherever we call bpf_gen_filter.
>  > > (Right now only two places iirc)
>  > 
>  > Attached is v2, that follows your suggestion.
>  
>  Close..
>  
>  > diff --git a/syscalls/bpf.c b/syscalls/bpf.c
>  > index 476a2778d8a0..372ab6dc5376 100644
>  > --- a/syscalls/bpf.c
>  > +++ b/syscalls/bpf.c
>  > @@ -29,9 +29,11 @@ static void bpf_prog_load(struct syscallrecord *rec)
>  >  	attr->prog_type = RAND_ARRAY(bpf_prog_types);
>  >  
>  >  	switch (attr->prog_type) {
>  > +#ifdef USE_BPF
>  >  	case BPF_PROG_TYPE_SOCKET_FILTER:
>  >  		bpf_gen_filter(&insns, &len);
>  >  		break;
>  > +#endif
>  >  	default:
>  >  		// this will go away when all the other cases are enumerated
>  >  		insns = zmalloc(page_size);
> 
> This chunk isn't needed because the whole file is already wrapped.

Right, I missed that, removed in (attached) v3.

Regards,
Jan

> 
> 	Dave
> 


[-- Attachment #2: 0001-fix-build-when-USE_BPF-is-not-defined.patch --]
[-- Type: text/x-patch, Size: 2164 bytes --]

From 46774a62353fe7c9d2a113e530539d0a9b73d4bd Mon Sep 17 00:00:00 2001
Message-Id: <46774a62353fe7c9d2a113e530539d0a9b73d4bd.1478617566.git.jstancek@redhat.com>
From: Jan Stancek <jstancek@redhat.com>
Date: Mon, 7 Nov 2016 12:50:27 +0100
Subject: [PATCH v3] fix build when USE_BPF is not defined

net/bpf.o: In function `bpf_gen_filter': bpf.c:852: undefined reference to `get_rand_bpf_fd'

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 net/bpf.c             | 3 +++
 syscalls/prctl.c      | 4 +++-
 syscalls/setsockopt.c | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/bpf.c b/net/bpf.c
index 4fe941733016..d6ca14bde6d3 100644
--- a/net/bpf.c
+++ b/net/bpf.c
@@ -8,6 +8,7 @@
 #include <string.h>
 
 #include "bpf.h"
+#include "config.h"
 #include "debug.h"
 #include "log.h"
 #include "net.h"
@@ -17,6 +18,7 @@
 #include "utils.h"
 #include "compat.h"
 
+#ifdef USE_BPF
 /**
  * BPF filters are used in networking such as in pf_packet, but also
  * in seccomp for application sand-boxing. Additionally, with arch
@@ -885,3 +887,4 @@ void bpf_gen_filter(unsigned long **addr, unsigned long *addrlen)
 	if (dump_bpf)
 		bpf_disasm_all(bpf->filter, bpf->len);
 }
+#endif
diff --git a/syscalls/prctl.c b/syscalls/prctl.c
index 02d2dbc6d8ab..cdbcdc217075 100644
--- a/syscalls/prctl.c
+++ b/syscalls/prctl.c
@@ -45,9 +45,11 @@ static int prctl_opts[] = {
 #ifdef USE_SECCOMP
 static void do_set_seccomp(struct syscallrecord *rec)
 {
-	unsigned long *optval = NULL, optlen = 0;
+	unsigned long *optval = NULL, __unused__ optlen = 0;
 
+#ifdef USE_BPF
 	bpf_gen_seccomp(&optval, &optlen);
+#endif
 
 	rec->a2 = SECCOMP_MODE_FILTER;
 	rec->a3 = (unsigned long) optval;
diff --git a/syscalls/setsockopt.c b/syscalls/setsockopt.c
index 8189b7a8ce9b..d395e54e23b9 100644
--- a/syscalls/setsockopt.c
+++ b/syscalls/setsockopt.c
@@ -48,7 +48,9 @@ static void socket_setsockopt(struct sockopt *so, __unused__ struct socket_tripl
 	case SO_ATTACH_FILTER: {
 		unsigned long *optval = NULL, optlen = 0;
 
+#ifdef USE_BPF
 		bpf_gen_filter(&optval, &optlen);
+#endif
 
 		so->optval = (unsigned long) optval;
 		so->optlen = optlen;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-08 15:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-07 11:58 [PATCH] fix build when USE_BPF is not defined Jan Stancek
2016-11-07 14:34 ` Dave Jones
2016-11-08 10:46   ` Jan Stancek
2016-11-08 15:00     ` Dave Jones
2016-11-08 15:08       ` Jan Stancek

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).