From mboxrd@z Thu Jan 1 00:00:00 1970 From: Roopa Prabhu Subject: [PATCH net-next 2/2] neighbour: send netlink notification if NTF_ROUTER changes Date: Sat, 22 Sep 2018 21:26:20 -0700 Message-ID: <1537676780-5370-3-git-send-email-roopa@cumulusnetworks.com> References: <1537676780-5370-1-git-send-email-roopa@cumulusnetworks.com> Cc: netdev@vger.kernel.org To: davem@davemloft.net Return-path: Received: from mail-pg1-f194.google.com ([209.85.215.194]:41641 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725969AbeIWKWb (ORCPT ); Sun, 23 Sep 2018 06:22:31 -0400 Received: by mail-pg1-f194.google.com with SMTP id z3-v6so2778795pgv.8 for ; Sat, 22 Sep 2018 21:26:29 -0700 (PDT) In-Reply-To: <1537676780-5370-1-git-send-email-roopa@cumulusnetworks.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Roopa Prabhu send netlink notification if neigh_update results in NTF_ROUTER change and if NEIGH_UPDATE_F_ISROUTER is on. Also move the NTF_ROUTER change function into a helper. Signed-off-by: Roopa Prabhu --- include/net/neighbour.h | 15 +++++++++++++++ net/core/neighbour.c | 7 ++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 6c1eecd..0874f7fc 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -544,4 +544,19 @@ static inline void neigh_update_ext_learned(struct neighbour *neigh, u32 flags, *notify = 1; } } + +static inline void neigh_update_is_router(struct neighbour *neigh, u32 flags, + int *notify) +{ + u8 ndm_flags = 0; + + ndm_flags |= (flags & NEIGH_UPDATE_F_ISROUTER) ? NTF_ROUTER : 0; + if ((neigh->flags ^ ndm_flags) & NTF_ROUTER) { + if (ndm_flags & NTF_ROUTER) + neigh->flags |= NTF_ROUTER; + else + neigh->flags &= ~NTF_ROUTER; + *notify = 1; + } +} #endif diff --git a/net/core/neighbour.c b/net/core/neighbour.c index ca99456..fb89294 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -1277,11 +1277,8 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, neigh->arp_queue_len_bytes = 0; } out: - if (update_isrouter) { - neigh->flags = (flags & NEIGH_UPDATE_F_ISROUTER) ? - (neigh->flags | NTF_ROUTER) : - (neigh->flags & ~NTF_ROUTER); - } + if (update_isrouter) + neigh_update_is_router(neigh, flags, ¬ify); write_unlock_bh(&neigh->lock); if (notify) -- 2.1.4