From: Victor Julien Date: Sun, 8 Nov 2015 07:48:24 +0000 (+0100) Subject: afpacket: on missing cluster settings, set defaults X-Git-Tag: suricata-3.0RC2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f89a4219906fe40cf2fb3092e6eaf1abd732faf8;p=thirdparty%2Fsuricata.git afpacket: on missing cluster settings, set defaults --- diff --git a/src/runmode-af-packet.c b/src/runmode-af-packet.c index fc17a4bd66..16d9113cb8 100644 --- a/src/runmode-af-packet.c +++ b/src/runmode-af-packet.c @@ -92,6 +92,10 @@ void AFPDerefConfig(void *conf) } } +/* if cluster id is not set, assign it automagically, uniq value per + * interface. */ +static int cluster_id_auto = 1; + /** * \brief extract information from config file * @@ -192,7 +196,7 @@ void *ParseAFPConfig(const char *iface) if (rss_queues > 0) { if (rss_queues < aconf->threads) { aconf->threads = rss_queues; - SCLogInfo("More core than RSS queues, using %d threads for interface %s", + SCLogInfo("More cores than RSS queues, using %d threads for interface %s", aconf->threads, iface); } } @@ -252,14 +256,15 @@ void *ParseAFPConfig(const char *iface) (void) SC_ATOMIC_ADD(aconf->ref, aconf->threads); if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-id", &tmpclusterid) != 1) { - SCLogError(SC_ERR_INVALID_ARGUMENT,"Could not get cluster-id from config"); + aconf->cluster_id = (uint16_t)(cluster_id_auto++); } else { aconf->cluster_id = (uint16_t)atoi(tmpclusterid); SCLogDebug("Going to use cluster-id %" PRId32, aconf->cluster_id); } if (ConfGetChildValueWithDefault(if_root, if_default, "cluster-type", &tmpctype) != 1) { - SCLogError(SC_ERR_GET_CLUSTER_TYPE_FAILED,"Could not get cluster-type from config"); + /* default to our safest choice: flow hashing + defrag enabled */ + aconf->cluster_type = PACKET_FANOUT_HASH | PACKET_FANOUT_FLAG_DEFRAG; } else if (strcmp(tmpctype, "cluster_round_robin") == 0) { SCLogInfo("Using round-robin cluster mode for AF_PACKET (iface %s)", aconf->iface);