Commit Graph

1648 Commits

Author SHA1 Message Date
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
is 07e04d08c3 Remove an overlapping struct copy from ether_input, which caused address
corruption for incoming netiso packets with recent (at least NetBSD-3 and
later) compilers. This is done in a way that the copy is avoided totally.
Code path tested with tcp+udp/ipv4+ipv6, arp and ISO cltp/clnp.
Visually ok'd by Christos@.
2006-12-01 18:43:40 +00:00
wiz fa34b615d2 Correct spelling of "immediate(ly)". From Zafer. 2006-11-24 21:23:07 +00:00
rpaulo bc3d08297a The change I committed to etherip was wrong. ether_snprintf doesn't make
sense when chaning the MAC address of the virtual interface as pointed
out by Hans himself.
So, introduce ether_nonstatic_aton() and make etherip(4) and tap(4) use it.
2006-11-24 01:04:30 +00:00
yamt 809ec70bcf implement ipv6 TSO.
partly from Matthias Scheler.  tested by him.
2006-11-23 19:41:58 +00:00
rpaulo 74b7608af9 Remove extra prototype. 2006-11-23 04:20:54 +00:00
rpaulo 5423539f94 New EtherIP driver based on tap(4) and gif(4) by Hans Rosenfeld.
Notable changes:
	* Fixes PR 34268.
	* Separates the code from gif(4) (which is more cleaner).
	* Allows the usage of STP (Spanning Tree Protocol).
	* Removed EtherIP implementation from gif(4)/tap(4).

Some input from Christos.
2006-11-23 04:07:07 +00:00
dyoung 43778cd2ec "Reform" TAILQ usage:
Obey the TAILQ abstraction while removing ifaddrs from an interface
in if_detach; just restart the loop after removing one or more
ifaddrs from the interface.

Convert a bunch of for (ifa = TAILQ_FIRST(); ifa; ifa = TAILQ_NEXT())
loops to TAILQ_FOREACH().

Remove some superfluous parentheses while I am here.
2006-11-20 04:09:25 +00:00
dyoung 33f672908d Correct the length of the TTL argument to setsockopt(IPPROTO_IP,
IP_TTL).
2006-11-16 22:58:00 +00:00
dyoung 51a6c2e769 Cosmetic: s/g_proto/sc_proto/.
(Straggler from last commit affecting net/if_gre.c, netinet/ip_gre.c.)
2006-11-16 22:32:38 +00:00
dyoung 641edc65f1 Cosmetic: s/g_proto/sc_proto/. Remove superfluous parentheses and
curly braces.
2006-11-16 22:26:35 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
dyoung 2ed50f892c make the routing socket report the right source address in RTM_GET
responses when a source-address selection policy is in use.
2006-11-13 19:16:01 +00:00
dyoung 00aa0b8d95 Fix bugs in rt_get_ifa() and put aside the sequence number stuff,
which isn't ready for primetime yet.
2006-11-13 19:14:30 +00:00