Skip to content

Commit

Permalink
Merge pull request #49 from netfoundry/v0.7.6-release-candidate
Browse files Browse the repository at this point in the history
Fixed references to unused zet ctrl socket in zfw_tunnel_wrapper.c
  • Loading branch information
r-caamano authored Jun 6, 2024
2 parents e258c9b + 9ef4af1 commit cd1af31
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 38 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.7.6] - 2024-06-04

###

- Fixed issues in zfw_tunnel_wrapper where incorrect reference was made to zet ctrl socket where needed to check status of event socket. Removed all
references to unused zet ctrl socket.

# [0.7.5] - 2024-06-04

###
Expand Down
2 changes: 1 addition & 1 deletion src/zfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ char *log_file_name;
char *object_file;
char *direction_string;

const char *argp_program_version = "0.7.5";
const char *argp_program_version = "0.7.6";
struct ring_buffer *ring_buffer;

__u32 if_list[MAX_IF_LIST_ENTRIES];
Expand Down
42 changes: 5 additions & 37 deletions src/zfw_tunnel_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const char *range_map_path = "/sys/fs/bpf/tc/globals/range_map";
const char *if_list_ext_map_path = "/sys/fs/bpf/tc/globals/if_list_extension_map";
const char *count_map_path = "/sys/fs/bpf/tc/globals/tuple_count_map";
const char *wildcard_port_map_path = "/sys/fs/bpf/tc/globals/wildcard_port_map";
int ctrl_socket, event_socket;
int event_socket;
char tunip_string[16]="";
char tunip_mask_string[10]="";
uint32_t tun_resolver_ip = 0;
Expand Down Expand Up @@ -212,9 +212,6 @@ void close_maps(int code){
if(event_socket != -1){
close(event_socket);
}
if(event_socket != -1){
close(ctrl_socket);
}
if(transp_fd != -1){
close(transp_fd);
}
Expand Down Expand Up @@ -1465,57 +1462,31 @@ void get_string(char source[4096], char dest[2048]){
int run(){
signal(SIGINT, INThandler);
system("clear");
setpath("/tmp/", "ziti-edge-tunnel.sock",SOCK_NAME);
setpath("/tmp/", "ziti-edge-tunnel-event.sock",EVENT_SOCK_NAME);
struct sockaddr_un ctrl_addr;
struct sockaddr_un event_addr;
int new_count = 0;
int old_count =0;
char* command = "{\"Command\":\"ZitiDump\",\"Data\":{\"DumpPath\": \"/tmp/.ziti\"}}";
int command_len = strlen(command);
byte cmdbytes[command_len];
string2Byte(command, cmdbytes);
char *val_type_str, *str;
int val_type;
int ret;


char event_buffer[EVENT_BUFFER_SIZE];
//open Unix client ctrl socket
//open Unix client event socket
event_socket = socket(AF_UNIX, SOCK_STREAM, 0);
if (ctrl_socket == -1) {
perror("socket");
printf("%s\n", strerror(errno));
return 1;
}
//open Unix client ctrl socket
ctrl_socket = socket(AF_UNIX, SOCK_STREAM, 0);
if (ctrl_socket == -1) {
perror("socket");
if (event_socket == -1) {
perror("event_socket");
printf("%s\n", strerror(errno));
return 1;
}
//zero sockaddr_un for compatibility
memset(&event_addr, 0, sizeof(struct sockaddr_un));
memset(&ctrl_addr, 0, sizeof(struct sockaddr_un));
ctrl_addr.sun_family = AF_UNIX;
event_addr.sun_family = AF_UNIX;
//copy string path of symbolic link to Sun Paths
//copy string path of symbolic link to Sun Path
strncpy(event_addr.sun_path, EVENT_SOCK_NAME, sizeof(event_addr.sun_path) - 1);
strncpy(ctrl_addr.sun_path, SOCK_NAME, sizeof(ctrl_addr.sun_path) - 1);
//connect to ziti-edge-tunnel unix sockets
ret = connect(event_socket, (const struct sockaddr *) &event_addr,sizeof(struct sockaddr_un));
if (ret == -1) {
fprintf(stderr, "The ziti-edge-tunnel-event sock is down.\n");
printf("%s\n", strerror(errno));
return -1;
}
ret = connect (ctrl_socket, (const struct sockaddr *) &ctrl_addr,sizeof(struct sockaddr_un));
if (ret == -1) {
fprintf(stderr, "The ziti-edge-tunnel sock is down.\n");
printf("%s\n", strerror(errno));
return -1;
}
while(true)
{
if(tun_fd == -1){
Expand Down Expand Up @@ -1643,9 +1614,6 @@ int main(int argc, char *argv[]) {
if(event_socket != -1){
close(event_socket);
}
if(event_socket != -1){
close(ctrl_socket);
}
sleep(1);
}
return 0;
Expand Down

0 comments on commit cd1af31

Please sign in to comment.