Commit 8cf8821e authored by Jeff Dike's avatar Jeff Dike Committed by Jakub Kicinski

net: Exempt multicast addresses from five-second neighbor lifetime

Commit 58956317 ("neighbor: Improve garbage collection")
guarantees neighbour table entries a five-second lifetime.  Processes
which make heavy use of multicast can fill the neighour table with
multicast addresses in five seconds.  At that point, neighbour entries
can't be GC-ed because they aren't five seconds old yet, the kernel
log starts to fill up with "neighbor table overflow!" messages, and
sends start to fail.

This patch allows multicast addresses to be thrown out before they've
lived out their five seconds.  This makes room for non-multicast
addresses and makes messages to all addresses more reliable in these
circumstances.

Fixes: 58956317 ("neighbor: Improve garbage collection")
Signed-off-by: default avatarJeff Dike <jdike@akamai.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20201113015815.31397-1-jdike@akamai.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 2b566873
...@@ -204,6 +204,7 @@ struct neigh_table { ...@@ -204,6 +204,7 @@ struct neigh_table {
int (*pconstructor)(struct pneigh_entry *); int (*pconstructor)(struct pneigh_entry *);
void (*pdestructor)(struct pneigh_entry *); void (*pdestructor)(struct pneigh_entry *);
void (*proxy_redo)(struct sk_buff *skb); void (*proxy_redo)(struct sk_buff *skb);
int (*is_multicast)(const void *pkey);
bool (*allow_add)(const struct net_device *dev, bool (*allow_add)(const struct net_device *dev,
struct netlink_ext_ack *extack); struct netlink_ext_ack *extack);
char *id; char *id;
......
...@@ -235,6 +235,8 @@ static int neigh_forced_gc(struct neigh_table *tbl) ...@@ -235,6 +235,8 @@ static int neigh_forced_gc(struct neigh_table *tbl)
write_lock(&n->lock); write_lock(&n->lock);
if ((n->nud_state == NUD_FAILED) || if ((n->nud_state == NUD_FAILED) ||
(tbl->is_multicast &&
tbl->is_multicast(n->primary_key)) ||
time_after(tref, n->updated)) time_after(tref, n->updated))
remove = true; remove = true;
write_unlock(&n->lock); write_unlock(&n->lock);
......
...@@ -125,6 +125,7 @@ static int arp_constructor(struct neighbour *neigh); ...@@ -125,6 +125,7 @@ static int arp_constructor(struct neighbour *neigh);
static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb); static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb);
static void arp_error_report(struct neighbour *neigh, struct sk_buff *skb); static void arp_error_report(struct neighbour *neigh, struct sk_buff *skb);
static void parp_redo(struct sk_buff *skb); static void parp_redo(struct sk_buff *skb);
static int arp_is_multicast(const void *pkey);
static const struct neigh_ops arp_generic_ops = { static const struct neigh_ops arp_generic_ops = {
.family = AF_INET, .family = AF_INET,
...@@ -156,6 +157,7 @@ struct neigh_table arp_tbl = { ...@@ -156,6 +157,7 @@ struct neigh_table arp_tbl = {
.key_eq = arp_key_eq, .key_eq = arp_key_eq,
.constructor = arp_constructor, .constructor = arp_constructor,
.proxy_redo = parp_redo, .proxy_redo = parp_redo,
.is_multicast = arp_is_multicast,
.id = "arp_cache", .id = "arp_cache",
.parms = { .parms = {
.tbl = &arp_tbl, .tbl = &arp_tbl,
...@@ -928,6 +930,10 @@ static void parp_redo(struct sk_buff *skb) ...@@ -928,6 +930,10 @@ static void parp_redo(struct sk_buff *skb)
arp_process(dev_net(skb->dev), NULL, skb); arp_process(dev_net(skb->dev), NULL, skb);
} }
static int arp_is_multicast(const void *pkey)
{
return ipv4_is_multicast(*((__be32 *)pkey));
}
/* /*
* Receive an arp request from the device layer. * Receive an arp request from the device layer.
......
...@@ -81,6 +81,7 @@ static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb); ...@@ -81,6 +81,7 @@ static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb);
static int pndisc_constructor(struct pneigh_entry *n); static int pndisc_constructor(struct pneigh_entry *n);
static void pndisc_destructor(struct pneigh_entry *n); static void pndisc_destructor(struct pneigh_entry *n);
static void pndisc_redo(struct sk_buff *skb); static void pndisc_redo(struct sk_buff *skb);
static int ndisc_is_multicast(const void *pkey);
static const struct neigh_ops ndisc_generic_ops = { static const struct neigh_ops ndisc_generic_ops = {
.family = AF_INET6, .family = AF_INET6,
...@@ -115,6 +116,7 @@ struct neigh_table nd_tbl = { ...@@ -115,6 +116,7 @@ struct neigh_table nd_tbl = {
.pconstructor = pndisc_constructor, .pconstructor = pndisc_constructor,
.pdestructor = pndisc_destructor, .pdestructor = pndisc_destructor,
.proxy_redo = pndisc_redo, .proxy_redo = pndisc_redo,
.is_multicast = ndisc_is_multicast,
.allow_add = ndisc_allow_add, .allow_add = ndisc_allow_add,
.id = "ndisc_cache", .id = "ndisc_cache",
.parms = { .parms = {
...@@ -1706,6 +1708,11 @@ static void pndisc_redo(struct sk_buff *skb) ...@@ -1706,6 +1708,11 @@ static void pndisc_redo(struct sk_buff *skb)
kfree_skb(skb); kfree_skb(skb);
} }
static int ndisc_is_multicast(const void *pkey)
{
return ipv6_addr_is_multicast((struct in6_addr *)pkey);
}
static bool ndisc_suppress_frag_ndisc(struct sk_buff *skb) static bool ndisc_suppress_frag_ndisc(struct sk_buff *skb)
{ {
struct inet6_dev *idev = __in6_dev_get(skb->dev); struct inet6_dev *idev = __in6_dev_get(skb->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment