Skip to content

Commit

Permalink
CentOS 6 support
Browse files Browse the repository at this point in the history
  • Loading branch information
samofatov committed Dec 28, 2017
1 parent 4e04c94 commit c5308e9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions introspection/bps.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

#include "libbpf.h"

// TODO: Remove this when CentOS 6 support is not needed anymore
#ifndef CLOCK_BOOTTIME
#define CLOCK_BOOTTIME 7
#endif

static const char * const prog_type_strings[] = {
[BPF_PROG_TYPE_UNSPEC] = "unspec",
[BPF_PROG_TYPE_SOCKET_FILTER] = "socket filter",
Expand Down
8 changes: 8 additions & 0 deletions src/cc/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
#include "libbpf.h"
#include "perf_reader.h"

// TODO: Remove this when CentOS 6 support is not needed anymore
#include "setns.h"

// TODO: remove these defines when linux-libc-dev exports them properly

#ifndef __NR_bpf
Expand All @@ -74,6 +77,11 @@
#define PERF_FLAG_FD_CLOEXEC (1UL << 3)
#endif

// TODO: Remove this when CentOS 6 support is not needed anymore
#ifndef AF_ALG
#define AF_ALG 38
#endif

#define min(x, y) ((x) < (y) ? (x) : (y))

static int probe_perf_reader_page_cnt = 8;
Expand Down
3 changes: 3 additions & 0 deletions src/cc/ns_guard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include "ns_guard.h"

// TODO: Remove this when CentOS 6 support is not needed anymore
#include "setns.h"

ProcMountNS::ProcMountNS(int pid) : target_ino_(0) {
if (pid < 0)
return;
Expand Down
12 changes: 12 additions & 0 deletions src/cc/setns.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This file is only needed to support build for CentOS 6
// Remove it when no longer needed.
// File is trivial and therefore is in public domain.

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include <unistd.h>
#include <sys/syscall.h>

#define setns(FD, NSTYPE) syscall(__NR_setns, (int)(FD), (int)(NSTYPE))

0 comments on commit c5308e9

Please sign in to comment.