Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc add zfw calls #1000

Open
wants to merge 24 commits into
base: release-1.x
Choose a base branch
from
Open

Rc add zfw calls #1000

wants to merge 24 commits into from

Conversation

r-caamano
Copy link
Member

This pull request adds system calls to zfw for the purpose allowing bi-directional transparency. I allows user to specify diverter function either via command line argument or environmental variable with command line taking precedence. ```-D, diverter or ZITI_DIVERTER =. I also added a more restrictive option which in addition to transparency support also provides full firewall filtering -f, --diverter-fw | DIVERTER_FIREWALL=. It assumes zfw binaries/ebpf objects are in /opt/openziti/bin by default but can be modified via environmental variable ZFW_OBJECT_PATH=.

…opt/openziti/bin directly vs pointing at symbolic link in /usr/sbn
…ent service so zfw can then remove the link route
…d rules and dns range rules if running in -f, --diverterFw mode
…er or firewall mode/interfaces via environmental variables
… to diverterIf now that it is a list of interfaces
… driver call backs rather than direct ip route system call
@r-caamano r-caamano requested a review from a team as a code owner October 4, 2024 14:49
unsigned char count = 0;
int rndm;
uv_random(NULL, NULL, &rndm, sizeof(rndm), 0, NULL);
random_port = htons(1024 + rndm % (65535 - 1023));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is htons (network byte order) really needed here? I could see it if the port value was going into a packet that gets put on the wire and received by hosts of any architecture, but I think we're just passing a command line option to a local process?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No its not. I had copied this function over from where I needed to pass it directly to an ebpf map key which stores the port in network order but here it can be in host order, so the htons can be omitted.

}
else if (pid == 0)
{
execv("/opt/openziti/bin/user/user_rules.sh", parmList);
Copy link
Member

@scareything scareything Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the parameters being used by user_rules.sh? specifically, should zfw_path be passed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excecv statement should have been execv(zfw_path, parmList) , so yes this should be changed.

close(fd);
char *protocols[2] = {"tcp", "udp"};
for(int x = 0; x < 2; x++){
char *const parmList[] = {zfw_path, "-I", "-c", prefix, "-m", prefix_len, "-l", "1" , "-h", "65535", "-t", "65535", "-p", protocols[x], NULL};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix is an int value here. should this be a string IP?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefix is a char array line 2621 char prefix[INET_ADDRSTRLEN];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants