From 153cad361451210c77b8b6305899488f80ae569b Mon Sep 17 00:00:00 2001 From: r-caamano Date: Mon, 14 Aug 2023 00:27:32 +0000 Subject: [PATCH] Fixed potential race condition for filter application in case dhcp not available at boot --- CHANGELOG.md | 7 +++++++ src/zfw.c | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6592d9b..2457202 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). --- +# [0.4.6] - 2023-08-13 + +### + +- Fixed potential race condition if upstream DHCP server is not functioning when FW inits ebpf. + Changed address family match to ethernet when applying TC Filters/Diag settings. + # [0.4.5] - 2023-08-03 ### diff --git a/src/zfw.c b/src/zfw.c index 4e2df2b..2d51d30 100644 --- a/src/zfw.c +++ b/src/zfw.c @@ -147,7 +147,7 @@ char *monitor_interface; char *tc_interface; char *object_file; char *direction_string; -const char *argp_program_version = "0.4.5"; +const char *argp_program_version = "0.4.6"; struct ring_buffer *ring_buffer; __u8 if_list[MAX_IF_LIST_ENTRIES]; @@ -1017,7 +1017,9 @@ void interface_tc() */ while (address) { - if (address->ifa_addr && (address->ifa_addr->sa_family == AF_INET)) + if(address->ifa_addr && ((!strncmp(address->ifa_name, "ziti0", 4) && (address->ifa_addr->sa_family == AF_INET)) + || (!strncmp(address->ifa_name, "tun", 3) && (address->ifa_addr->sa_family == AF_INET)) + || (address->ifa_addr->sa_family == AF_PACKET))) { idx = if_nametoindex(address->ifa_name); if(!idx){ @@ -1117,7 +1119,9 @@ void interface_diag() */ while (address) { - if (address->ifa_addr && (address->ifa_addr->sa_family == AF_INET)) + if (address->ifa_addr && ((!strncmp(address->ifa_name, "ziti0", 4) && (address->ifa_addr->sa_family == AF_INET)) + || (!strncmp(address->ifa_name, "tun", 3) && (address->ifa_addr->sa_family == AF_INET)) + || (address->ifa_addr->sa_family == AF_PACKET))) { idx = if_nametoindex(address->ifa_name); if(!idx){