Commit Graph

1180 Commits

Author SHA1 Message Date
cegger 302b7dbb45 Check if ndi is valid before use.
ok tonnerre@
2009-08-06 12:17:11 +00:00
dyoung bb61b3608a Use malloc(...|M_ZERO) instead of malloc(...) followed by memset(,0,). 2009-08-04 22:04:23 +00:00
dyoung 59b8f11a8b Fix typo in comment, s/SIOCSIFADDR/SIOCINITIFADDR/. 2009-07-30 17:28:36 +00:00
tonnerre 5d2cc68d22 Instead of using the net.inet6.ip6.accept_rtadv sysctl for all devices,
make net.inet6.ip6.accept_rtadv the default for individual per-device
settings so people can use the ndp(8) utility to set per-device whether
or not to accept route advertisements.

rtadvd changes to follow.

(Debated on tech-net@ before but almost two weeks passed by without any
comment on the patch.)
2009-07-25 23:12:09 +00:00
pooka 7aa04865ab POOL_INIT -> pool_init 2009-05-26 00:17:56 +00:00
pooka 21e6fa78da Remove declaration of unused extern struct ifnet loif[NLOOP], which
was already removed once, but brought back in a wholesale import.
While here, mop up the #ifdef __SomeotherOS__ noise.
2009-05-25 22:49:23 +00:00
elad 29c3cf04e6 Remove "privileged" variable, perform the kauth(9) call before we go into
splnet() for the privileged commands. Privileged commands were marked as
such for clarity.

Mailing list reference:

	http://mail-index.netbsd.org/tech-net/2009/05/08/msg001283.html
2009-05-12 23:01:26 +00:00
elad b15203315e Implicit EPERM -> explicit EACCES.
Requested by ad@ and yamt@.
2009-05-12 22:22:46 +00:00
elad d4ee4ec689 Remove some more "priv" variable usage in favor of kauth(9) calls. 2009-05-07 21:51:47 +00:00
elad 4188b89914 Remove some usage of "priv" and "privileged" variables and instead pass
around credentials. Also push down kauth(9) calls closer to where the
operation is done.

Mailing list reference:

	http://mail-index.netbsd.org/tech-net/2009/04/30/msg001270.html
2009-05-06 21:41:59 +00:00
elad 996746c20d Replace wrong __UNCONST() use with a local variable.
Similar to issues pointed out by bouyer@ and forgotten by me when I did
the last commit.

Should fix issues reported on current-users@ in:

    http://mail-index.netbsd.org/current-users/2009/05/02/msg009273.html
2009-05-02 18:58:03 +00:00
martin 6a887ea20a Add missing paranthesis - from Kurt Lidl in PR port-vax/41316 2009-05-01 03:23:39 +00:00
elad 3c1f169a59 Commit changes to netinet6/in6_src.c, forgot in previous commit:
http://mail-index.netbsd.org/source-changes/2009/04/30/msg220547.html

Make in_pcbsetport() set the port number selected before passing "sin" to
kauth(9).
2009-04-30 20:26:09 +00:00
elad ddcbe0e1dd - Make in6_pcbbind_{addr,port}() static
- Properly authorize port binding in in_pcbsetport() and in6_pcbsetport()

- Pass struct sockaddr_in6 to in6_pcbsetport() instead of just the address,
  so that we have a more complete context

- Adjust udp6_output() to craft a sockaddr_in6 as it calls in6_pcbsetport()

- Fix an issue in in_pcbbind() where we used the "dom_sa_any" pointer and
  not a copy of it, pointed out by bouyer@, thanks!

Mailing list reference:

	http://mail-index.netbsd.org/tech-net/2009/04/29/msg001259.html
2009-04-30 18:18:34 +00:00
elad 3a272cca86 Only check if the port is used if it was specified.
Should fix problem reported in

    http://mail-index.netbsd.org/current-users/2009/04/22/msg009130.html
2009-04-22 18:35:01 +00:00
elad b7a329340e Replace KAUTH_GENERIC_ISSUSER with a better alternative. 2009-04-20 19:57:18 +00:00
elad e75a3b5e33 Extract in6_pcbbind()'s guts into two new routines: in6_pcbbind_addr() and
in6_pcbbind_port(), used for binding to an address and a port respectively.

While here, fix a possible "leak" of an in6pcb when binding to an address
succeeded but binding to an auto-assigned port failed.

Proposed and received no objections on tech-net@:

	http://mail-index.netbsd.org/tech-net/2009/04/15/msg001223.html
2009-04-20 18:14:30 +00:00
tsutsui d779b85d3e Remove extra whitespace added by a stupid tool.
XXX: more in src/sys/arch
2009-04-18 14:58:02 +00:00
drochner 40629b1267 fix traversing of a control mbuf in the case that a message len
is not aligned wrt CMSG_ALIGN - the length counter drops below 0
in this case which was not checked for,
fixes crashes (with isc_dhcrelay4) reported by Uwe in tech-net
(subject: netbsd5-rc3 crash caused by isc_dhcrelay)
2009-04-18 12:40:52 +00:00
elad d91dbb36b0 Don't set sin->sin_port and sin6->sin6_port to 0 before calling
ifa_ifwithaddr(), as we no longer do a byte compare on the entire struct.

