Commit Graph

1719 Commits

Author SHA1 Message Date
joerg b2dde09db1 Explicitly assert that the protocol out pr_ctloutput before calling it. 2007-08-14 16:03:48 +00:00
seanb 7a700a611e - Check IFF_RUNNING | IFF_UP in gre_output() correctly. 2007-08-14 13:36:50 +00:00
dyoung 3aa180f03a As a stopgap measure to avoid dependency on net/if.h, don't use
IFNAMSIZ.
2007-08-07 04:59:46 +00:00
dyoung 97ecf3fcfd Constify. bcopy -> memcpy. 2007-08-07 04:41:46 +00:00
dyoung 9ca94f6e09 Use satocsdl() instead of SDL(). 2007-08-07 04:41:15 +00:00
dyoung 846a5ed688 Use satocsdl() instead of SDL(). bcopy -> memcpy. 2007-08-07 04:39:34 +00:00
dyoung e3b7db6399 Constify. 2007-08-07 04:37:44 +00:00
dyoung 59d43281b6 Use sockaddr_dl_measure() and sockaddr_dl_init(). Erase unnecessary
cast.
2007-08-07 04:27:44 +00:00
dyoung 1cf606d23a In if_alloc_sadl(), use sockaddr_dl_init() and satocsdl(). Introduce
variable 'mask' for the netmask, and use it instead of assigning
to 'sdl' twice.

In ifa_ifwithnet(), use satocsdl().
2007-08-07 04:14:37 +00:00
dyoung 04d14f227e Lengthen sockaddr_dl so that a 16-byte FireWire address will fit
into sdl_data[].

Move the macro satocsdl() to net/if_dl.h, and introduce satosdl().

Add some helpers for initializing sockaddr_dl (sockaddr_dl_init),
for finding out the length to put in a sockaddr_dl's sdl_len member
(sockaddr_dl_measure), and for setting the link-layer address in
a sockaddr_dl to a new value (sockaddr_dl_setaddr).

Make sockaddr_copy() panic if the caller tries to copy a sockaddr
to a destination where it will not fit.
2007-08-07 04:06:20 +00:00
yamt cf51ee04a5 don't forget to maintain ama_addrs. reported by Coverity via Arnaud Lacombe. 2007-08-02 12:37:47 +00:00
yamt 5e1e651c3e agrport_mc_del_callback: s/SIOCADDMULTI/SIOCDELMULTI/ 2007-08-02 12:34:23 +00:00
dyoung edc2327d04 Cosmetic: remove superfluous parentheses. Compare pointers with
NULL instead of testing "truth."  Remove unnecessary casts to void*
in memset() calls.
2007-07-21 03:12:10 +00:00
dyoung 49412ed4f9 Use NULL instead of 0 for null pointers. 2007-07-21 02:24:11 +00:00
dyoung 08e6f22226 Take steps to hide the radix_node implementation of the forwarding table
from the forwarding table's users:

        Introduce rt_walktree() for walking the routing table and
        applying a function to each rtentry.  Replace most
        rn_walktree() calls with it.

        Use rt_getkey()/rt_setkey() to get/set a route's destination.
        Keep a pointer to the sockaddr key in the rtentry, so that
        rtentry users do not have to grovel in the radix_node for
        the key.

        Add a RTM_GET method to rtrequest.  Use that instead of
        radix_node lookups in, e.g., carp(4).

Add sys/net/link_proto.c, which supplies sockaddr routines for
link-layer socket addresses (sockaddr_dl).

Cosmetic:

        Constify.  KNF.  Stop open-coding LIST_FOREACH, TAILQ_FOREACH,
        et cetera.  Use NULL instead of 0 for null pointers.  Use
        __arraycount().  Reduce gratuitous parenthesization.

        Stop using variadic arguments for rip6_output(), it is
        unnecessary.

        Remove the unnecessary rtentry member rt_genmask and the
        code to maintain it, since nothing actually used it.

        Make rt_maskedcopy() easier to read by using meaningful variable
        names.

        Extract a subroutine intern_netmask() for looking up a netmask in
        the masks table.

        Start converting backslash-ridden IPv6 macros in
        sys/netinet6/in6_var.h into inline subroutines that one
        can read without special eyeglasses.

