commit 542b5debcac44cab857cdbe1e6847608563812cd
parent 7e6c6359d47b5b79ac879543752394942a1fc6e6
Author: Robin Bron <robin@finwo.nl>
Date: Wed, 8 Mar 2023 21:30:57 +0100
Removed debug printf's
Diffstat:
9 files changed, 34 insertions(+), 109 deletions(-)
diff --git a/Makefile b/Makefile
@@ -4,7 +4,7 @@ SRC:=
SRC+=$(wildcard src/*.c)
SRC+=$(wildcard src/*/*.c)
-override CFLAGS?=-Wall -g -O2
+override CFLAGS?=-Wall -s -O2
INCLUDES:=
INCLUDES+=-I src
diff --git a/README.md b/README.md
@@ -27,4 +27,4 @@ This project is a work in progress, the license(s) shown here are not complete
TODO:
- benhoyt/inih
- cofyc/argparse
-- tidwall/btree
+- finwo/mindex
diff --git a/manpage.1.md b/manpage.1.md
@@ -27,4 +27,4 @@ This project is a work in progress, the license(s) shown here are not complete
TODO:
- benhoyt/inih
- cofyc/argparse
-- tidwall/btree
+- finwo/mindex
diff --git a/pmlag.1 b/pmlag.1
@@ -34,4 +34,4 @@ repository, after which you can run \f[V]make\f[R] to build the project.
This project is a work in progress, the license(s) shown here are not
complete
.PP
-TODO: - benhoyt/inih - cofyc/argparse - tidwall/btree
+TODO: - benhoyt/inih - cofyc/argparse - finwo/mindex
diff --git a/pmlag.html b/pmlag.html
@@ -176,6 +176,6 @@ project.</p>
<h1 id="license">LICENSE</h1>
<p>This project is a work in progress, the license(s) shown here are not
complete</p>
-<p>TODO: - benhoyt/inih - cofyc/argparse - tidwall/btree</p>
+<p>TODO: - benhoyt/inih - cofyc/argparse - finwo/mindex</p>
</body>
</html>
diff --git a/src/task/bond.c b/src/task/bond.c
@@ -17,14 +17,14 @@ int task_bond_onpacket(struct pmlag_bond *bond, unsigned char *buffer, size_t bu
struct sockaddr_ll saddr_ll;
saddr_ll.sll_halen = ETH_ALEN;
- // Debug: print eth header
- printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x > %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, %.4x (%ld), %ld\n",
- buffer[6],buffer[7],buffer[8],buffer[9],buffer[10],buffer[11], // SRC
- buffer[0],buffer[1],buffer[2],buffer[3],buffer[ 4],buffer[ 5], // DST
- ((unsigned int)((unsigned char)buffer[12]) << 8) + buffer[13], // PROTO
- buflen,
- mindex_length(bond->rt)
- );
+ /* // Debug: print eth header */
+ /* printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x > %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, %.4x (%ld), %ld\n", */
+ /* buffer[6],buffer[7],buffer[8],buffer[9],buffer[10],buffer[11], // SRC */
+ /* buffer[0],buffer[1],buffer[2],buffer[3],buffer[ 4],buffer[ 5], // DST */
+ /* ((unsigned int)((unsigned char)buffer[12]) << 8) + buffer[13], // PROTO */
+ /* buflen, */
+ /* mindex_length(bond->rt) */
+ /* ); */
// Get interface to send the packet from
memcpy(saddr_ll.sll_addr, buffer, ETH_ALEN);
@@ -135,78 +135,3 @@ void * task_bond_thread(void *arg) {
pthread_exit(NULL);
return NULL;
}
-
-/* void * thread_bond_old(void *arg) { */
-/* struct pmlag_rt_entry *rt_entry; */
-/* int iface_list_len; */
-/* int iface_list_sel; */
-/* pmlag_iface_llist *iface_list_entry; */
-
-/* sleep(1); */
-
-/* while(1) { */
-/* /1* sleep(1); *1/ */
-
-/* // Fetch entry from routing table */
-/* pthread_mutex_lock(&(bond->mtx_rt)); */
-/* rt_entry = mindex_get(bond->rt, &(struct pmlag_rt_entry){ .mac = buffer }); */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* // Fetch length of interface list */
-/* iface_list_len = 0; */
-/* iface_list_entry = rt_entry->interfaces; */
-/* while(iface_list_entry) { */
-/* iface_list_len++; */
-/* iface_list_entry = iface_list_entry->next; */
-/* } */
-
-/* // Select interface at random */
-/* iface_list_sel = rand() % iface_list_len; */
-/* iface_list_entry = rt_entry->interfaces; */
-/* while(iface_list_sel--) iface_list_entry = iface_list_entry->next; */
-/* iface = iface_list_entry->data; */
-
-/* // Unlock routing table */
-/* pthread_mutex_unlock(&(bond->mtx_rt)); */
-
-/* // Prepare saddr_ll for sendto */
-/* saddr_ll.sll_ifindex = iface->ifidx; */
-/* memcpy(saddr_ll.sll_addr, buffer, ETH_ALEN); */
-
-/* // Forward packet to iface as-is */
-/* send_len = sendto(iface->sockfd, buffer, buflen, 0, (const struct sockaddr*)&saddr_ll, sizeof(struct sockaddr_ll)); */
-/* if(send_len != buflen) { */
-/* perror("sendto"); */
-/* /1* pthread_exit(NULL); *1/ */
-/* /1* return NULL; *1/ */
-/* } */
-/* } */
-
- /* // Wait for iface threads to finish */
- /* iface = bond->interfaces; */
- /* while(iface) { */
- /* pthread_join(iface->tid, NULL); */
- /* iface = iface->next; */
- /* } */
-
- /* pthread_exit(NULL); */
- /* return NULL; */
-/* } */
diff --git a/src/task/iface.c b/src/task/iface.c
@@ -14,13 +14,13 @@ int task_iface_onpacket(struct pmlag_iface *iface, unsigned char *buffer, size_t
uint16_t proto;
int16_t bcidx;
- // Debug: print eth header
- printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x < %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, %.4x (%ld)\n",
- buffer[0],buffer[1],buffer[2],buffer[3],buffer[ 4],buffer[ 5], // DST
- buffer[6],buffer[7],buffer[8],buffer[9],buffer[10],buffer[11], // SRC
- ((unsigned int)((unsigned char)buffer[12]) << 8) + buffer[13], // PROTO
- buflen
- );
+ /* // Debug: print eth header */
+ /* printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x < %.2x:%.2x:%.2x:%.2x:%.2x:%.2x, %.4x (%ld)\n", */
+ /* buffer[0],buffer[1],buffer[2],buffer[3],buffer[ 4],buffer[ 5], // DST */
+ /* buffer[6],buffer[7],buffer[8],buffer[9],buffer[10],buffer[11], // SRC */
+ /* ((unsigned int)((unsigned char)buffer[12]) << 8) + buffer[13], // PROTO */
+ /* buflen */
+ /* ); */
// Update the routing table as-needed
proto = ((uint16_t)((unsigned char)buffer[(ETH_ALEN*2)+0]) << 8) + buffer[(ETH_ALEN*2)+1];
diff --git a/src/util/config.h b/src/util/config.h
@@ -31,14 +31,14 @@ struct pmlag_iface {
};
struct pmlag_bond {
- void *next; // linked-list next reference
- char *name; // name of the bond interface
- int mode; // which mode to run pmlag in for this bond
- int sockfd; // file descriptor for the bond socket interface
+ void *next; // linked-list next reference
+ char *name; // name of the bond interface
+ int mode; // which mode to run pmlag in for this bond
+ int sockfd; // file descriptor for the bond socket interface
int16_t bcidx; // big-endian broadcast index for quickly detecting dead paths
- pthread_t tid; // thread id where the bond interface listener recides in
- pthread_mutex_t mtx_rt; // lock for the routing table of the bond
- struct mindex_t *rt; // pointer to the routing table
+ pthread_t tid; // thread id where the bond interface listener recides in
+ pthread_mutex_t mtx_rt; // lock for the routing table of the bond
+ struct mindex_t *rt; // pointer to the routing table
pmlag_iface_llist *interfaces; // linked-list of interfaces contained in the bond
};
diff --git a/src/util/socket.c b/src/util/socket.c
@@ -15,14 +15,14 @@
#include "socket.h"
unsigned char * iface_mac(char * ifname) {
- struct ifreq ifr;
- unsigned char *mac = calloc(1, ETH_ALEN);
+ struct ifreq ifr;
+ unsigned char *mac = calloc(1, ETH_ALEN);
int sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
- ifr.ifr_addr.sa_family = AF_PACKET;
- strncpy(ifr.ifr_name , ifname , IFNAMSIZ-1);
- ioctl(sockfd, SIOCGIFHWADDR, &ifr);
- close(sockfd);
- memcpy(mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
+ ifr.ifr_addr.sa_family = AF_PACKET;
+ strncpy(ifr.ifr_name , ifname , IFNAMSIZ-1);
+ ioctl(sockfd, SIOCGIFHWADDR, &ifr);
+ close(sockfd);
+ memcpy(mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
return mac;
}