Skip to contentSkip to conversation

rtnl: Ignore adding/removing interface to/from bridge

PATCH Applied Jonathan Liu 2 participants 2 messages Apr 2, 2023 – Apr 11, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtnl: Ignore adding/removing interface to/from bridge

Avoids wifi interface being removed and added again when tethering is disabled.

---
 src/rtnl.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
src/rtnl.c +14 -3
index a87296ff..e8a8325e 100644
@@ -886,7 +886,7 @@ static inline void print_attr(struct rtattr *attr, const char *name)
 		print("  attr %d (len %d)\n", attr->rta_type, len);
 }
 
-static void rtnl_link(struct nlmsghdr *hdr)
+static void rtnl_link(struct nlmsghdr *hdr, bool *has_master)
 {
 	struct ifinfomsg *msg;
 	struct rtattr *attr;
@@ -928,6 +928,7 @@ static void rtnl_link(struct nlmsghdr *hdr)
 			print_attr(attr, "priority");
 			break;
 		case IFLA_MASTER:
+			*has_master = true;
 			print_attr(attr, "master");
 			break;
 		case IFLA_WIRELESS:
@@ -960,22 +961,32 @@ static void rtnl_link(struct nlmsghdr *hdr)
 
 static void rtnl_newlink(struct nlmsghdr *hdr)
 {
+	bool has_master = false;
 	struct ifinfomsg *msg = (struct ifinfomsg *) NLMSG_DATA(hdr);
 
-	rtnl_link(hdr);
+	rtnl_link(hdr, &has_master);
 
 	if (hdr->nlmsg_type == IFLA_WIRELESS)
 		connman_warn_once("Obsolete WEXT WiFi driver detected");
 
+	/* ignore RTM_NEWLINK when adding interface to bridge */
+	if (has_master)
+		return;
+
 	process_newlink(msg->ifi_type, msg->ifi_index, msg->ifi_flags,
 				msg->ifi_change, msg, IFA_PAYLOAD(hdr));
 }
 
 static void rtnl_dellink(struct nlmsghdr *hdr)
 {
+	bool has_master = false;
 	struct ifinfomsg *msg = (struct ifinfomsg *) NLMSG_DATA(hdr);
 
-	rtnl_link(hdr);
+	rtnl_link(hdr, &has_master);
+
+	/* ignore RTM_DELLINK when removing interface from bridge */
+	if (has_master)
+		return;
 
 	process_dellink(msg->ifi_type, msg->ifi_index, msg->ifi_flags,
 				msg->ifi_change, msg, IFA_PAYLOAD(hdr));
Signature · 1 line
2.40.0
#1 lore raw
Quoted 3 lines · Jonathan Liu

Avoids wifi interface being removed and added again when tethering is disabled.

Applied, thanks!

[1/1] rtnl: Ignore adding/removing interface to/from bridge

      commit: 64ba5d457c77ebb65b0a23910d26089973fb6ce7

Best regards,

Signature · 1 line
Daniel Wagner <[email protected]>