From: Alexey Date: Thu, 1 Feb 2024 09:37:30 +0000 (+0000) Subject: Throw, not self_destruct(), on qos_flow configuration errors (#1644) X-Git-Tag: SQUID_7_0_1~221 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=48ee361eea2002d0d57ec65956a5e035351732b7;p=thirdparty%2Fsquid.git Throw, not self_destruct(), on qos_flow configuration errors (#1644) --- diff --git a/src/ip/QosConfig.cc b/src/ip/QosConfig.cc index 20800da3dd..ad32975f6b 100644 --- a/src/ip/QosConfig.cc +++ b/src/ip/QosConfig.cc @@ -10,6 +10,7 @@ #include "acl/Gadgets.h" #include "base/IoManip.h" #include "base/PackableStream.h" +#include "base/TextException.h" #include "cache_cf.h" #include "comm/Connection.h" #include "compat/cmsg.h" @@ -20,6 +21,7 @@ #include "ip/QosConfig.h" #include "ip/tools.h" #include "Parsing.h" +#include "sbuf/Stream.h" #include "Store.h" #include @@ -305,8 +307,7 @@ Ip::Qos::Config::parseConfigLine() /* Assume preserve is true. We don't set at initialisation as this affects isHitTosActive(). We have to do this now, as we may never match the 'tos' parameter below */ #if !USE_QOS_TOS - debugs(3, DBG_CRITICAL, "ERROR: Invalid option 'qos_flows'. QOS features not enabled in this build"); - self_destruct(); + throw TextException(ToSBuf("Invalid option 'qos_flows'. QOS features not enabled in this build"), Here()); #endif while ( (token = ConfigParser::NextToken()) ) { @@ -325,13 +326,11 @@ Ip::Qos::Config::parseConfigLine() << "Netfilter mark preservation not available."); #endif // USE_LIBNETFILTERCONNTRACK #elif SO_MARK // SO_MARK && USE_LIBCAP - debugs(3, DBG_CRITICAL, "ERROR: Invalid parameter 'mark' in qos_flows option. " - << "Linux Netfilter marking not available without LIBCAP support."); - self_destruct(); + throw TextException(ToSBuf("Invalid parameter 'mark' in qos_flows option. ", + "Linux Netfilter marking not available on this platform."), Here()); #else // SO_MARK && USE_LIBCAP - debugs(3, DBG_CRITICAL, "ERROR: Invalid parameter 'mark' in qos_flows option. " - << "Linux Netfilter marking not available on this platform."); - self_destruct(); + throw TextException(ToSBuf("Invalid parameter 'mark' in qos_flows option. ", + "Linux Netfilter marking not available on this platform."), Here()); #endif // SO_MARK && USE_LIBCAP } else if (strncmp(token, "tos",3) == 0) { preserveMissTos = true; @@ -346,14 +345,12 @@ Ip::Qos::Config::parseConfigLine() if (mark) { if (!xstrtoui(&token[10], nullptr, &markLocalHit, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad mark local-hit value " << &token[10]); - self_destruct(); + throw TextException(ToSBuf("Bad mark local-hit value ", &token[10]), Here()); } } else { unsigned int v = 0; if (!xstrtoui(&token[10], nullptr, &v, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad TOS local-hit value " << &token[10]); - self_destruct(); + throw TextException(ToSBuf("Bad TOS local-hit value ", &token[10]), Here()); } tosLocalHit = (tos_t)v; } @@ -362,14 +359,12 @@ Ip::Qos::Config::parseConfigLine() if (mark) { if (!xstrtoui(&token[12], nullptr, &markSiblingHit, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad mark sibling-hit value " << &token[12]); - self_destruct(); + throw TextException(ToSBuf("Bad mark sibling-hit value ", &token[12]), Here()); } } else { unsigned int v = 0; if (!xstrtoui(&token[12], nullptr, &v, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad TOS sibling-hit value " << &token[12]); - self_destruct(); + throw TextException(ToSBuf("Bad TOS sibling-hit value ", &token[12]), Here()); } tosSiblingHit = (tos_t)v; } @@ -378,14 +373,12 @@ Ip::Qos::Config::parseConfigLine() if (mark) { if (!xstrtoui(&token[11], nullptr, &markParentHit, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad mark parent-hit value " << &token[11]); - self_destruct(); + throw TextException(ToSBuf("Bad mark parent-hit value ", &token[11]), Here()); } } else { unsigned int v = 0; if (!xstrtoui(&token[11], nullptr, &v, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad TOS parent-hit value " << &token[11]); - self_destruct(); + throw TextException(ToSBuf("Bad TOS parent-hit value ", &token[11]), Here()); } tosParentHit = (tos_t)v; } @@ -395,8 +388,7 @@ Ip::Qos::Config::parseConfigLine() char *end; if (mark) { if (!xstrtoui(&token[5], &end, &markMiss, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss value " << &token[5]); - self_destruct(); + throw TextException(ToSBuf("Bad mark miss value ", &token[5]), Here()); } if (*end == '/') { if (!xstrtoui(end + 1, nullptr, &markMissMask, 0, std::numeric_limits::max())) { @@ -409,8 +401,7 @@ Ip::Qos::Config::parseConfigLine() } else { unsigned int v = 0; if (!xstrtoui(&token[5], &end, &v, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss value " << &token[5]); - self_destruct(); + throw TextException(ToSBuf("Bad TOS miss value ", &token[5]), Here()); } tosMiss = (tos_t)v; if (*end == '/') { @@ -427,8 +418,7 @@ Ip::Qos::Config::parseConfigLine() } else if (strcmp(token, "disable-preserve-miss") == 0) { if (preserveMissTosMask!=0xFFU || preserveMissMarkMask!=0xFFFFFFFFU) { - debugs(3, DBG_CRITICAL, "ERROR: miss-mask feature cannot be set with disable-preserve-miss"); - self_destruct(); + throw TextException(ToSBuf("miss-mask feature cannot be set with disable-preserve-miss"), Here()); } if (mark) { preserveMissMark = false; @@ -442,19 +432,16 @@ Ip::Qos::Config::parseConfigLine() if (mark && preserveMissMark) { if (!xstrtoui(&token[10], nullptr, &preserveMissMarkMask, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad mark miss-mark value " << &token[10]); - self_destruct(); + throw TextException(ToSBuf("Bad mark miss-mark value ", &token[10]), Here()); } } else if (preserveMissTos) { unsigned int v = 0; if (!xstrtoui(&token[10], nullptr, &v, 0, std::numeric_limits::max())) { - debugs(3, DBG_CRITICAL, "ERROR: Bad TOS miss-mark value " << &token[10]); - self_destruct(); + throw TextException(ToSBuf("Bad TOS miss-mark value ", &token[10]), Here()); } preserveMissTosMask = (tos_t)v; } else { - debugs(3, DBG_CRITICAL, "ERROR: miss-mask feature cannot be set without miss-preservation enabled"); - self_destruct(); + throw TextException(ToSBuf("miss-mask feature cannot be set without miss-preservation enabled"), Here()); } }