Reviewed by and okay from dyoung@.
2009-04-14 21:25:20 +00:00
liamjfoy 29f894919e Init ip6flow pool dynamically instead of using a linkset. 2009-03-23 18:43:20 +00:00
he 59e8c39718 Correct two more bungled bcopy() -> memcpy() conversions. 2009-03-19 08:22:29 +00:00
cegger e2cb85904d bcopy -> memcpy 2009-03-18 17:06:41 +00:00
cegger c363a9cb62 bzero -> memset 2009-03-18 16:00:08 +00:00
cegger 35fb64746b bcmp -> memcmp 2009-03-18 15:14:29 +00:00
cegger df7f595ecd Ansify function definitions w/o arguments. Generated with sed. 2009-03-18 10:22:21 +00:00
cegger dc56dbbd97 ansify function definitions 2009-03-15 21:23:31 +00:00
dsl 02cdf4d2c8 Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
2009-03-14 14:45:51 +00:00
christos 52d2525b45 make created and lastused time_t to avoid 2038 problems. 2009-02-14 20:53:04 +00:00
dyoung de6be57a12 Use the in6_ifaddr ia_ifa member instead of casting from from
in6_ifaddr to ifaddr.

Remove unnecessary parentheses.  Do not needlessly cast RTM_ADD to
int.

No functional change intended.
2009-02-05 22:32:24 +00:00
christos 14ba6c67a5 Provide compatibility to the old timeval SCM_TIMESTAMP messages. 2009-01-19 02:27:57 +00:00
christos 51200e9aa1 mention that you'll need to update compat if you change the size of in6_ifreq. 2009-01-15 23:22:15 +00:00
christos 5a4537eb47 Emulate a couple more ioctls. Thanks to Matthias Drochner for pointing them out. 2009-01-15 20:32:59 +00:00
christos ba8b020023 - switch the lifetime struct to time_t and provide compatibility for the
old ioctl.
2009-01-15 18:20:48 +00:00
christos bae29cd69f Change back time_t in the lifetime struct to int32_t's for binary compatibily.
Since this is just the number of seconds for lifetime of the address, it is
not an issue.
2009-01-14 18:06:52 +00:00
christos 461a86f9bd merge christos-time_t 2009-01-11 02:45:45 +00:00
yamt b1fea83762 remove extra semicolons. 2009-01-03 03:43:21 +00:00
cegger dcf705893e use M_ZERO on malloc() and remove subsequent bzero(). 2008-12-19 18:49:37 +00:00
cegger 9b87d582bd kill MALLOC and FREE macros. 2008-12-17 20:51:31 +00:00
pooka c6e7028d1c Make dom_maxrtkey of inet/inet6domain the size of the ip_encap pack
structures.  This is far from optimal, but gets rid of iffy
#ifdef INET in radix.c.  The radix bonsai still needs lots of love
before loading domains dynamically is possible...
2008-11-25 18:28:05 +00:00
dyoung de87fe677d *** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02🇩🇪ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address.  (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior.  Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability.  KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR.  In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr.  That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR.  In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR.  For example, pull ..._init() out of any switch
statement that looks like this:

        switch (...->sa_family) {
        case ...:
                ..._init();
                ...
                break;
        ...
        default:
                ..._init();
                ...
                break;
        }

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

        switch (x & (IFF_UP|IFF_RUNNING)) {
        case 0:
                ...
                break;
        case IFF_RUNNING:
                ...
                break;
        case IFF_UP:
                ...
                break;
        case IFF_UP|IFF_RUNNING:
                ...
                break;
        }

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure.  Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls.  In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source.  In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively.  Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset.  Delete unnecessary casts to void *.  Use
sockaddr_in_init() and sockaddr_in6_init().  Compare pointers with
NULL instead of "testing truth".  Replace some instances of (type
*)0 with NULL.  Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 00:20:01 +00:00
plunky 8903ff8350 sockopt_getmbuf() may fail, handle that possibility 2008-10-27 20:03:07 +00:00
dyoung 420368fa25 Use sockaddr_in_init(). Wrap lines. No functional change intended. 2008-10-24 22:30:32 +00:00
dyoung 74264e2e40 bzero -> memset. Avoid some messy casts to sockaddr by using a
union of sockaddr_in6 and sockaddr.  No functional change intended.
2008-10-24 21:30:34 +00:00
dyoung cf969cfa5a Constify the rt_addrinfo argument to the ifa_rtrequest member
function of struct ifaddr.
2008-10-24 17:07:33 +00:00
dyoung ee1bfcb3e8 bzero -> memset. Do not "test truth" of pointers, but compare with
NULL, instead.  Do not gratuitously cast to void *.  Use NULL
instead of (type *)0.

No functional changes intended.
2008-10-24 16:54:18 +00:00
hans c25473a894 if_input needs to be called at splnet(). ok by cube. 2008-10-19 23:28:31 +00:00
hans b0d4e5c1a7 include bpf headers so that the bpf calls actually do something. ok by cube. 2008-10-16 18:56:56 +00:00
plunky 1bd707dd19 ip6_pcbopts() is called with the socket lock held, use M_NOWAIT 2008-10-12 15:24:10 +00:00
plunky 452f1527b6 ip6_pcbopt() is in the ctloutput path, we should not
sleep here because socket lock is held. use M_NOWAIT
2008-10-12 15:12:17 +00:00