One functional change: when the kernel serves an RTM_GET, RTM_LOCK,
or RTM_CHANGE request, it applies the netmask (if supplied) to a
destination before searching for it in the forwarding table.

I have changed sys/netinet/ip_carp.c, carp_setroute(), to remove
the unlawful radix_node knowledge.

Apart from the changes to carp(4), netiso, ATM, and strip(4), I
have run the changes on three nodes in my wireless routing testbed,
which involves IPv4 + IPv6 dynamic routing acrobatics, and it's
working beautifully so far.
2007-07-19 20:48:52 +00:00
ad bba99c25aa Generic soft interrupts are mandatory. 2007-07-14 21:02:36 +00:00
dyoung 690f9353c0 Cosmetic: KNF. Shorten a staircase. 2007-07-12 04:28:59 +00:00
xtraeme 746fb9e8e8 Replace a simple lock with a mutex and make it static (as it's only used
on this file). Ok by ad@.
2007-07-11 21:26:53 +00:00
dyoung 911c7b0317 Cosmetic: KNF. 2007-07-11 00:53:14 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
scw 2346befecc If the underlying link's MTU is less than PP_MTU (e.g. PPPoE), set our
MRU to the link's MTU and initiate an MRU negotiation with the peer.

This is useful when the PPP session is bridged from Ethernet to ATM
by an ADSL modem (such as the Linksys AM200). Unless we negotiate the
lower MRU, the peer is unaware that 1500-byte packets will not make
it umolested across the link (the Linksys AM200 silently truncates them
to 1498 bytes, creating a nice PMTU blackhole).

Note that the PPP RFC says peers MUST accept 1500 byte packets,
regardless of the negotiated MRU, so most ISPs which use PPPoA will
probably still send 1500-byte packets. However, I persuaded my ISP
(Andrews and Arnold) to modify their software to generate an ICMP error
"fragment needed" for packets with IP.DF set which are larger than the
negotiated MRU. They will still forward non-IP.DF packets, with the
associated truncation, but at least my PMTU troubles have gone.
2007-06-23 08:45:25 +00:00
dyoung cb3da2abc3 Remove unnecessary __UNCONST(). 2007-06-13 05:08:02 +00:00
dyoung 95edb940c2 Get rid of radix_node_head.rnh_walktree, because it is only ever
set to rn_walktree.

Introduce rt_walktree(), which applies a subroutine to every route
in a particular address family.  Use it instead of rn_walktree()
virtually everywhere.  This helps to hide the routing table
implementation.
2007-06-09 03:07:21 +00:00
christos 89734304c6 - fix unused variable when none of the compat options are defined.
- remove debugging
2007-06-01 15:41:15 +00:00
enami 723ff30abc Fix some bugs in ifconf():
- maintain space left correctly.  the pointer is advanced by the size
  of struct ifreq when length of address is small.
- single sizeof operator is enough to take the size of struct.
- the type of `sz' must be singed type since it is/was compared against to
  the variable which may become negative.
- no need to traverse rest of interfaces once we got an error.  note that
  the latter `break' statement was inside inner loop.
