netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] few NTF_ROUTER related updates
@ 2018-09-23  4:26 Roopa Prabhu
  2018-09-23  4:26 ` [PATCH net-next 1/2] neighbour: allow admin to set NTF_ROUTER Roopa Prabhu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Roopa Prabhu @ 2018-09-23  4:26 UTC (permalink / raw)
  To: davem; +Cc: netdev

From: Roopa Prabhu <roopa@cumulusnetworks.com>

This series allows setting of NTF_ROUTER by an external
entity (eg BGP E-VPN control plane). Also fixes missing
netlink notification on neigh NTF_ROUTER flag changes.

Roopa Prabhu (2):
  neighbour: allow admin to set NTF_ROUTER
  neighbour: send netlink notification if NTF_ROUTER changes

 include/net/neighbour.h | 15 +++++++++++++++
 net/core/neighbour.c    | 16 +++++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/2] neighbour: allow admin to set NTF_ROUTER
  2018-09-23  4:26 [PATCH net-next 0/2] few NTF_ROUTER related updates Roopa Prabhu
@ 2018-09-23  4:26 ` Roopa Prabhu
  2018-09-23  4:26 ` [PATCH net-next 2/2] neighbour: send netlink notification if NTF_ROUTER changes Roopa Prabhu
  2018-09-24 19:21 ` [PATCH net-next 0/2] few NTF_ROUTER related updates David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Roopa Prabhu @ 2018-09-23  4:26 UTC (permalink / raw)
  To: davem; +Cc: netdev

From: Roopa Prabhu <roopa@cumulusnetworks.com>

This patch allows admin setting of NTF_ROUTER flag
on a neighbour entry. This enables external control
plane (like bgp evpn) to manage neigh entries with
NTF_ROUTER flag.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
---
 net/core/neighbour.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index aa19d86..ca99456 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1709,7 +1709,8 @@ static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh,
 static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh,
 		     struct netlink_ext_ack *extack)
 {
-	int flags = NEIGH_UPDATE_F_ADMIN | NEIGH_UPDATE_F_OVERRIDE;
+	int flags = NEIGH_UPDATE_F_ADMIN | NEIGH_UPDATE_F_OVERRIDE |
+		NEIGH_UPDATE_F_OVERRIDE_ISROUTER;
 	struct net *net = sock_net(skb->sk);
 	struct ndmsg *ndm;
 	struct nlattr *tb[NDA_MAX+1];
@@ -1784,12 +1785,16 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh,
 		}
 
 		if (!(nlh->nlmsg_flags & NLM_F_REPLACE))
-			flags &= ~NEIGH_UPDATE_F_OVERRIDE;
+			flags &= ~(NEIGH_UPDATE_F_OVERRIDE |
+				   NEIGH_UPDATE_F_OVERRIDE_ISROUTER);
 	}
 
 	if (ndm->ndm_flags & NTF_EXT_LEARNED)
 		flags |= NEIGH_UPDATE_F_EXT_LEARNED;
 
+	if (ndm->ndm_flags & NTF_ROUTER)
+		flags |= NEIGH_UPDATE_F_ISROUTER;
+
 	if (ndm->ndm_flags & NTF_USE) {
 		neigh_event_send(neigh, NULL);
 		err = 0;
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] neighbour: send netlink notification if NTF_ROUTER changes
  2018-09-23  4:26 [PATCH net-next 0/2] few NTF_ROUTER related updates Roopa Prabhu
  2018-09-23  4:26 ` [PATCH net-next 1/2] neighbour: allow admin to set NTF_ROUTER Roopa Prabhu
@ 2018-09-23  4:26 ` Roopa Prabhu
  2018-09-24 19:21 ` [PATCH net-next 0/2] few NTF_ROUTER related updates David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Roopa Prabhu @ 2018-09-23  4:26 UTC (permalink / raw)
  To: davem; +Cc: netdev

From: Roopa Prabhu <roopa@cumulusnetworks.com>

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 <roopa@cumulusnetworks.com>
---
 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, &notify);
 	write_unlock_bh(&neigh->lock);
 
 	if (notify)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 0/2] few NTF_ROUTER related updates
  2018-09-23  4:26 [PATCH net-next 0/2] few NTF_ROUTER related updates Roopa Prabhu
  2018-09-23  4:26 ` [PATCH net-next 1/2] neighbour: allow admin to set NTF_ROUTER Roopa Prabhu
  2018-09-23  4:26 ` [PATCH net-next 2/2] neighbour: send netlink notification if NTF_ROUTER changes Roopa Prabhu
@ 2018-09-24 19:21 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-09-24 19:21 UTC (permalink / raw)
  To: roopa; +Cc: netdev

From: Roopa Prabhu <roopa@cumulusnetworks.com>
Date: Sat, 22 Sep 2018 21:26:18 -0700

> From: Roopa Prabhu <roopa@cumulusnetworks.com>
> 
> This series allows setting of NTF_ROUTER by an external
> entity (eg BGP E-VPN control plane). Also fixes missing
> netlink notification on neigh NTF_ROUTER flag changes.

Series applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-25  1:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-23  4:26 [PATCH net-next 0/2] few NTF_ROUTER related updates Roopa Prabhu
2018-09-23  4:26 ` [PATCH net-next 1/2] neighbour: allow admin to set NTF_ROUTER Roopa Prabhu
2018-09-23  4:26 ` [PATCH net-next 2/2] neighbour: send netlink notification if NTF_ROUTER changes Roopa Prabhu
2018-09-24 19:21 ` [PATCH net-next 0/2] few NTF_ROUTER related updates David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).