From 238e3327e58950aaa341ecd262b66d72b4730ca6 Mon Sep 17 00:00:00 2001 From: liangbotong Date: Mon, 3 Jul 2023 11:45:24 +0800 Subject: [PATCH] NewIP config file and NS modification 1.config NewIP HOOKS are enabled by default. 2.Use unicast to send NS to update the status of neighbor table entries. Signed-off-by: liangbotong --- newip/src/linux-5.10/net/newip/Kconfig | 2 +- .../linux-5.10/net/newip/nip_hooks_register.c | 4 +- .../linux-5.10/net/newip/nip_hooks_register.h | 2 +- .../third_party/linux-5.10/net/newip/nndisc.c | 39 ++++++++++++------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/newip/src/linux-5.10/net/newip/Kconfig b/newip/src/linux-5.10/net/newip/Kconfig index ce282ce..037ef78 100644 --- a/newip/src/linux-5.10/net/newip/Kconfig +++ b/newip/src/linux-5.10/net/newip/Kconfig @@ -17,7 +17,7 @@ config NEWIP_FAST_KEEPALIVE Support for NewIP fast keepalive. config NEWIP_HOOKS - default n + def_bool NEWIP && HCK_VENDOR_HOOKS help Enable NewIP hooks implemented as tracepoints Allow NewIP modules to attach to tracepoint "hooks" defined via diff --git a/newip/src/linux-5.10/net/newip/nip_hooks_register.c b/newip/src/linux-5.10/net/newip/nip_hooks_register.c index 1d94250..849414e 100644 --- a/newip/src/linux-5.10/net/newip/nip_hooks_register.c +++ b/newip/src/linux-5.10/net/newip/nip_hooks_register.c @@ -53,10 +53,12 @@ void nip_ninet_gifconf_lhck_register(void) REGISTER_HCK_LITE_HOOK(nip_ninet_gifconf_lhck, nip_ninet_gifconf); } -void __init ninet_hooks_init(void) +int __init ninet_hooks_init(void) { nip_ninet_ehashfn_lhck_register(); nip_ninet_gifconf_lhck_register(); + + return 0; } void __exit ninet_hooks_exit(void) diff --git a/newip/src/linux-5.10/net/newip/nip_hooks_register.h b/newip/src/linux-5.10/net/newip/nip_hooks_register.h index b1bc8e7..43bf43d 100644 --- a/newip/src/linux-5.10/net/newip/nip_hooks_register.h +++ b/newip/src/linux-5.10/net/newip/nip_hooks_register.h @@ -13,7 +13,7 @@ #define _NIP_HOOKS_REGISTER_H #ifdef CONFIG_NEWIP_HOOKS -void __init ninet_hooks_init(void); +int __init ninet_hooks_init(void); #endif #endif /* _NIP_HOOKS_REGISTER_H */ diff --git a/newip/third_party/linux-5.10/net/newip/nndisc.c b/newip/third_party/linux-5.10/net/newip/nndisc.c index 918843f..6d1e4d2 100644 --- a/newip/third_party/linux-5.10/net/newip/nndisc.c +++ b/newip/third_party/linux-5.10/net/newip/nndisc.c @@ -375,11 +375,22 @@ static void nndisc_send_ns(struct net_device *dev, nip_dbg("dst output fail"); } +static void __send_ns_packet(__u8 nud_state, struct net_device *dev, + const struct nip_addr *target, const struct nip_addr *saddr) +{ + if (nud_state & NUD_VALID) { + nndisc_send_ns(dev, target, target, saddr); + nip_dbg("unicast ns"); + } else { + nndisc_send_ns(dev, target, &nip_broadcast_addr_arp, saddr); + nip_dbg("multicast ns"); + } +} + static void nndisc_solicit(struct neighbour *neigh, struct sk_buff *skb) { struct net_device *dev = neigh->dev; struct nip_addr *target = (struct nip_addr *)&neigh->primary_key; - struct nip_addr *saddr = NULL; struct ninet_dev *idev; /* Obtain the NewIP address from the current dev as @@ -387,22 +398,20 @@ static void nndisc_solicit(struct neighbour *neigh, struct sk_buff *skb) */ rcu_read_lock(); idev = __nin_dev_get(dev); - if (idev) { - read_lock_bh(&idev->lock); - if (!list_empty(&idev->addr_list)) { - struct ninet_ifaddr *ifp; - - list_for_each_entry(ifp, &idev->addr_list, if_list) { - saddr = &ifp->addr; - nndisc_send_ns(dev, target, - &nip_broadcast_addr_arp, - saddr); - } - } - read_unlock_bh(&idev->lock); - } else { + if (!idev) { nip_dbg("idev don't exist"); + rcu_read_unlock(); + return; } + read_lock_bh(&idev->lock); + if (!list_empty(&idev->addr_list)) { + struct ninet_ifaddr *ifp; + + list_for_each_entry(ifp, &idev->addr_list, if_list) { + __send_ns_packet(neigh->nud_state, dev, target, &ifp->addr); + } + } + read_unlock_bh(&idev->lock); rcu_read_unlock(); } -- Gitee