Commit d961db35 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[NEIGH]: Netlink notifications

Currently neighbour event notifications are limited to update
notifications and only sent if the ARP daemon is enabled. This
patch extends the existing notification code by also reporting
neighbours being removed due to gc or administratively and
removes the dependency on the ARP daemon. This allows to keep
track of neighbour states without periodically fetching the
complete neighbour table.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4f494554
...@@ -55,9 +55,8 @@ ...@@ -55,9 +55,8 @@
#define PNEIGH_HASHMASK 0xF #define PNEIGH_HASHMASK 0xF
static void neigh_timer_handler(unsigned long arg); static void neigh_timer_handler(unsigned long arg);
#ifdef CONFIG_ARPD static void __neigh_notify(struct neighbour *n, int type, int flags);
static void neigh_app_notify(struct neighbour *n); static void neigh_update_notify(struct neighbour *neigh);
#endif
static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev); static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev);
void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev); void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev);
...@@ -110,6 +109,7 @@ static void neigh_cleanup_and_release(struct neighbour *neigh) ...@@ -110,6 +109,7 @@ static void neigh_cleanup_and_release(struct neighbour *neigh)
if (neigh->parms->neigh_cleanup) if (neigh->parms->neigh_cleanup)
neigh->parms->neigh_cleanup(neigh); neigh->parms->neigh_cleanup(neigh);
__neigh_notify(neigh, RTM_DELNEIGH, 0);
neigh_release(neigh); neigh_release(neigh);
} }
...@@ -830,13 +830,10 @@ static void neigh_timer_handler(unsigned long arg) ...@@ -830,13 +830,10 @@ static void neigh_timer_handler(unsigned long arg)
out: out:
write_unlock(&neigh->lock); write_unlock(&neigh->lock);
} }
if (notify) if (notify)
call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh); neigh_update_notify(neigh);
#ifdef CONFIG_ARPD
if (notify && neigh->parms->app_probes)
neigh_app_notify(neigh);
#endif
neigh_release(neigh); neigh_release(neigh);
} }
...@@ -1065,11 +1062,8 @@ out: ...@@ -1065,11 +1062,8 @@ out:
write_unlock_bh(&neigh->lock); write_unlock_bh(&neigh->lock);
if (notify) if (notify)
call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh); neigh_update_notify(neigh);
#ifdef CONFIG_ARPD
if (notify && neigh->parms->app_probes)
neigh_app_notify(neigh);
#endif
return err; return err;
} }
...@@ -2002,6 +1996,11 @@ nla_put_failure: ...@@ -2002,6 +1996,11 @@ nla_put_failure:
return -EMSGSIZE; return -EMSGSIZE;
} }
static void neigh_update_notify(struct neighbour *neigh)
{
call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
__neigh_notify(neigh, RTM_NEWNEIGH, 0);
}
static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
struct netlink_callback *cb) struct netlink_callback *cb)
...@@ -2421,7 +2420,6 @@ static const struct file_operations neigh_stat_seq_fops = { ...@@ -2421,7 +2420,6 @@ static const struct file_operations neigh_stat_seq_fops = {
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
#ifdef CONFIG_ARPD
static inline size_t neigh_nlmsg_size(void) static inline size_t neigh_nlmsg_size(void)
{ {
return NLMSG_ALIGN(sizeof(struct ndmsg)) return NLMSG_ALIGN(sizeof(struct ndmsg))
...@@ -2453,16 +2451,11 @@ errout: ...@@ -2453,16 +2451,11 @@ errout:
rtnl_set_sk_err(RTNLGRP_NEIGH, err); rtnl_set_sk_err(RTNLGRP_NEIGH, err);
} }
#ifdef CONFIG_ARPD
void neigh_app_ns(struct neighbour *n) void neigh_app_ns(struct neighbour *n)
{ {
__neigh_notify(n, RTM_GETNEIGH, NLM_F_REQUEST); __neigh_notify(n, RTM_GETNEIGH, NLM_F_REQUEST);
} }
static void neigh_app_notify(struct neighbour *n)
{
__neigh_notify(n, RTM_NEWNEIGH, 0);
}
#endif /* CONFIG_ARPD */ #endif /* CONFIG_ARPD */
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
......
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