]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: fix build when eBPF not built-in
authorEric Leblond <eric@regit.org>
Sat, 19 Jan 2019 16:33:46 +0000 (17:33 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 18 Jun 2019 05:07:02 +0000 (07:07 +0200)
src/runmode-af-packet.c
src/source-af-packet.c

index 920fac8a3309dcf5db47ccc6b5ab0fecebafb6fd..b6d235616b2d731ccc6fda9f1bbcc8fe6a5ba4a1 100644 (file)
@@ -386,6 +386,7 @@ static void *ParseAFPConfig(const char *iface)
 #endif
     }
 
+#ifdef HAVE_PACKET_EBPF
     if (ConfGetChildValueBoolWithDefault(if_root, if_default, "pinned-maps", (int *)&boolval) != 1) {
         if (boolval) {
             SCLogConfig("Using pinned maps on iface %s",
@@ -393,6 +394,7 @@ static void *ParseAFPConfig(const char *iface)
             aconf->ebpf_t_config.flags |= EBPF_PINNED_MAPS;
         }
     }
+#endif
 
 #ifdef HAVE_PACKET_EBPF
     /* One shot loading of the eBPF file */
@@ -416,9 +418,9 @@ static void *ParseAFPConfig(const char *iface)
 #ifdef HAVE_PACKET_EBPF
         SCLogConfig("af-packet will use '%s' as eBPF filter file",
                   ebpf_file);
-#endif
         aconf->ebpf_filter_file = ebpf_file;
         aconf->ebpf_t_config.mode = AFP_MODE_EBPF_BYPASS;
+#endif
         ConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &conf_val);
         if (conf_val) {
 #ifdef HAVE_PACKET_EBPF
@@ -452,6 +454,7 @@ static void *ParseAFPConfig(const char *iface)
     if (ConfGetChildValueWithDefault(if_root, if_default, "xdp-filter-file", &ebpf_file) != 1) {
         aconf->xdp_filter_file = NULL;
     } else {
+#ifdef HAVE_PACKET_XDP
         SCLogInfo("af-packet will use '%s' as XDP filter file",
                   ebpf_file);
         aconf->ebpf_t_config.mode = AFP_MODE_XDP_BYPASS;
@@ -460,17 +463,16 @@ static void *ParseAFPConfig(const char *iface)
         /* TODO FIXME Do we really have a usage of setting XDP and not bypassing ? */
         ConfGetChildValueBoolWithDefault(if_root, if_default, "bypass", &conf_val);
         if (conf_val) {
-#ifdef HAVE_PACKET_XDP
             SCLogConfig("Using bypass kernel functionality for AF_PACKET (iface %s)",
                     aconf->iface);
             aconf->flags |= AFP_XDPBYPASS;
             RunModeEnablesBypassManager();
             BypassedFlowManagerRegisterCheckFunc(EBPFCheckBypassedFlowTimeout, (void *) &(aconf->ebpf_t_config));
             BypassedFlowManagerRegisterUpdateFunc(EBPFUpdateFlow, NULL);
+        }
 #else
-            SCLogError(SC_ERR_UNIMPLEMENTED, "Bypass set but XDP support is not built-in");
+       SCLogError(SC_ERR_UNIMPLEMENTED, "XDP filter set but XDP support is not built-in");
 #endif
-        }
 #ifdef HAVE_PACKET_XDP
         const char *xdp_mode;
         if (ConfGetChildValueWithDefault(if_root, if_default, "xdp-mode", &xdp_mode) != 1) {
@@ -495,7 +497,6 @@ static void *ParseAFPConfig(const char *iface)
                 aconf->ebpf_t_config.cpus_count = 1;
             }
         }
-
 #endif
     }
 
index 75208102befdc527be2b0ae8fdb9d51af57705d8..98070e27dd884d97d839d43e7a301c6b9d9fec7f 100644 (file)
@@ -292,7 +292,9 @@ typedef struct AFPThreadVars_
 
     uint8_t xdp_mode;
 
+#ifdef HAVE_PACKET_EBPF
     struct ebpf_timeout_config ebpf_t_config;
+#endif
 
 } AFPThreadVars;
 
@@ -2583,9 +2585,9 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, const void *initdata, void **data)
     ptv->ebpf_lb_fd = afpconfig->ebpf_lb_fd;
     ptv->ebpf_filter_fd = afpconfig->ebpf_filter_fd;
     ptv->xdp_mode = afpconfig->xdp_mode;
+#ifdef HAVE_PACKET_EBPF
     ptv->ebpf_t_config.cpus_count = UtilCpuGetNumProcessorsConfigured();
 
-#ifdef HAVE_PACKET_EBPF
     if (ptv->flags & (AFP_BYPASS|AFP_XDPBYPASS)) {
         ptv->v4_map_fd = EBPFGetMapFDByName(ptv->iface, "flow_table_v4");
         if (ptv->v4_map_fd == -1) {