From 680673c97a5f65038fb273bcff57e705b0620f7f Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Tue, 9 May 2023 15:38:08 +0300 Subject: [PATCH] Driver: fortcout: Simplify fort_callout_ale_classify() --- src/driver/fortcout.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/driver/fortcout.c b/src/driver/fortcout.c index 860d5eb2..5741f26b 100644 --- a/src/driver/fortcout.c +++ b/src/driver/fortcout.c @@ -348,6 +348,16 @@ inline static void fort_callout_ale_by_conf(PCFORT_CALLOUT_ARG ca, PCFORT_CALLOU } } +inline static BOOL fort_callout_ale_is_local_address(PFORT_CALLOUT_ARG ca, + PCFORT_CALLOUT_ALE_EXTRA cx, PFORT_DEVICE_CONF device_conf, const UINT32 classify_flags) +{ + if (fort_device_flag(device_conf, FORT_DEVICE_BOOT_FILTER_LOCALS) != 0) + return FALSE; + + return ((classify_flags & FWP_CONDITION_FLAG_IS_LOOPBACK) != 0 + || fort_addr_is_local_broadcast(cx->remote_ip, ca->isIPv6)); +} + static void fort_callout_ale_classify(PFORT_CALLOUT_ARG ca, PCFORT_CALLOUT_ALE_INDEX ci) { const UINT32 classify_flags = ca->inFixedValues->incomingValue[ci->flags].value.uint32; @@ -361,20 +371,18 @@ static void fort_callout_ale_classify(PFORT_CALLOUT_ARG ca, PCFORT_CALLOUT_ALE_I ? (const UINT32 *) ca->inFixedValues->incomingValue[ci->remoteIp].value.byteArray16 : &ca->inFixedValues->incomingValue[ci->remoteIp].value.uint32; - PFORT_DEVICE_CONF device_conf = &fort_device()->conf; - - if (fort_device_flag(device_conf, FORT_DEVICE_BOOT_FILTER_LOCALS) == 0 - && ((classify_flags & FWP_CONDITION_FLAG_IS_LOOPBACK) != 0 - || fort_addr_is_local_broadcast(remote_ip, ca->isIPv6))) { - fort_callout_classify_permit(ca->filter, ca->classifyOut); - return; - } - FORT_CALLOUT_ALE_EXTRA cx = { .is_reauth = is_reauth, .remote_ip = remote_ip, }; + PFORT_DEVICE_CONF device_conf = &fort_device()->conf; + + if (fort_callout_ale_is_local_address(ca, &cx, device_conf, classify_flags)) { + fort_callout_classify_permit(ca->filter, ca->classifyOut); + return; + } + fort_callout_ale_by_conf(ca, ci, &cx, device_conf); }