History log of /src/sys/net/if_srt.c |
Revision | | Date | Author | Comments |
1.32 |
| 16-Jun-2021 |
riastradh | if_attach and if_initialize cannot fail, don't test return value
These were originally made failable back in 2017 when if_initialize allocated a softint in every interface for link state changes, so that it could fail gracefully instead of panicking:
https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html
However, this spawned many seldom- or never-tested error branches, which are risky to have around. And that softint in every interface has since been replaced by a single global workqueue, because link state changes require thread context but not low latency or high throughput:
https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html
So there is no longer any reason for if_initialize to fail. (The subroutine if_stats_init can't fail because percpu_alloc can't fail either.)
There is a snag: the softint_establish in if_percpuq_create could fail, potentially leading to bad consequences later on trying to use the softint. This change doesn't introduce any new bugs because of the snag -- if_percpuq_attach was already broken. However, the snag can be better addressed without spawning error branches, either by using a single softint or making softints less scarce.
(Separate commit will change the signatures of if_attach and if_initialize to return void, scheduled to ride whatever is the next convenient kernel bump.)
Patch and testing on amd64 and evbmips64-eb by maya@; commit message soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
|
1.31 |
| 29-Jan-2020 |
thorpej | branches: 1.31.10; Adopt <net/if_stats.h>.
|
1.30 |
| 27-Apr-2019 |
pgoyette | branches: 1.30.4; A few more empty-string --> NULL in required-modules lists
|
1.29 |
| 26-Mar-2019 |
pgoyette | Add cloned-interface-create code to srt open() routine so behavior matches that which is documented in srtconfig(1) man page. Without this, srt only works if you first create the srtN interface with ifconfig(8).
|
1.28 |
| 26-Mar-2019 |
pgoyette | Add devsw_{attach,detach} stuff for _MODULE variant. (Not needed for built-in variant since the devsw is also built-in.) This will allow the modular srt devices to be accessed via open(2) and ioctl(2).
XXX Someone(tm) needs to update MAKEDEV to create the /dev/srtN device nodes (with device-major 179)!
|
1.27 |
| 23-Oct-2017 |
msaitoh | branches: 1.27.4; - If if_attach() failed in the attach function, free resources and return. - KNF
|
1.26 |
| 14-Feb-2017 |
ozaki-r | branches: 1.26.4; 1.26.6; Do ND in L2_output in the same manner as arpresolve
The benefits of this change are: - The flow is consistent with IPv4 (and FreeBSD and OpenBSD) - old: ip6_output => nd6_output (do ND if needed) => L2_output (lookup a stored cache) - new: ip6_output => L2_output (lookup a cache. Do ND if cache not found) - We can remove some workarounds in nd6_output - We can move L2 specific operations to their own place - The performance slightly improves because one cache lookup is reduced
|
1.25 |
| 09-Feb-2017 |
kre | PR kern/51280
This allows srt devices to work for IPv6. srt still needs work (particularly #ifdef INET6 but also general effeciency and similar.)
|
1.24 |
| 14-Jan-2017 |
maya | branches: 1.24.2; appease coverity by using strlcpy instead of strncpy
ok riastradh
|
1.23 |
| 07-Aug-2016 |
christos | modularize some more drivers and merge the module glue
|
1.22 |
| 20-Jun-2016 |
knakahara | branches: 1.22.2; apply if_output_lock() to L3 callers which call ifp->if_output() of L2(or L3 tunneling).
|
1.21 |
| 28-Apr-2016 |
ozaki-r | Constify rtentry of if_output
We no longer need to change rtentry below if_output.
The change makes it clear where rtentries are changed (or not) and helps forthcoming locking (os psrefing) rtentries.
|
1.20 |
| 24-Aug-2015 |
pooka | sprinkle _KERNEL_OPT
|
1.19 |
| 25-Jul-2014 |
dholland | branches: 1.19.4; Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
|
1.18 |
| 16-Mar-2014 |
dholland | branches: 1.18.2; Change (mostly mechanically) every cdevsw/bdevsw I can find to use designated initializers.
I have not built every extant kernel so I have probably broken at least one build; however I've also found and fixed some wrong cdevsw/bdevsw entries so even if so I think we come out ahead.
|
1.17 |
| 28-Oct-2011 |
dyoung | branches: 1.17.2; 1.17.12; 1.17.16; For these interfaces, the implementation of SIOCSIFDSTADDR is identical to SIOCINITIFADDR, and SIOCSIFDSTADDR callers always fall back to SIOCINITIFADDR, so just get rid of the SIOCSIFDSTADDR case.
|
1.16 |
| 17-Jul-2011 |
joerg | Retire varargs.h support. Move machine/stdarg.h logic into MI sys/stdarg.h and expect compiler to provide proper builtins, defaulting to the GCC interface. lint still has a special fallback. Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and derive va_list as required by standards.
|
1.15 |
| 09-Sep-2010 |
tls | From Coyote Point source tree: "fix" srt IPv4 lookup on little-endian hosts. IPv6 is probably still broken, and, actually, the lookup table for mask values should be kept in network byte order, not host byte order and the corresponding change to the srtconfig ioctl interface made.
But at least this works.
|
1.14 |
| 05-Apr-2010 |
joerg | Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf check into the inline functions as well the fourth argument for bpf_attach.
|
1.13 |
| 19-Jan-2010 |
pooka | branches: 1.13.2; 1.13.4; Redefine bpf linkage through an always present op vector, i.e. #if NBPFILTER is no longer required in the client. This change doesn't yet add support for loading bpf as a module, since drivers can register before bpf is attached. However, callers of bpf can now be modularized.
Dynamically loadable bpf could probably be done fairly easily with coordination from the stub driver and the real driver by registering attachments in the stub before the real driver is loaded and doing a handoff. ... and I'm not going to ponder the depths of unload here.
Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
|
1.12 |
| 09-Dec-2009 |
dyoung | KNF.
|
1.11 |
| 18-Mar-2009 |
cegger | bzero -> memset
|
1.10 |
| 18-Mar-2009 |
cegger | bcmp -> memcmp
|
1.9 |
| 07-Nov-2008 |
dyoung | branches: 1.9.4; *** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link 02:de: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.
|
1.8 |
| 15-Jun-2008 |
christos | branches: 1.8.2; 1.8.4; - add if_alloc (ours just mallocs), and if_initname and use them (from FreeBSD) - kill memsets where M_ZERO can be used.
|
1.7 |
| 07-Feb-2008 |
dyoung | branches: 1.7.6; 1.7.8; 1.7.10; 1.7.12; 1.7.14; Start patching up the kernel so that a network driver always has the opportunity to handle an ioctl before generic ifioctl handling occurs. This will ease extending the kernel and sharing of code between drivers.
First steps: Make the signature of ifioctl_common() match struct ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new ifioctl() regime, throughout the kernel.
|
1.6 |
| 11-Dec-2007 |
lukem | use __KERNEL_RCSID()
|
1.5 |
| 04-Mar-2007 |
christos | branches: 1.5.16; 1.5.22; 1.5.24; 1.5.26; 1.5.28; Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
|
1.4 |
| 17-Feb-2007 |
dyoung | 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.
|
1.3 |
| 05-Jan-2007 |
mouse | branches: 1.3.2; 1.3.4; 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.)
|
1.2 |
| 29-Dec-2006 |
wiz | branches: 1.2.2; Add RCS Id.
|
1.1 |
| 29-Dec-2006 |
mouse | Very first import of the source-address-based routing pseudo-device, before any cleanup at all, per discussion with perry@.
|
1.2.2.6 |
| 11-Feb-2008 |
yamt | sync with head.
|
1.2.2.5 |
| 21-Jan-2008 |
yamt | sync with head
|
1.2.2.4 |
| 03-Sep-2007 |
yamt | sync with head.
|
1.2.2.3 |
| 26-Feb-2007 |
yamt | sync with head.
|
1.2.2.2 |
| 30-Dec-2006 |
yamt | sync with head.
|
1.2.2.1 |
| 29-Dec-2006 |
yamt | file if_srt.c was added on branch yamt-lazymbuf on 2006-12-30 20:50:20 +0000
|
1.3.4.2 |
| 12-Mar-2007 |
rmind | Sync with HEAD.
|
1.3.4.1 |
| 27-Feb-2007 |
yamt | - sync with head. - move sched_changepri back to kern_synch.c as it doesn't know PPQ anymore.
|
1.3.2.2 |
| 12-Jan-2007 |
ad | Sync with head.
|
1.3.2.1 |
| 05-Jan-2007 |
ad | file if_srt.c was added on branch newlock2 on 2007-01-12 01:04:12 +0000
|
1.5.28.1 |
| 13-Dec-2007 |
bouyer | Sync with HEAD
|
1.5.26.1 |
| 11-Dec-2007 |
yamt | sync with head.
|
1.5.24.1 |
| 26-Dec-2007 |
ad | Sync with head.
|
1.5.22.1 |
| 18-Feb-2008 |
mjf | Sync with HEAD.
|
1.5.16.2 |
| 23-Mar-2008 |
matt | sync with HEAD
|
1.5.16.1 |
| 09-Jan-2008 |
matt | sync with HEAD
|
1.7.14.1 |
| 18-Jun-2008 |
simonb | Sync with head.
|
1.7.12.1 |
| 23-Jun-2008 |
wrstuden | Sync w/ -current. 34 merge conflicts to follow.
|
1.7.10.4 |
| 09-Oct-2010 |
yamt | sync with head
|
1.7.10.3 |
| 11-Aug-2010 |
yamt | sync with head.
|
1.7.10.2 |
| 11-Mar-2010 |
yamt | sync with head
|
1.7.10.1 |
| 04-May-2009 |
yamt | sync with head.
|
1.7.8.1 |
| 17-Jun-2008 |
yamt | sync with head.
|
1.7.6.2 |
| 17-Jan-2009 |
mjf | Sync with HEAD.
|
1.7.6.1 |
| 29-Jun-2008 |
mjf | Sync with HEAD.
|
1.8.4.2 |
| 28-Apr-2009 |
skrll | Sync with HEAD.
|
1.8.4.1 |
| 19-Jan-2009 |
skrll | Sync with HEAD.
|
1.8.2.1 |
| 13-Dec-2008 |
haad | Update haad-dm branch to haad-dm-base2.
|
1.9.4.1 |
| 13-May-2009 |
jym | Sync with HEAD.
Commit is split, to avoid a "too many arguments" protocol error.
|
1.13.4.2 |
| 05-Mar-2011 |
rmind | sync with head
|
1.13.4.1 |
| 30-May-2010 |
rmind | sync with head
|
1.13.2.2 |
| 22-Oct-2010 |
uebayasi | Sync with HEAD (-D20101022).
|
1.13.2.1 |
| 30-Apr-2010 |
uebayasi | Sync with HEAD.
|
1.17.16.1 |
| 18-May-2014 |
rmind | sync with head
|
1.17.12.2 |
| 03-Dec-2017 |
jdolecek | update from HEAD
|
1.17.12.1 |
| 20-Aug-2014 |
tls | Rebase to HEAD as of a few days ago.
|
1.17.2.1 |
| 22-May-2014 |
yamt | sync with head.
for a reference, the tree before this commit was tagged as yamt-pagecache-tag8.
this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments")
|
1.18.2.1 |
| 10-Aug-2014 |
tls | Rebase.
|
1.19.4.6 |
| 28-Aug-2017 |
skrll | Sync with HEAD
|
1.19.4.5 |
| 05-Feb-2017 |
skrll | Sync with HEAD
|
1.19.4.4 |
| 05-Oct-2016 |
skrll | Sync with HEAD
|
1.19.4.3 |
| 09-Jul-2016 |
skrll | Sync with HEAD
|
1.19.4.2 |
| 29-May-2016 |
skrll | Sync with HEAD
|
1.19.4.1 |
| 22-Sep-2015 |
skrll | Sync with HEAD
|
1.22.2.1 |
| 20-Mar-2017 |
pgoyette | Sync with HEAD
|
1.24.2.1 |
| 21-Apr-2017 |
bouyer | Sync with HEAD
|
1.26.6.1 |
| 10-Dec-2017 |
snj | Pull up following revision(s) (requested by msaitoh in ticket #427): sys/arch/amiga/dev/if_bah_zbus.c: 1.17 sys/arch/arm/broadcom/bcm53xx_eth.c: 1.30 sys/arch/powerpc/booke/dev/pq3etsec.c: 1.32 sys/arch/usermode/dev/if_veth.c: 1.9 sys/dev/ic/an.c: 1.66 sys/dev/ic/athn.c: 1.17 sys/dev/ic/atw.c: 1.162 sys/dev/ic/bwi.c: 1.33 sys/dev/ic/dwc_gmac.c: 1.41-1.42 sys/dev/ic/malo.c: 1.10 sys/dev/ic/rt2560.c: 1.31 sys/dev/ic/rt2661.c: 1.36 sys/dev/ic/rt2860.c: 1.29 sys/dev/ic/rtw.c: 1.127 sys/dev/ic/rtwvar.h: 1.46 sys/dev/ic/smc90cx6.c: 1.71 sys/dev/ic/smc90cx6var.h: 1.12 sys/dev/ic/wi.c: 1.244 sys/dev/pci/if_ipw.c: 1.66 sys/dev/pci/if_iwi.c: 1.104 sys/dev/pci/if_iwm.c: 1.76 sys/dev/pci/if_iwn.c: 1.86 sys/dev/pci/if_rtwn.c: 1.13 sys/dev/pci/if_wm.c: 1.541 sys/dev/pci/if_wpi.c: 1.79 sys/dev/pci/ixgbe/ixgbe.c: 1.106 sys/dev/pci/ixgbe/ixv.c: 1.73 via patch sys/dev/pcmcia/if_malo_pcmcia.c: 1.15 sys/dev/scsipi/if_se.c: 1.95 sys/dev/usb/if_upl.c: 1.60 sys/net/if.c: 1.396 sys/net/if.h: 1.241 sys/net/if_arc.h: 1.23 sys/net/if_arcsubr.c: 1.78 sys/net/if_bridge.c: 1.136-1.137 sys/net/if_etherip.c: 1.39 sys/net/if_faith.c: 1.56 sys/net/if_gif.c: 1.131 sys/net/if_loop.c: 1.96 sys/net/if_mpls.c: 1.30 sys/net/if_pppoe.c: 1.129 sys/net/if_srt.c: 1.27 sys/net/if_stf.c: 1.102 sys/net/if_tap.c: 1.100 sys/net/if_vlan.c: 1.105 sys/netinet/ip_carp.c: 1.91 sys/rump/net/lib/libshmif/if_shmem.c: 1.73-1.74 sys/rump/net/lib/libvirtif/if_virt.c: 1.55-1.56 if_initalize() and if_attach() failed when resource allocation failed (e.g. allocating softint). Without this change, it panics. It's bad because resource shortage really occured when a lot of pseudo interface is created. To avoid this problem, don't panic and change return value of if_initialize() and if_attach() to int. Caller fanction will be recover from error cleanly by checking the return value. Return if bah_attach_subr() failed. If if_attach() failed in the attach function, return. - If if_initialize() failed in the attach function, free resources and return. - Add some missing frees in bridge_clone_destroy(). - KNF If error occured in bcmeth_ccb_attach(), free resources and return. If error occured in pq3etsec_attach(), free resources and return. If error occured in the attach function, free resources and return. - If if_initialize() failed in athn_attach(), free resources and return. - Add missing pmf_event_deregister() in athn_detach(). - Free resources correctly on some errors in atw_attach(). - Use apint*() insread of printf() in the attach function. If if_initialize() failed in the attach function, return. - If if_initialize() failed in the attach function, free resources and return. - Add missing dwc_gmac_free_dma_rings() and mutex_destroy() when attach failed. - If if_initialize() failed in the attach function, free resources and return. - ifp is always not NULL in iwi_detach(). Check correctly with ifp->if_softc. - If if_initialize() failed in the attach function, free resources and return. - Fix error path in the attach function correctly. If if_initialize() failed in the attach function, free resources and return. If if_attach() failed in the attach function, free resources and return. - If if_initialize() failed in the attach function, free resources and return. - KNF - If if_attach() failed in the attach function, free resources and return. - KNF Fix compile error. Fix compile error. We don't need '&mii', but just 'mii' for mii_detach(). Don't free sc_rthash twice
|
1.26.4.2 |
| 29-Apr-2017 |
pgoyette | Revise previous. Rather than explicitly including <sys/localcount.h> in all the places where {b,c}devsw is initialized, just include it from <sys/conf.h>. This avoids an include-sequence dependancy.
|
1.26.4.1 |
| 29-Apr-2017 |
pgoyette | Add DEVSW_MODULE_INIT to existing device-driver modules, so that they willl have a localcount defined and thus be permitted to load. Without a localcount, loading the module will return EINVAL.
XXX the dtrace and drm stuff might need to be fed back upstream?
|
1.27.4.2 |
| 08-Apr-2020 |
martin | Merge changes from current as of 20200406
|
1.27.4.1 |
| 10-Jun-2019 |
christos | Sync with HEAD
|
1.30.4.1 |
| 29-Feb-2020 |
ad | Sync with head.
|
1.31.10.1 |
| 17-Jun-2021 |
thorpej | Sync w/ HEAD.
|