Fix NewIP route issues and btdev Makefile

Fix the issue that a network port can add a route or address when it is not running.

The btdev Makefile adds a conditional compilation.

Signed-off-by: liangbotong <liangbotong@huawei.com>
This commit is contained in:
liangbotong
2023-04-20 10:58:50 +08:00
parent ce7d12b6f2
commit c23f7b8ffc
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-$(CONFIG_NEWIP) += bt/
# kernel/linux/linux-5.10/drivers/net/Makefile add obj-y += bt/ or obj-$(CONFIG_NEWIP) += bt/
obj-y += btdev.o
@@ -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;