commit 9926be60eb43938f818d022871493900c57689d3
parent a4a5fe3eb2d9d46c60721f64e65ad222bda72c6e
Author: Yersa Nordman <yersa@finwo.nl>
Date: Thu, 12 Oct 2023 00:28:58 +0200
Register bond interface with epoll as well
Diffstat:
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -36,7 +36,6 @@ int64_t millis() {
void handle_packet_bond(struct pmlag_bond *bond) {
int i, buflen;
- struct sockaddr_ll saddr_ll;
buflen = read(bond->sockfd, rcvbuf, RCVBUFSIZ);
// Get interface to send the packet from
@@ -248,7 +247,21 @@ int main(int argc, const char **argv) {
bond->sockfd = 0;
continue;
}
- /* printf("Opened tap for %s\n", bond->name); */
+ bond->epev = calloc(1, sizeof(struct epoll_event));
+ if (!bond->epev) {
+ perror("calloc");
+ bond->epev = NULL;
+ continue;
+ }
+ bond->epev->events = EPOLLIN;
+ bond->epev->data.ptr = bond;
+ if (epoll_ctl(epfd, EPOLL_CTL_ADD, bond->sockfd, bond->epev)) {
+ free(bond->epev);
+ close(bond->sockfd);
+ bond->sockfd = 0;
+ bond->epev = NULL;
+ continue;
+ }
}
// (re)initialize routing table
diff --git a/src/util/config.h b/src/util/config.h
@@ -22,6 +22,7 @@ struct pmlag_iface {
struct pmlag_bond {
PMLAG_ENTITY_TYPE type;
char *name;
+ struct epoll_event *epev;
PMLAG_STATE state;
int bc_timer;
uint16_t bc_id;