Skip to content

Commit 9ce33e4

Browse files
roopa-prabhudavem330
authored andcommitted
neighbour: support for NTF_EXT_LEARNED flag
This patch extends NTF_EXT_LEARNED support to the neighbour system. Example use-case: An Ethernet VPN implementation (eg in FRR routing suite) can use this flag to add dynamic reachable external neigh entires learned via control plane. The use of neigh NTF_EXT_LEARNED in this patch is consistent with its use with bridge and vxlan fdb entries. Signed-off-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0aef78a commit 9ce33e4

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

include/net/neighbour.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ static inline void *neighbour_priv(const struct neighbour *n)
246246
#define NEIGH_UPDATE_F_OVERRIDE 0x00000001
247247
#define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002
248248
#define NEIGH_UPDATE_F_OVERRIDE_ISROUTER 0x00000004
249+
#define NEIGH_UPDATE_F_EXT_LEARNED 0x20000000
249250
#define NEIGH_UPDATE_F_ISROUTER 0x40000000
250251
#define NEIGH_UPDATE_F_ADMIN 0x80000000
251252

@@ -526,5 +527,21 @@ static inline void neigh_ha_snapshot(char *dst, const struct neighbour *n,
526527
} while (read_seqretry(&n->ha_lock, seq));
527528
}
528529

529-
530+
static inline void neigh_update_ext_learned(struct neighbour *neigh, u32 flags,
531+
int *notify)
532+
{
533+
u8 ndm_flags = 0;
534+
535+
if (!(flags & NEIGH_UPDATE_F_ADMIN))
536+
return;
537+
538+
ndm_flags |= (flags & NEIGH_UPDATE_F_EXT_LEARNED) ? NTF_EXT_LEARNED : 0;
539+
if ((neigh->flags ^ ndm_flags) & NTF_EXT_LEARNED) {
540+
if (ndm_flags & NTF_EXT_LEARNED)
541+
neigh->flags |= NTF_EXT_LEARNED;
542+
else
543+
neigh->flags &= ~NTF_EXT_LEARNED;
544+
*notify = 1;
545+
}
546+
}
530547
#endif

net/core/neighbour.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,8 @@ static void neigh_periodic_work(struct work_struct *work)
820820
write_lock(&n->lock);
821821

822822
state = n->nud_state;
823-
if (state & (NUD_PERMANENT | NUD_IN_TIMER)) {
823+
if ((state & (NUD_PERMANENT | NUD_IN_TIMER)) ||
824+
(n->flags & NTF_EXT_LEARNED)) {
824825
write_unlock(&n->lock);
825826
goto next_elt;
826827
}
@@ -1136,6 +1137,8 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
11361137
if (neigh->dead)
11371138
goto out;
11381139

1140+
neigh_update_ext_learned(neigh, flags, &notify);
1141+
11391142
if (!(new & NUD_VALID)) {
11401143
neigh_del_timer(neigh);
11411144
if (old & NUD_CONNECTED)
@@ -1781,6 +1784,9 @@ static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh,
17811784
flags &= ~NEIGH_UPDATE_F_OVERRIDE;
17821785
}
17831786

1787+
if (ndm->ndm_flags & NTF_EXT_LEARNED)
1788+
flags |= NEIGH_UPDATE_F_EXT_LEARNED;
1789+
17841790
if (ndm->ndm_flags & NTF_USE) {
17851791
neigh_event_send(neigh, NULL);
17861792
err = 0;

0 commit comments

Comments
 (0)