add interface for allowing consumers to register for ARP updates,
redirects, and path MTU changes Reviewed by: silby
This commit is contained in:
parent
284333d353
commit
8e7e854cd6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174559
@ -318,7 +318,7 @@ rtredirect(struct sockaddr *dst,
|
||||
int flags,
|
||||
struct sockaddr *src)
|
||||
{
|
||||
struct rtentry *rt;
|
||||
struct rtentry *rt, *rt0 = NULL;
|
||||
int error = 0;
|
||||
short *stat = NULL;
|
||||
struct rt_addrinfo info;
|
||||
@ -362,8 +362,9 @@ rtredirect(struct sockaddr *dst,
|
||||
* Create new route, rather than smashing route to net.
|
||||
*/
|
||||
create:
|
||||
if (rt)
|
||||
rtfree(rt);
|
||||
rt0 = rt;
|
||||
rt = NULL;
|
||||
|
||||
flags |= RTF_GATEWAY | RTF_DYNAMIC;
|
||||
bzero((caddr_t)&info, sizeof(info));
|
||||
info.rti_info[RTAX_DST] = dst;
|
||||
@ -371,14 +372,19 @@ rtredirect(struct sockaddr *dst,
|
||||
info.rti_info[RTAX_NETMASK] = netmask;
|
||||
info.rti_ifa = ifa;
|
||||
info.rti_flags = flags;
|
||||
rt = NULL;
|
||||
error = rtrequest1(RTM_ADD, &info, &rt);
|
||||
if (rt != NULL) {
|
||||
RT_LOCK(rt);
|
||||
EVENTHANDLER_INVOKE(route_event, RTEVENT_REDIRECT_UPDATE, rt0, rt, dst);
|
||||
flags = rt->rt_flags;
|
||||
}
|
||||
if (rt0)
|
||||
RTFREE_LOCKED(rt0);
|
||||
|
||||
stat = &rtstat.rts_dynamic;
|
||||
} else {
|
||||
struct rtentry *gwrt;
|
||||
|
||||
/*
|
||||
* Smash the current notion of the gateway to
|
||||
* this destination. Should check about netmask!!!
|
||||
@ -390,6 +396,9 @@ rtredirect(struct sockaddr *dst,
|
||||
* add the key and gateway (in one malloc'd chunk).
|
||||
*/
|
||||
rt_setgate(rt, rt_key(rt), gateway);
|
||||
gwrt = rtalloc1(gateway, 1, 0);
|
||||
EVENTHANDLER_INVOKE(route_event, RTEVENT_REDIRECT_UPDATE, rt, gwrt, dst);
|
||||
RTFREE_LOCKED(gwrt);
|
||||
}
|
||||
} else
|
||||
error = EHOSTUNREACH;
|
||||
|
@ -359,6 +359,13 @@ int rtrequest(int, struct sockaddr *,
|
||||
struct sockaddr *, struct sockaddr *, int, struct rtentry **);
|
||||
int rtrequest1(int, struct rt_addrinfo *, struct rtentry **);
|
||||
int rt_check(struct rtentry **, struct rtentry **, struct sockaddr *);
|
||||
|
||||
#include <sys/eventhandler.h>
|
||||
#define RTEVENT_ARP_UPDATE 1
|
||||
#define RTEVENT_PMTU_UPDATE 2
|
||||
#define RTEVENT_REDIRECT_UPDATE 3
|
||||
typedef void (*rtevent_fn)(void *, int, struct rtentry *, struct rtentry *, struct sockaddr *);
|
||||
EVENTHANDLER_DECLARE(route_event, rtevent_fn);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -578,7 +578,10 @@ in_arpinput(struct mbuf *m)
|
||||
#ifdef DEV_CARP
|
||||
int carp_match = 0;
|
||||
#endif
|
||||
|
||||
struct sockaddr_in sin;
|
||||
sin.sin_len = sizeof(struct sockaddr_in);
|
||||
sin.sin_family = AF_INET;
|
||||
|
||||
if (ifp->if_bridge)
|
||||
bridged = 1;
|
||||
|
||||
@ -772,6 +775,10 @@ in_arpinput(struct mbuf *m)
|
||||
la->la_preempt = arp_maxtries;
|
||||
hold = la->la_hold;
|
||||
la->la_hold = NULL;
|
||||
|
||||
sin.sin_addr.s_addr = ntohl(itaddr.s_addr);
|
||||
EVENTHANDLER_INVOKE(route_event, RTEVENT_ARP_UPDATE, rt, NULL,
|
||||
(struct sockaddr *)&sin);
|
||||
RT_UNLOCK(rt);
|
||||
if (hold != NULL)
|
||||
(*ifp->if_output)(ifp, hold, rt_key(rt), rt);
|
||||
|
Loading…
Reference in New Issue
Block a user