Commit Graph

1661 Commits

Author SHA1 Message Date
thorpej 7cc07e11dc TRUE -> true, FALSE -> false 2007-02-22 06:16:03 +00:00
thorpej 712239e366 Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 22:59:35 +00:00
dyoung 58cb526fa7 Use __arraycount(). 2007-02-21 02:24:14 +00:00
dyoung af8be3e751 Remove extraneous parentheses. bcopy -> memcpy. 2007-02-20 08:55:54 +00:00
dyoung 818fe8ed7b Remove unused #define SIN.
Constify.
2007-02-20 08:32:14 +00:00
dyoung b700519db9 Remove unused #define SIN(). From he@. 2007-02-19 21:18:23 +00:00
dyoung ba2aee81a0 Fix fallout from if_output constification. Thanks, Havard Eidnes,
for reporting the problem and testing my patch.
2007-02-19 21:17:03 +00:00
matt 58aa85753d Initialize routeswitch with structure initializers. 2007-02-18 22:46:32 +00:00
dyoung 3365b046ad Use satocsin to cast to const struct sockaddr_in *. 2007-02-18 07:17:48 +00:00
dogcow 27a0c93811 constify struct sockaddr. 2007-02-18 06:20:10 +00:00
dyoung 5493f188c7 KNF: de-__P, bzero -> memset, bcmp -> memcmp. Remove extraneous
parentheses in return statements.

Cosmetic: don't open-code TAILQ_FOREACH().

Cosmetic: change types of variables to avoid oodles of casts: in
   in6_src.c, avoid casts by changing several route_in6 pointers
   to struct route pointers.  Remove unnecessary casts to caddr_t
   elsewhere.

Pave the way for eliminating address family-specific route caches:
   soon, struct route will not embed a sockaddr, but it will hold
   a reference to an external sockaddr, instead.  We will set the
   destination sockaddr using rtcache_setdst().  (I created a stub
   for it, but it isn't used anywhere, yet.)  rtcache_free() will
   free the sockaddr.  I have extracted from rtcache_free() a helper
   subroutine, rtcache_clear().  rtcache_clear() will "forget" a
   cached route, but it will not forget the destination by releasing
   the sockaddr.  I use rtcache_clear() instead of rtcache_free()
   in rtcache_update(), because rtcache_update() is not supposed
   to forget the destination.

Constify:

   1 Introduce const accessor for route->ro_dst, rtcache_getdst().

   2 Constify the 'dst' argument to ifnet->if_output().  This
     led me to constify a lot of code called by output routines.

   3 Constify the sockaddr argument to protosw->pr_ctlinput.  This
     led me to constify a lot of code called by ctlinput routines.

   4 Introduce const macros for converting from a generic sockaddr
     to family-specific sockaddrs, e.g., sockaddr_in: satocsin6,
     satocsin, et cetera.
2007-02-17 22:34:07 +00:00
dyoung 3267be0b29 Cosmetic: don't open-code LIST_FOREACH(). Remove extraneous
parentheses.  Bzero -> memset.  Shorten staircase in rt_timer_add().
2007-02-17 07:50:49 +00:00
dyoung 7cfeb3c2ed Clean this code up some.
Extract subroutine rn_delete1() to ease RADIX_MPATH integration,
should we ever do that.

Remove RN_DEBUG code that does not compile.

Join some lines of the type

        type var1;
        type var2;
        type var3;

making

        type var1, var2, var3.

Break lines of the type if (expr) stmt1; else stmt2; so that normal
people can read them.
2007-02-17 07:46:38 +00:00
bouyer 53bfe8e81c Drop M_PROMISC before passing the packet to a carp device, for the same
reason it's dropped before passing to bridge: when a vlan interface is
in promisc mode, it will loop the packet back to ether_input() with
M_PROMISC set, and when carp calls ether_input again the flag is still
there and the packet is dropped. If the carp interface doesn't take
the packet M_PROMISC is set just after is needed anyway.
Tested on a box with multiple carp on vlans, no comments about this patch
on tech-net@
2007-01-29 22:13:14 +00:00
cbiere bcfa6c3c08 Use be16dec() and be32dec() instead of reimplementing them. 2007-01-27 07:16:01 +00:00
cbiere 6b77c2af74 Use a plain memcpy() instead of alignment- and endian-specific hacks. 2007-01-27 07:12:16 +00:00
dyoung 2115f7da2f Fix the check for a routing loop. 2007-01-26 19:32:32 +00:00
dyoung 832c31b2c6 Mark some shared variables as volatile. 2007-01-26 03:01:32 +00:00
isaki 7525ed1e40 Install <net/if_pflog.h>. 2007-01-13 14:13:53 +00:00
mouse 8fb29141e0 Hook srt into the rest of the kernel build machinery, so it works to
just uncomment the pseudo-device line (which arguably should go into
other ports' GENERICs too, and at some point may).

OKed by perry.
2007-01-11 05:36:29 +00:00
bouyer 9403f4d239 Don't define dropanyway: label unless ISO or NETATALK is defined. Fix
kern/35364 by Gene ENonymous
2007-01-06 20:38:14 +00:00
joerg 8632294e2e Add a debug option for the route cache to help tracing down issues
like PR 35272 and 35318. When the kernel is compiled with
-DRTCACHE_DEBUG, all rtcache entries are logged to a list with the place
they got initialised. This allows overwrites, double inits and other
manual messing to be detected.
2007-01-05 16:40:08 +00:00
mouse 9707fdff94 Add workarounds for include-file bugs exposed by this file. (Ideal, of
course, would be to fix the include-file bugs; that may follow later.)
2007-01-05 06:32:48 +00:00
elad b2eb9a5389 Consistent usage of KAUTH_GENERIC_ISSUSER. 2007-01-04 19:07:03 +00:00
wiz 0b5301abc7 Add RCS Id. 2006-12-29 10:39:59 +00:00
mouse ebc746c114 Very first import of the source-address-based routing pseudo-device,
before any cleanup at all, per discussion with perry@.
2006-12-29 04:20:14 +00:00
joerg eb04733c4e Introduce new helper functions to abstract the route caching.
rtcache_init and rtcache_init_noclone lookup ro_dst and store
the result in ro_rt, taking care of the reference counting and
calling the domain specific route cache.
rtcache_free checks if a route was cashed and frees the reference.
rtcache_copy copies ro_dst of the given struct route, checking that
enough space is available and incrementing the reference count of the
cached rtentry if necessary.
rtcache_check validates that the cached route is still up. If it isn't,
it tries to look it up again. Afterwards ro_rt is either a valid again
or NULL.
rtcache_copy is used internally.

Adjust to callers of rtalloc/rtflush in the tree to check the sanity of
ro_dst first (if necessary). If it doesn't fit the expectations, free
the cache, otherwise check if the cached route is still valid. After
that combination, a single check for ro_rt == NULL is enough to decide
whether a new lookup needs to be done with a different ro_dst.
Make the route checking in gre stricter by repeating the loop check
after revalidation.
Remove some unused RADIX_MPATH code in in6_src.c. The logic is slightly
changed here to first validate the route and check RTF_GATEWAY
afterwards. This is sementically equivalent though.
etherip doesn't need sc_route_expire similiar to the gif changes from
dyoung@ earlier.

Based on the earlier patch from dyoung@, reviewed and discussed with
him.
2006-12-15 21:18:52 +00:00
christos 5abf774808 initialize error, cause gcc3 says so. 2006-12-10 23:12:37 +00:00
is dc12fff4c3 Explain XID magic constants, correcting the format ID 2006-12-10 14:52:29 +00:00
is 8812d0414b oops, forgot lan_hdr_len length offset 2006-12-10 14:49:43 +00:00
is e80820a117 oops, forgot the m_adj 2006-12-10 14:47:40 +00:00
is 9c9b34873f was wrong magic constant. no functional change. 2006-12-10 14:45:09 +00:00
is d227658f6b Avoid overlapping struct assignment, like in the Ethernet and FDDI cases. 2006-12-10 14:39:03 +00:00
is 60ee96c865 Explain llc XID magic constants, correcting the XID header format tag. 2006-12-10 14:21:32 +00:00
is 74a405e314 Avoid overlapping struct assignment for FDDI. Should fix netiso like in the
Ethernet case.
2006-12-10 12:34:42 +00:00
is 287d53b453 explain XID constants, and fix a wrong one 2006-12-10 11:39:43 +00:00
is 1f15d00952 define some more magic LLC constants 2006-12-10 11:35:36 +00:00
is 29b0f75d10 comment on llc class 2006-12-10 10:51:11 +00:00
dyoung cf7bb443ac Straggler from last: convert to rtflush(). 2006-12-09 06:32:58 +00:00
dyoung c308b1c661 Here are various changes designed to protect against bad IPv4
routing caused by stale route caches (struct route).  Route caches
are sprinkled throughout PCBs, the IP fast-forwarding table, and
IP tunnel interfaces (gre, gif, stf).

Stale IPv6 and ISO route caches will be treated by separate patches.

Thank you to Christoph Badura for suggesting the general approach
to invalidating route caches that I take here.

Here are the details:

Add hooks to struct domain for tracking and for invalidating each
domain's route caches: dom_rtcache, dom_rtflush, and dom_rtflushall.

Introduce helper subroutines, rtflush(ro) for invalidating a route
cache, rtflushall(family) for invalidating all route caches in a
routing domain, and rtcache(ro) for notifying the domain of a new
cached route.

Chain together all IPv4 route caches where ro_rt != NULL.  Provide
in_rtcache() for adding a route to the chain.  Provide in_rtflush()
and in_rtflushall() for invalidating IPv4 route caches.  In
in_rtflush(), set ro_rt to NULL, and remove the route from the
chain.  In in_rtflushall(), walk the chain and remove every route
cache.

In rtrequest1(), call rtflushall() to invalidate route caches when
a route is added.

In gif(4), discard the workaround for stale caches that involves
expiring them every so often.

Replace the pattern 'RTFREE(ro->ro_rt); ro->ro_rt = NULL;' with a
call to rtflush(ro).

Update ipflow_fastforward() and all other users of route caches so
that they expect a cached route, ro->ro_rt, to turn to NULL.

Take care when moving a 'struct route' to rtflush() the source and
to rtcache() the destination.

In domain initializers, use .dom_xxx tags.

KNF here and there.
2006-12-09 05:33:04 +00:00
joerg b49bdf49d7 Deinline rt_get_ifa. Keep it in route.c as it is part of the routing
API, even though rtsock.c is the only user right now.
2006-12-07 19:37:08 +00:00
joerg d87b42b41f Deinline rt_replace_ifa and move rt_set_ifa and rt_set_ifa1 to
route.c as they are not used outside that file.
2006-12-07 19:20:14 +00:00
dyoung 627864e36f Per discussion on tech-net@, discard the address-munging hack that
let one create a tunnel with equal inner and outer destination IP
numbers.  Update gre(4) documentation for this change.

Extract subroutine  gre_update_route() from gre_compute_route(),
and always call it in gre_output() to freshen the route for
tunnel-encapsulated packets.
2006-12-04 02:40:15 +00:00
dyoung 31730224f4 In gre_clone_destroy,
1 use splnet() to synchronize gre clone destruction with interrupts,
  and
2 wait to call if_detach() until after joining the gre kernel
  thread.
2006-12-04 01:49:47 +00:00
dyoung e45f67b8b4 Extract subroutines rn_walkfirst() and rn_walknext() from rn_walktree().
No functional change intended.

Add some new diagnostic code, bracketed by #ifdef RN_DEBUG, that
uses the two new subroutines to walk and print a tree.

XXX The format of the diagnostic print-outs needs improvement.
2006-12-04 01:45:50 +00:00
dyoung 7e5a475027 Replace the temporary variable ndst with rt_key(rt). This will
simplify the application of RADIX_MPATH patches.

No functional change intended.
2006-12-04 00:56:44 +00:00
dyoung 8a5a3d2d66 Paranoid protection against use after free: in rtfree(), set rt_ifa
and rt_ifp to NULL.
2006-12-04 00:52:47 +00:00
dyoung b0520122af Cosmetic: remove extra empty line. 2006-12-04 00:48:59 +00:00
dyoung 626b8f05e2 Fix spelling, s/straglers/stragglers/. 2006-12-03 19:17:41 +00:00
dyoung 7b85ed030b In if_rt_walktree(), make absolutely certain not to leave a dangling
pointer, rt_ifp, from an rtentry to an interface that we are going
to destroy.
2006-12-02 20:48:13 +00:00