-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
babeld: add remove_interface function
Add the ubus function to remove an interface from babeld: ubus call babeld remove_interface '{"ifname":"eth0"}' Signed-off-by: Nick Hainke <[email protected]>
- Loading branch information
1 parent
879725c
commit 31d3611
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
babeld/patches/100-interface-local-add-remove-interface-function.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
From 2f75f3d7073bad9b4b0c031aa792013fd6b61c19 Mon Sep 17 00:00:00 2001 | ||
From: Polynomialdivision <[email protected]> | ||
Date: Tue, 1 Feb 2022 22:37:29 +0100 | ||
Subject: [PATCH] interface/local: add remove_interface function | ||
|
||
Babeld can add interfaces dynamically. However, babeld is missing a | ||
function to remove interfaces and stop meshing on them. Add a function | ||
that can do it. | ||
|
||
Signed-off-by: Nick Hainke <[email protected]> | ||
--- | ||
interface.c | 33 +++++++++++++++++++++++++++++++++ | ||
interface.h | 1 + | ||
local.h | 1 + | ||
3 files changed, 35 insertions(+) | ||
|
||
--- a/interface.c | ||
+++ b/interface.c | ||
@@ -94,6 +94,39 @@ add_interface(char *ifname, struct inter | ||
return ifp; | ||
} | ||
|
||
+void | ||
+remove_interface(char *ifname) | ||
+{ | ||
+ struct interface *tmp_ifp, *ifp = NULL; | ||
+ | ||
+ if(interfaces == NULL) | ||
+ return; | ||
+ | ||
+ if(strcmp(interfaces->name, ifname) == 0) { | ||
+ tmp_ifp = interfaces; | ||
+ interface_updown(tmp_ifp, 0); | ||
+ interfaces = tmp_ifp->next; | ||
+ free(tmp_ifp); | ||
+ return; | ||
+ } | ||
+ | ||
+ FOR_ALL_INTERFACES(ifp) { | ||
+ if(ifp->next == NULL) | ||
+ break; | ||
+ if(strcmp(ifp->next->name, ifname) == 0) { | ||
+ break; | ||
+ } | ||
+ } | ||
+ | ||
+ if(ifp->next == NULL) | ||
+ return; | ||
+ | ||
+ tmp_ifp = ifp->next; | ||
+ interface_updown(tmp_ifp, 0); | ||
+ ifp->next = tmp_ifp->next; | ||
+ free(tmp_ifp); | ||
+} | ||
+ | ||
int | ||
flush_interface(char *ifname) | ||
{ | ||
--- a/interface.h | ||
+++ b/interface.h | ||
@@ -147,6 +147,7 @@ if_up(struct interface *ifp) | ||
} | ||
|
||
struct interface *add_interface(char *ifname, struct interface_conf *if_conf); | ||
+void remove_interface(char *ifname); | ||
int flush_interface(char *ifname); | ||
unsigned jitter(struct buffered *buf, int urgent); | ||
unsigned update_jitter(struct interface *ifp, int urgent); | ||
--- a/local.h | ||
+++ b/local.h | ||
@@ -27,6 +27,7 @@ struct xroute; | ||
#define LOCAL_FLUSH 0 | ||
#define LOCAL_ADD 1 | ||
#define LOCAL_CHANGE 2 | ||
+#define LOCAL_REMOVE 3 | ||
|
||
#ifndef MAX_LOCAL_SOCKETS | ||
#define MAX_LOCAL_SOCKETS 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters