From fd1a22b5d2ab87d3b317ea8f6656436a48cb60c1 Mon Sep 17 00:00:00 2001 From: liangbotong Date: Tue, 18 Apr 2023 13:56:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E5=9C=A8=E7=BD=91=E5=8F=A3?= =?UTF-8?q?=E6=9C=AA=E8=BF=90=E8=A1=8C=E6=97=B6=E6=B7=BB=E5=8A=A0=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E5=8F=8A=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liangbotong --- src/linux/drivers/net/bt/Makefile | 2 +- src/linux/net/newip/nip_addrconf.c | 6 ++++++ src/linux/net/newip/route.c | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/linux/drivers/net/bt/Makefile b/src/linux/drivers/net/bt/Makefile index 74ae415..15494e8 100644 --- a/src/linux/drivers/net/bt/Makefile +++ b/src/linux/drivers/net/bt/Makefile @@ -1,3 +1,3 @@ # enable btdev: -# kernel/linux/linux-5.10/drivers/net/Makefile add obj-y += bt/ +# kernel/linux/linux-5.10/drivers/net/Makefile add obj-y += bt/ or obj-$(CONFIG_NEWIP) += bt/ obj-y += btdev.o diff --git a/src/linux/net/newip/nip_addrconf.c b/src/linux/net/newip/nip_addrconf.c index 64d953e..1badbca 100644 --- a/src/linux/net/newip/nip_addrconf.c +++ b/src/linux/net/newip/nip_addrconf.c @@ -96,6 +96,12 @@ static struct ninet_ifaddr *nip_add_addr(struct ninet_dev *idev, goto rcu_lock_out; } + if (!netif_running(idev->dev)) { + nip_dbg("network interface is not running"); + err = -ENODEV; + goto rcu_lock_out; + } + if (idev->cnf.disable_nip) { err = -EACCES; goto rcu_lock_out; diff --git a/src/linux/net/newip/route.c b/src/linux/net/newip/route.c index 0ede62a..e7c8a4a 100644 --- a/src/linux/net/newip/route.c +++ b/src/linux/net/newip/route.c @@ -428,7 +428,13 @@ static struct nip_rt_info *nip_route_info_create(struct nip_fib_config *cfg) nip_dbg("fail to get ninet dev (ifindex=%u)", cfg->fc_ifindex); goto out; } - + /* Do not add a route when the network port is not running + * to avoid incorrect route selection + */ + if (!netif_running(idev->dev)) { + nip_dbg("network interface is not running"); + goto out; + } if (cfg->fc_metric == 0) cfg->fc_metric = NIP_RT_PRIO_USER; -- Gitee