Commit 8d71740c authored by Tom Tucker's avatar Tom Tucker Committed by David S. Miller

[NET]: Core net changes to generate netevents

Generate netevents for:
- neighbour changes
- routing redirects
- pmtu changes
Signed-off-by: default avatarTom Tucker <tom@opengridcomputing.com>
Signed-off-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 792d1932
...@@ -7,7 +7,7 @@ obj-y := sock.o request_sock.o skbuff.o iovec.o datagram.o stream.o scm.o \ ...@@ -7,7 +7,7 @@ obj-y := sock.o request_sock.o skbuff.o iovec.o datagram.o stream.o scm.o \
obj-$(CONFIG_SYSCTL) += sysctl_net_core.o obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
obj-y += dev.o ethtool.o dev_mcast.o dst.o \ obj-y += dev.o ethtool.o dev_mcast.o dst.o netevent.o \
neighbour.o rtnetlink.o utils.o link_watch.o filter.o neighbour.o rtnetlink.o utils.o link_watch.o filter.o
obj-$(CONFIG_XFRM) += flow.o obj-$(CONFIG_XFRM) += flow.o
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <net/neighbour.h> #include <net/neighbour.h>
#include <net/dst.h> #include <net/dst.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/netevent.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/string.h> #include <linux/string.h>
...@@ -754,6 +755,7 @@ static void neigh_timer_handler(unsigned long arg) ...@@ -754,6 +755,7 @@ static void neigh_timer_handler(unsigned long arg)
neigh->nud_state = NUD_STALE; neigh->nud_state = NUD_STALE;
neigh->updated = jiffies; neigh->updated = jiffies;
neigh_suspect(neigh); neigh_suspect(neigh);
notify = 1;
} }
} else if (state & NUD_DELAY) { } else if (state & NUD_DELAY) {
if (time_before_eq(now, if (time_before_eq(now,
...@@ -762,6 +764,7 @@ static void neigh_timer_handler(unsigned long arg) ...@@ -762,6 +764,7 @@ static void neigh_timer_handler(unsigned long arg)
neigh->nud_state = NUD_REACHABLE; neigh->nud_state = NUD_REACHABLE;
neigh->updated = jiffies; neigh->updated = jiffies;
neigh_connect(neigh); neigh_connect(neigh);
notify = 1;
next = neigh->confirmed + neigh->parms->reachable_time; next = neigh->confirmed + neigh->parms->reachable_time;
} else { } else {
NEIGH_PRINTK2("neigh %p is probed.\n", neigh); NEIGH_PRINTK2("neigh %p is probed.\n", neigh);
...@@ -819,6 +822,8 @@ static void neigh_timer_handler(unsigned long arg) ...@@ -819,6 +822,8 @@ static void neigh_timer_handler(unsigned long arg)
out: out:
write_unlock(&neigh->lock); write_unlock(&neigh->lock);
} }
if (notify)
call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
#ifdef CONFIG_ARPD #ifdef CONFIG_ARPD
if (notify && neigh->parms->app_probes) if (notify && neigh->parms->app_probes)
...@@ -926,9 +931,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, ...@@ -926,9 +931,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
{ {
u8 old; u8 old;
int err; int err;
#ifdef CONFIG_ARPD
int notify = 0; int notify = 0;
#endif
struct net_device *dev; struct net_device *dev;
int update_isrouter = 0; int update_isrouter = 0;
...@@ -948,9 +951,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, ...@@ -948,9 +951,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
neigh_suspect(neigh); neigh_suspect(neigh);
neigh->nud_state = new; neigh->nud_state = new;
err = 0; err = 0;
#ifdef CONFIG_ARPD
notify = old & NUD_VALID; notify = old & NUD_VALID;
#endif
goto out; goto out;
} }
...@@ -1022,9 +1023,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, ...@@ -1022,9 +1023,7 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
if (!(new & NUD_CONNECTED)) if (!(new & NUD_CONNECTED))
neigh->confirmed = jiffies - neigh->confirmed = jiffies -
(neigh->parms->base_reachable_time << 1); (neigh->parms->base_reachable_time << 1);
#ifdef CONFIG_ARPD
notify = 1; notify = 1;
#endif
} }
if (new == old) if (new == old)
goto out; goto out;
...@@ -1056,6 +1055,9 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, ...@@ -1056,6 +1055,9 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
(neigh->flags & ~NTF_ROUTER); (neigh->flags & ~NTF_ROUTER);
} }
write_unlock_bh(&neigh->lock); write_unlock_bh(&neigh->lock);
if (notify)
call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, neigh);
#ifdef CONFIG_ARPD #ifdef CONFIG_ARPD
if (notify && neigh->parms->app_probes) if (notify && neigh->parms->app_probes)
neigh_app_notify(neigh); neigh_app_notify(neigh);
......
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
#include <net/icmp.h> #include <net/icmp.h>
#include <net/xfrm.h> #include <net/xfrm.h>
#include <net/ip_mp_alg.h> #include <net/ip_mp_alg.h>
#include <net/netevent.h>
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
#include <linux/sysctl.h> #include <linux/sysctl.h>
#endif #endif
...@@ -1125,6 +1126,7 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw, ...@@ -1125,6 +1126,7 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
struct rtable *rth, **rthp; struct rtable *rth, **rthp;
u32 skeys[2] = { saddr, 0 }; u32 skeys[2] = { saddr, 0 };
int ikeys[2] = { dev->ifindex, 0 }; int ikeys[2] = { dev->ifindex, 0 };
struct netevent_redirect netevent;
if (!in_dev) if (!in_dev)
return; return;
...@@ -1217,6 +1219,11 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw, ...@@ -1217,6 +1219,11 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
goto do_next; goto do_next;
} }
netevent.old = &rth->u.dst;
netevent.new = &rt->u.dst;
call_netevent_notifiers(NETEVENT_REDIRECT,
&netevent);
rt_del(hash, rth); rt_del(hash, rth);
if (!rt_intern_hash(hash, rt, &rt)) if (!rt_intern_hash(hash, rt, &rt))
ip_rt_put(rt); ip_rt_put(rt);
...@@ -1452,6 +1459,7 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) ...@@ -1452,6 +1459,7 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
} }
dst->metrics[RTAX_MTU-1] = mtu; dst->metrics[RTAX_MTU-1] = mtu;
dst_set_expires(dst, ip_rt_mtu_expires); dst_set_expires(dst, ip_rt_mtu_expires);
call_netevent_notifiers(NETEVENT_PMTU_UPDATE, dst);
} }
} }
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <net/dst.h> #include <net/dst.h>
#include <net/xfrm.h> #include <net/xfrm.h>
#include <net/netevent.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -742,6 +743,7 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu) ...@@ -742,6 +743,7 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
dst->metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; dst->metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG;
} }
dst->metrics[RTAX_MTU-1] = mtu; dst->metrics[RTAX_MTU-1] = mtu;
call_netevent_notifiers(NETEVENT_PMTU_UPDATE, dst);
} }
} }
...@@ -1155,6 +1157,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *saddr, ...@@ -1155,6 +1157,7 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *saddr,
struct rt6_info *rt, *nrt = NULL; struct rt6_info *rt, *nrt = NULL;
int strict; int strict;
struct fib6_node *fn; struct fib6_node *fn;
struct netevent_redirect netevent;
/* /*
* Get the "current" route for this destination and * Get the "current" route for this destination and
...@@ -1252,6 +1255,10 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *saddr, ...@@ -1252,6 +1255,10 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *saddr,
if (ip6_ins_rt(nrt, NULL, NULL, NULL)) if (ip6_ins_rt(nrt, NULL, NULL, NULL))
goto out; goto out;
netevent.old = &rt->u.dst;
netevent.new = &nrt->u.dst;
call_netevent_notifiers(NETEVENT_REDIRECT, &netevent);
if (rt->rt6i_flags&RTF_CACHE) { if (rt->rt6i_flags&RTF_CACHE) {
ip6_del_rt(rt, NULL, NULL, NULL); ip6_del_rt(rt, NULL, NULL, NULL);
return; return;
......
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