禁止在网口未运行时添加路由及地址

Signed-off-by: liangbotong <liangbotong@huawei.com>
This commit is contained in:
liangbotong
2023-04-18 13:56:03 +08:00
parent 24da81f7af
commit fd1a22b5d2
3 changed files with 14 additions and 2 deletions
+1 -1
View File
@@ -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
+6
View File
@@ -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;
+7 -1
View File
@@ -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;