connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtnl: Ignore adding/removing interface to/from bridge
@ 2023-04-01 23:59 Jonathan Liu
  2023-04-11  7:40 ` Daniel Wagner
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Liu @ 2023-04-01 23:59 UTC (permalink / raw)
  To: connman; +Cc: Jonathan Liu

Avoids wifi interface being removed and added again when tethering is
disabled.
---
 src/rtnl.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/rtnl.c b/src/rtnl.c
index a87296ff..e8a8325e 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -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));
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtnl: Ignore adding/removing interface to/from bridge
  2023-04-01 23:59 [PATCH] rtnl: Ignore adding/removing interface to/from bridge Jonathan Liu
@ 2023-04-11  7:40 ` Daniel Wagner
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Wagner @ 2023-04-11  7:40 UTC (permalink / raw)
  To: connman, Jonathan Liu; +Cc: Daniel Wagner


On Sun, 02 Apr 2023 09:59:19 +1000, Jonathan Liu wrote:
> 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,
-- 
Daniel Wagner <wagi@monom.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-11  7:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-01 23:59 [PATCH] rtnl: Ignore adding/removing interface to/from bridge Jonathan Liu
2023-04-11  7:40 ` Daniel Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).