PERFORCE change 130667 for review
Kip Macy
kmacy at FreeBSD.org
Tue Dec 11 21:00:33 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=130667
Change 130667 by kmacy at kmacy:storage:toehead on 2007/12/12 05:00:16
add interface for allowing consumers to register for ARP updates,
redirects, and path MTU changes
Affected files ...
.. //depot/projects/toehead/sys/net/route.c#2 edit
.. //depot/projects/toehead/sys/net/route.h#2 edit
.. //depot/projects/toehead/sys/netinet/if_ether.c#2 edit
Differences ...
==== //depot/projects/toehead/sys/net/route.c#2 (text+ko) ====
@@ -318,7 +318,7 @@
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,8 @@
* Create new route, rather than smashing route to net.
*/
create:
- if (rt)
- rtfree(rt);
+ rt0 = rt;
+
flags |= RTF_GATEWAY | RTF_DYNAMIC;
bzero((caddr_t)&info, sizeof(info));
info.rti_info[RTAX_DST] = dst;
@@ -375,10 +375,16 @@
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 @@
* 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;
==== //depot/projects/toehead/sys/net/route.h#2 (text+ko) ====
@@ -359,6 +359,13 @@
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
==== //depot/projects/toehead/sys/netinet/if_ether.c#2 (text+ko) ====
@@ -578,7 +578,10 @@
#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 @@
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);
More information about the p4-projects
mailing list