2007-06-01 09:35:47 +00:00
christos f6ca3502bf provide the minimum ifreq size (when sockaddr is empty) 2007-05-31 02:56:50 +00:00
christos d81aadc176 Move the nasty ifdefs in one place. Requested by ad and dyoung. 2007-05-30 21:02:02 +00:00
christos 781021f65e fix unused variable. 2007-05-29 23:32:41 +00:00
xtraeme 967c5e0168 Initialize oifr to fix build with COMPAT_40. 2007-05-29 22:05:01 +00:00
christos 20bfd9898e Add a sockaddr_storage member to "struct ifreq" maintaining backwards
compatibility with the older ioctls. This avoids stack smashing and
abuse of "struct sockaddr" when ioctls placed "struct sockaddr_foo's" that
were longer than "struct sockaddr".
XXX: Some of the emulations might be broken; I tried to add code for
them but I did not test them.
2007-05-29 21:32:27 +00:00
yamt a5e5b20e90 use mutex. 2007-05-20 07:57:03 +00:00
christos 885ed2ab13 return POLLERR instead of ENXIO since we are expecting an revents mask not
an errno.
2007-05-17 18:01:57 +00:00
dyoung 752b247e01 Cosmetic: make the macro 'equal' into an inline subroutine, bcmp
-> memcmp, bcopy -> memcpy, 0 -> NULL, shorten staircases, remove
needless cast to int.
2007-05-06 06:21:26 +00:00
dyoung d9b62cfaed Switch from spl(9) to mutex(9) and condvar(9).
Fix a defect in the locking of file descriptors as we delegate a
UDP socket from userland to the kernel.  Move sc_fp out of sc_soparm.
Synchronize access to sc_fp by gre_ioctl() and the kernel thread
using a condition variable.  For simplicity's sake, make it the
kernel helper thread's responsibility to close its UDP socket.
2007-05-06 02:47:52 +00:00
dyoung 680f00f8b5 Factor rtcache_lookup2() out of rtcache_lookup1(), for re-use in
the IPv6 stack.  rtcache_lookup2() takes an int * argument that it
writes with 1 if we had a cache 'hit', 0 if there was a cache
'miss'.
2007-05-06 02:17:54 +00:00
dyoung f650cb5d03 Free the route cache after detaching the interface w/ if_detach()
instead of before, because if_detach() may cause the cache to be
reloaded.  (I already fixed this in both etherip(4) and gre(4).
Ewww, rampant code duplication.)
2007-05-06 02:15:34 +00:00
yamt 3c8e37e03e agrether_hashmbuf: feed ipv6 flowlabel to hash calculation. 2007-05-05 18:23:23 +00:00
dyoung 72f0a6dfb0 Eliminate address family-specific route caches (struct route, struct
route_in6, struct route_iso), replacing all caches with a struct
route.

The principle benefit of this change is that all of the protocol
families can benefit from route cache-invalidation, which is
necessary for correct routing.  Route-cache invalidation fixes an
ancient PR, kern/3508, at long last; it fixes various other PRs,
also.

Discussions with and ideas from Joerg Sonnenberger influenced this
work tremendously.  Of course, all design oversights and bugs are
mine.

DETAILS

1 I added to each address family a pool of sockaddrs.  I have
  introduced routines for allocating, copying, and duplicating,
  and freeing sockaddrs:

        struct sockaddr *sockaddr_alloc(sa_family_t af, int flags);
        struct sockaddr *sockaddr_copy(struct sockaddr *dst,
                                       const struct sockaddr *src);
        struct sockaddr *sockaddr_dup(const struct sockaddr *src, int flags);
        void sockaddr_free(struct sockaddr *sa);

  sockaddr_alloc() returns either a sockaddr from the pool belonging
  to the specified family, or NULL if the pool is exhausted.  The
  returned sockaddr has the right size for that family; sa_family
  and sa_len fields are initialized to the family and sockaddr
  length---e.g., sa_family = AF_INET and sa_len = sizeof(struct
  sockaddr_in).  sockaddr_free() puts the given sockaddr back into
  its family's pool.

  sockaddr_dup() and sockaddr_copy() work analogously to strdup()
  and strcpy(), respectively.  sockaddr_copy() KASSERTs that the
  family of the destination and source sockaddrs are alike.

  The 'flags' argumet for sockaddr_alloc() and sockaddr_dup() is
  passed directly to pool_get(9).

2 I added routines for initializing sockaddrs in each address
  family, sockaddr_in_init(), sockaddr_in6_init(), sockaddr_iso_init(),
  etc.  They are fairly self-explanatory.

