Skip to content

Commit

Permalink
Merge pull request #7 from netfoundry/v0.3.8_candidate
Browse files Browse the repository at this point in the history
Refactored start_ebpf_router.py
  • Loading branch information
r-caamano authored Jun 26, 2023
2 parents fc5af2a + d5fb899 commit 351078e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.8] - 2023-06-26

###

- Fixed missing terminating bold in README.md.
- Refactored start_ebpf_router.py to suppress some output messages.

# [0.3.7] - 2023-06-16

###
Expand Down
14 changes: 8 additions & 6 deletions files/scripts/start_ebpf_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import subprocess
import time
import shutil

def tc_status(interface, direction):
process = subprocess.Popen(['tc', 'filter', 'show', 'dev', interface, direction], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down Expand Up @@ -145,7 +146,7 @@ def set_local_rules(resolver):
print("resolver_port=", resolver_port)
os.system('/opt/openziti/bin/zfw -I -c ' + lan_ip + ' -m ' + lan_mask + ' -l ' + resolver_port + ' -h ' + resolver_port + ' -t 0 -p tcp')
os.system('/opt/openziti/bin/zfw -I -c ' + lan_ip + ' -m ' + lan_mask + ' -l ' + resolver_port + ' -h ' + resolver_port + ' -t 0 -p udp')

netfoundry = False
if(os.path.exists('/opt/netfoundry/ziti/ziti-router/config.yml')):
netfoundry = True
Expand Down Expand Up @@ -278,10 +279,11 @@ def set_local_rules(resolver):

ingress_object_file = '/opt/openziti/bin/zfw_tc_ingress.o'
egress_object_file = '/opt/openziti/bin/zfw_tc_outbound_track.o'
if os.system("/opt/openziti/bin/zfw -L -E"):
test1 = os.system("/opt/openziti/bin/zfw -Q")
if test1:
print("failed to clear ebpf maps")
status = subprocess.run(['/opt/openziti/bin/zfw', '-L', '-E'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if(status.returncode):
test1 = subprocess.run(['/opt/openziti/bin/zfw', '-Q'],stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if(test1.returncode):
print("Ebpf not running no maps to clear")
for i in internal_list:
if(not tc_status(i, "ingress")):
test1 = os.system("/opt/openziti/bin/zfw -X " + i + " -O " + ingress_object_file + " -z ingress")
Expand Down Expand Up @@ -398,5 +400,5 @@ def set_local_rules(resolver):
else:
print("ziti-router.service already converted. Nothing to do!")
else:
print("Skipping ziti-router.service conversion. File does not exist or config.yml not set!")
print("Skipping ziti-router.service conversion. File does not exist or no changes made to config.yml!")
sys.exit(0)
2 changes: 1 addition & 1 deletion src/zfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static char *tun_interface;
static char *tc_interface;
static char *object_file;
static char *direction_string;
const char *argp_program_version = "0.3.7";
const char *argp_program_version = "0.3.8";

static __u8 if_list[MAX_IF_LIST_ENTRIES];
int ifcount = 0;
Expand Down

0 comments on commit 351078e

Please sign in to comment.