Skip to contentSkip to conversation

few NTF_ROUTER related updates

PATCH In review Roopa Prabhu 2 participants 4 messages Sep 23, 2018 – Sep 25, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover few NTF_ROUTER related updates

From: Roopa Prabhu <[email protected]>

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(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/2 neighbour: allow admin to set NTF_ROUTER

From: Roopa Prabhu <[email protected]>

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.

---
 net/core/neighbour.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
net/core/neighbour.c +7 -2
index aa19d86..ca99456 100644
@@ -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;
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/2 neighbour: send netlink notification if NTF_ROUTER changes

In reply to Roopa Prabhu

From: Roopa Prabhu <[email protected]>

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.

---
 include/net/neighbour.h | 15 +++++++++++++++
 net/core/neighbour.c    |  7 ++-----
 2 files changed, 17 insertions(+), 5 deletions(-)
include/net/neighbour.h +15 -0
index 6c1eecd..0874f7fc 100644
@@ -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
net/core/neighbour.c +2 -5
index ca99456..fb89294 100644
@@ -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)
Signature · 1 line
2.1.4