3 structs route_in6 and route_iso are no more.  All protocol families
  use struct route.  I have changed the route cache, 'struct route',
  so that it does not contain storage space for a sockaddr.  Instead,
  struct route points to a sockaddr coming from the pool the sockaddr
  belongs to.  I added a new method to struct route, rtcache_setdst(),
  for setting the cache destination:

        int rtcache_setdst(struct route *, const struct sockaddr *);

  rtcache_setdst() returns 0 on success, or ENOMEM if no memory is
  available to create the sockaddr storage.

  It is now possible for rtcache_getdst() to return NULL if, say,
  rtcache_setdst() failed.  I check the return value for NULL
  everywhere in the kernel.

4 Each routing domain (struct domain) has a list of live route
  caches, dom_rtcache.  rtflushall(sa_family_t af) looks up the
  domain indicated by 'af', walks the domain's list of route caches
  and invalidates each one.
2007-05-02 20:40:22 +00:00
dyoung 7ff356f18d Free route cache after detaching an etherip(4) instance. 2007-04-23 05:05:03 +00:00
xtraeme df40909241 rtcache_clear is defined as static void in route.c, but it's used
in netinet/in_route.c. Move the prototype into route.h to fix
the build.
2007-04-22 13:05:21 +00:00
dyoung 3ce5c94b0e In gre_clone_destroy(), free the route cache after calling if_detach(),
because if_detach() may cause us to transmit a packet, which
ordinarily entails reloading the route cache.  This fixes a bug
where the kernel would panic later in rtflush().  Thanks Michael
Earnhart for reporting the bug.

In gre_output(), do not leak mbufs.
2007-04-14 22:41:42 +00:00
martin de3603e82a caddr_t fallout (only visible with options PPPOE_SERVER) 2007-03-31 11:00:23 +00:00
ad 9982390dd6 lwp::l_acflag is no longer used. 2007-03-29 16:51:21 +00:00
dyoung be7bb25d74 Make all debug messages use GRE_DPRINTF(). Get rid of a redundant
if_ierrors++.  Change (type *)0 to NULL.  Get rid of unnecessary
casts to void *.
2007-03-21 03:18:08 +00:00
dyoung 271d77fa58 If we do not recognize the protocol of a received packet, then
increase ifi_noproto.  If the GRE header contains routing options,
increase the input-error count, ifi_ierrors.

While I am here, make some cosmetic changes: remove unnecessary
'proto' argument from gre_input3().  Shorten some staircases.
2007-03-21 01:56:05 +00:00
dyoung cafee584b5 KNF: compare pointers with NULL instead of 0, and do not "test
truth" of either integers or pointers, so that it's clear
     what's going on.  Remove superfluous () from return statements.
     bcmp -> memcmp, bcopy -> memcpy.

Misc. cosmetic: join some lines, remove a few empty lines, remove
spaces from type casts.  Don't open-code IFNET_FOREACH().  Shorten
some staircases.
2007-03-18 20:59:38 +00:00
dyoung 912b6eb53e The departure of IPv6 interfaces does not agree with pf. The pfil
hooks that signal the interface's departure run before IPv6 sends
messages to indicate that it is leaving its multicast groups; when
pf filters the departure messages, it does not recognize the output
interface, so it complains at the departure of gre65, for example:

pf_test6: kif == NULL, if_xname gre65

I have changed if_detach() so that it calls pr_usrreq(PRU_PURGEIF)
before pfil_run_hooks(PFIL_IFNET_DETACH), instead of the other way
around.  That quiets the pf_test6: messages.
2007-03-18 20:05:52 +00:00
dyoung 72d41408ef bcopy -> memcpy, bcmp -> memcmp.
Don't open-code LIST_FOREACH().
2007-03-17 06:36:05 +00:00
ad 59d979c5f1 Pass an ipl argument to pool_init/POOL_INIT to be used when initializing
the pool's lock.
2007-03-12 18:18:22 +00:00
drochner 814e248430 don't use DVUNIT_ANY as unit number to attach pseudo devices,
use FSTATE_STAR and cf_unit=0 like normal devices.
Thanks to Arnaud Degroote for the bug report and testing.
2007-03-09 18:42:22 +00:00