Project

General

Profile

Actions

Bug #2899

closed

Suricata 4.1.2 and up to 5.x Dev branch - Make compile issue when using PF_ring library on Redhat only

Added by Jake Babbin about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

Discovered a bug that appears when compiling Suricata 4.x up to the current 5.x Dev branches.

When compiling with PF_Ring support a single line change is required in order to get Suricata to compile on Redhat 6.x.

File:
"src/source-pfring.c"

Snippet from the original Code
154 ChecksumValidationMode checksum_mode;
155
156 bool vlan_hdr_warned;
157 } PfringThreadVars;
158
159 /**
CHANGE TO (NOTING THE ADDITION Of “_” to the line)
154 ChecksumValidationMode checksum_mode;
155
156 bool vlan_hdr_warned;
157 } PfringThreadVars_;
158
159 /**

Configure options to replicate:
./configure --enable-pfring --enable-af-packet --enable-lua --enable-geoip --with-libpcap-include=/usr/local/pfring/include --with-libpcap-libraries=/usr/local/pfring/lib -- with=libpfring-includes=/usr/local/pfring/include --with-libpfring-libraries=/usr/local/pfring/lib

If the source file is not corrected then the 'make' command is issued to build the Suricata tool this is the error you will get


CC source-pfring.o
source-pfring.c:157: error: redefinition of typedef ‘PfringThreadVars’
source-pfring.h:31: note: previous declaration of ‘PfringThreadVars’ was here
make[2]: *** [source-pfring.o] Error 1
make[2]: Leaving directory `/home/suricatauser/GIT_Suricata/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/suricatauser/GIT_Suricata'
make: *** [all] Error 2

Actions #1

Updated by Jason Taylor about 5 years ago

  • Assignee set to Jason Taylor
Actions #2

Updated by Jason Taylor about 5 years ago

  • Status changed from New to Assigned
Actions #3

Updated by Jason Taylor about 5 years ago

  • Subject changed from Suricata 4.1.2 and up to 5.x Dev branch - Make compile issue when using PF_ring library on Redhat only to Suricata 4.1.2 and up to 5.x Dev branch - Make compile issue when using PF_ring library on Redhat only

this appears to be the result of a gcc change with the older 4.3/4.4 with regard to the -pendantic compile flag and the handling of typedef redefinition. GCC in other versions appears to allow the redefinition based on the C standards being requested/followed at compile time.

https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ce3765bf44e49ef0568a1ad4a0b7f807591d6412

the latest el6 has gcc version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23) provided by the RPM gcc-4.4.7-23.el6.x86_64.

I am still researching the best way to fix.

Actions #4

Updated by Jason Taylor about 5 years ago

It looks like just removing the typdef and variable name of the struct would work, since that is defined in source-pfring.h. Thoughts?

$ git diff
diff --git a/src/source-pfring.c b/src/source-pfring.c
index 1dc06d6..06249de 100644
--- a/src/source-pfring.c
+++ b/src/source-pfring.c
@@ -120,7 +120,7 @@ static SCMutex pfring_bpf_set_filter_lock = SCMUTEX_INITIALIZER;
 /**
  * \brief Structure to hold thread specific variables.
  */
-typedef struct PfringThreadVars_
+struct PfringThreadVars_
 {
     /* thread specific handle */
     pfring *pd;
@@ -154,7 +154,7 @@ typedef struct PfringThreadVars_
      ChecksumValidationMode checksum_mode;

     bool vlan_hdr_warned;
-} PfringThreadVars;
+};

 /**
  * \brief Registration Function for RecievePfring.

Actions #5

Updated by Victor Julien about 5 years ago

  • Status changed from Assigned to Closed
  • Target version set to 5.0beta1
Actions

Also available in: Atom PDF