Commit Graph

1744 Commits

Author SHA1 Message Date
dyoung 7cf94b5474 Rename gre_socreate1() -> gre_socreate(). 2007-09-08 04:34:02 +00:00
dyoung 88399b6877 We cannot sleep in a software interrupt, so do not sockaddr_dl_alloc(...,
M_WAITOK).  Instead, sockaddr_dl_init() a sockaddr_dl on the stack.
2007-09-02 19:42:21 +00:00
dyoung da055795a8 Delete unused variable. 2007-09-02 07:03:22 +00:00
dyoung c87aad4f08 Simplify code, add debug statements, and fix a bug that could
soclose() a UDP socket that a struct file still pointed at.
2007-09-02 07:01:41 +00:00
dyoung 76b1df3703 Get rid of struct oifreq/ifreq compat code, because ifioctl() has
taken care of this for us.
2007-09-02 01:50:58 +00:00
dyoung 0af5ef16d6 Be consistent: use the prefix sc_ for all members of the gre_softc. 2007-09-02 01:49:49 +00:00
dyoung 36a3794513 Protect userland from ifreq_getaddr() w/ #ifdef _KERNEL. 2007-09-02 00:24:18 +00:00
dyoung 064ec1416f token_addmulti and token_delmulti are never used in the kernel, so
delete them.
2007-09-01 07:41:22 +00:00
dyoung c66d2e7604 fddi_addmulti and fddi_delmulti are never used in the kernel, so
delete them.
2007-09-01 07:40:53 +00:00
dyoung 9bee2cd7f1 Fix compilation if !defined(INET6). Thanks, Geoff Wing, for the
bug report & patch.
2007-09-01 07:03:32 +00:00
dyoung 2fc102750d Use ifreq_setaddr(), ifreq_getaddr(), sockaddr_in_init(), and
sockaddr_copy().  Constify.  Compare pointers with NULL, not 0.
Don't "test truth" of pointers, but compare with NULL.
2007-09-01 04:32:50 +00:00
dyoung aade2db1a7 Use ifreq_getaddr(). Pass a sockaddr instead of ifreq where sockaddr
will suffice.
2007-09-01 03:07:24 +00:00
dyoung 7e6b3f4292 Per discussion in 30 May 2007 on tech-net, add accessors for
ifreq->ifr_addr, ifreq_getaddr() and ifreq_setaddr().
2007-08-31 21:02:15 +00:00
dyoung e44b703953 Move sc_fp & sc_newfp from struct gre_softc to struct gre_soparm. 2007-08-30 05:54:07 +00:00
dyoung 7ac92eed2a Remove out-of-date debug message and comment. 2007-08-30 05:14:32 +00:00
dyoung f562a76244 Cosmetic: remove an out-of-place comma in a comment. 2007-08-30 05:01:30 +00:00
dyoung 17038010cb Do not hold the mutex as much in gre_thread1(). Move initial mutex
acquisition and final release out into gre_thread().  This will
fix a locking bug that LOCKDEBUG exposed: holding a spinlock over
an sosend() call is a no-no.

Cosmetic: join some lines, remove some unnecessary curly braces.
2007-08-30 04:58:25 +00:00
dyoung a7ae782635 Make rtcache() and rtflush() block IPL_NET while they add/remove
a route from the cached routes list, so that the list won't change
out from under them.
2007-08-30 02:22:29 +00:00
dyoung b3fc296326 Use malloc(9) for sockaddrs instead of pool(9), and remove dom_sa_pool
and dom_sa_len members from struct domain.  Pools of fixed-size
objects are too rigid for sockaddr_dls, whose size can vary over
a wide range.

Return sockaddr_dl to its "historical" size.  Now that I'm using
malloc(9) instead of pool(9) to allocate sockaddr_dl, I can create
a sockaddr_dl of any size in the kernel, so expanding sockaddr_dl
is useless.

Avoid using sizeof(struct sockaddr_dl) in the kernel.

Introduce sockaddr_dl_alloc() for allocating & initializing an
arbitrary sockaddr_dl on the heap.

Add an argument, the sockaddr length, to sockaddr_alloc(),
sockaddr_copy(), and sockaddr_dl_setaddr().

Constify: LLADDR() -> CLLADDR().

Where the kernel overwrites LLADDR(), use sockaddr_dl_setaddr(),
instead.  Used properly, sockaddr_dl_setaddr() will not overrun
the end of the sockaddr.
2007-08-30 02:17:34 +00:00
dyoung b4ed197c2d LLADDR -> CLLADDR. 2007-08-27 14:59:11 +00:00
dyoung d93512cce5 Remove dead code. 2007-08-27 14:57:47 +00:00
dyoung ae7a571b06 Add a new routing message type, RTM_SETGATE. We can use an
RTM_SETGATE message to ask the link layer to fill in the link-layer
nexthop before we try to detect a duplicate route in a multipath-capable
kernel.
2007-08-27 00:34:01 +00:00
dyoung 5204966a96 Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).

Use sockaddr_dl_setaddr() in a few places.
2007-08-26 22:59:08 +00:00
dyoung e7e5e02759 Overhaul gre(4), especially the GRE in UDP bits:
* Create the kernel thread in gre_clone_create() instead of trying
  to create it in gre_ioctl().  (Thanks ad@ for suggesting it, and
  pointing out that I can't kthread_create while I hold a spin
  lock.)  Run the thread always, but put it to sleep while the
  gre(4) is not in UDP mode.

* Use sockaddr_in_init().

* Move some thread state off of the stack and into the softc.

* Extract subroutines gre_do_recv(), gre_do_send(), and gre_reconf()
  from gre_thread1(), making the code more readable.
2007-08-24 23:38:31 +00:00
skd d4509b0376 Clean up net compat ioctls, and clean up handling of wireless ioctls. 2007-08-20 04:49:40 +00:00
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