mirror of
https://github.com/openharmony/kernel_common_modules_newip.git
synced 2026-07-20 00:53:31 -04:00
!47 解决多个网口配置相同地址只能配置第一个接口的问题
Merge pull request !47 from tangruifeng/master
This commit is contained in:
@@ -59,6 +59,13 @@ int nip_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||
struct nip_rt_info *nip_dst_alloc(struct net *net, struct net_device *dev,
|
||||
int flags);
|
||||
|
||||
static inline bool nip_addr_and_ifindex_eq(const struct nip_addr *a1,
|
||||
const struct nip_addr *a2, int ifindex1, int ifindex2)
|
||||
{
|
||||
return (a1->bitlen == a2->bitlen) && (a1->bitlen <= NIP_ADDR_BIT_LEN_MAX) &&
|
||||
(memcmp(&a1->v.u, &a2->v.u, a1->bitlen >> 3) == 0) && (ifindex1 == ifindex2);
|
||||
};
|
||||
|
||||
static inline bool nip_addr_eq(const struct nip_addr *a1,
|
||||
const struct nip_addr *a2)
|
||||
{
|
||||
|
||||
@@ -115,8 +115,10 @@ int nip_fib_add(struct hlist_head *nip_tb_head, struct nip_rt_info *rt)
|
||||
h = &nip_tb_head[hash];
|
||||
|
||||
hlist_for_each_entry(fib_node, h, fib_hlist) {
|
||||
if (nip_addr_eq(&fib_node->nip_route_info->rt_dst,
|
||||
&rt->rt_dst)) {
|
||||
if (nip_addr_and_ifindex_eq
|
||||
(&fib_node->nip_route_info->rt_dst, &rt->rt_dst,
|
||||
fib_node->nip_route_info->rt_idev->dev->ifindex,
|
||||
rt->rt_idev->dev->ifindex)) {
|
||||
err = -EEXIST;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user