From: Jonathan Liu <net147@gmail.com>
To: connman@lists.linux.dev
Cc: Jonathan Liu <net147@gmail.com>
Subject: [PATCH] rtnl: Ignore adding/removing interface to/from bridge
Date: Sun, 2 Apr 2023 09:59:19 +1000 [thread overview]
Message-ID: <20230401235919.111754-1-net147@gmail.com> (raw)
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
next reply other threads:[~2023-04-02 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-01 23:59 Jonathan Liu [this message]
2023-04-11 7:40 ` [PATCH] rtnl: Ignore adding/removing interface to/from bridge Daniel Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230401235919.111754-1-net147@gmail.com \
--to=net147@gmail.com \
--cc=connman@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).