aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if.c
Commit message (Collapse)AuthorAgeFilesLines
* Add linkstate to bridge(4), set the link to up when at least one underlyingAndrew Thompson2012-04-201-2/+2
| | | | | | | | | | | | interface is up, otherwise the link is down. This, among other things, allows carp to work on a bridge. Prodded by: glebius Tested by: Alexander Lunev Notes: svn path=/head/; revision=234487
* Remove KASSERTS, they do not add any value here since the pointer is about toAndrew Thompson2012-04-181-6/+2
| | | | | | | be derefernced anyway. Notes: svn path=/head/; revision=234403
* g/c last bit of old ipv6 prefix management.Sergey Kandaurov2012-02-081-1/+0
| | | | | | | | Reviewed by: bz Obtained from: NetBSD, net/if.h, rev 1.80 Notes: svn path=/head/; revision=231229
* Fix typo in r231010.Gleb Smirnoff2012-02-051-1/+1
| | | | | | | Submitted by: linimon Notes: svn path=/head/; revision=231013
* Better comment for ifa_init(), ifa_ref(), ifa_free().Gleb Smirnoff2012-02-051-1/+1
| | | | Notes: svn path=/head/; revision=231010
* In ifa_init() initialize if_data.ifi_datalen. This would beGleb Smirnoff2012-02-051-0/+1
| | | | | | | | | required after upcoming changes from bz@. Discussed with: bz Notes: svn path=/head/; revision=231009
* Convert all users of IF_ADDR_LOCK to use new locking macros that specifyJohn Baldwin2012-01-051-53/+53
| | | | | | | | | | either a read lock or write lock. Reviewed by: bz MFC after: 2 weeks Notes: svn path=/head/; revision=229621
* Restore a feature that was present in 5.x and 6.x, and was cleared inGleb Smirnoff2011-12-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 7.x, 8.x and 9.x with pf(4) imports: pfsync(4) should suppress CARP preemption, while it is running its bulk update. However, reimplement the feature in more elegant manner, that is partially inspired by newer OpenBSD: - Rename term "suppression" to "demotion", to match with OpenBSD. - Keep a global demotion factor, that can be raised by several conditions, for now these are: - interface goes down - carp(4) has problems with ip_output() or ip6_output() - pfsync performs bulk update - Unlike in OpenBSD the demotion factor isn't a counter, but is actual value added to advskew. The adjustment values for particular error conditions are also configurable, and their defaults are maximum advskew value, so a single failure bumps demotion to maximum. This is for POLA compatibility, and should satisfy most users. - Demotion factor is a writable sysctl, so user can do foot shooting, if he desires to. Notes: svn path=/head/; revision=228736
* A major overhaul of the CARP implementation. The ip_carp.c was startedGleb Smirnoff2011-12-161-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from scratch, copying needed functionality from the old implemenation on demand, with a thorough review of all code. The main change is that interface layer has been removed from the CARP. Now redundant addresses are configured exactly on the interfaces, they run on. The CARP configuration itself is, as before, configured and read via SIOCSVH/SIOCGVH ioctls. A new prefix created with SIOCAIFADDR or SIOCAIFADDR_IN6 may now be configured to a particular virtual host id, which makes the prefix redundant. ifconfig(8) semantics has been changed too: now one doesn't need to clone carpXX interface, he/she should directly configure a vhid on a Ethernet interface. To supply vhid data from the kernel to an application the getifaddrs(8) function had been changed to pass ifam_data with each address. [1] The new implementation definitely closes all PRs related to carp(4) being an interface, and may close several others. It also allows to run a single redundant IP per interface. Big thanks to Bjoern Zeeb for his help with inet6 part of patch, for idea on using ifam_data and for several rounds of reviewing! PR: kern/117000, kern/126945, kern/126714, kern/120130, kern/117448 Reviewed by: bz Submitted by: bz [1] Notes: svn path=/head/; revision=228571
* Remove the unused if_free_type() function.Brooks Davis2011-12-091-21/+2
| | | | | | | X-MFC after: never Notes: svn path=/head/; revision=228380
* Improve logging:Gleb Smirnoff2011-11-221-2/+2
| | | | | | | | | - don't hardcode function name - use LOG_DEBUG for such a debug message - print error value Notes: svn path=/head/; revision=227832
* Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.Ed Schouten2011-11-071-2/+2
| | | | | | | This means that their use is restricted to a single C file. Notes: svn path=/head/; revision=227293
* Add infrastructure to allow all frames/packets received on an interfaceBjoern A. Zeeb2011-07-031-0/+16
| | | | | | | | | | | | | | | | | to be assigned to a non-default FIB instance. You may need to recompile world or ports due to the change of struct ifnet. Submitted by: cjsp Submitted by: Alexander V. Chernikov (melifaro ipfw.ru) (original versions) Reviewed by: julian Reviewed by: Alexander V. Chernikov (melifaro ipfw.ru) MFC after: 2 weeks X-MFC: use spare in struct ifnet Notes: svn path=/head/; revision=223735
* Update ifc_len field of struct ifconf passed for the ioctl SIOCGIFCONF32Sergey Kandaurov2011-06-281-0/+2
| | | | | | | | | | | | (i.e. under COMPAT_FREEBSD32) in case ifconf() returned success to match the native SIOCGIFCONF behavior. PR: kern/158369 Reported by: Paul Procacci <pprocacci att gmail com> MFC after: 1 week Notes: svn path=/head/; revision=223625
* When removing ifnets, we should first remove the reference to ifnetGleb Smirnoff2011-04-041-9/+10
| | | | | | | | | | | | | | from the interface index, then decrease refcount, not vice versa. Otherwise there is a race (reproducible) when if_free_internal() contests on IFNET_WLOCK(), and we got a zero-refed ifnet in the index for a long time. It may be picked by some other thread, that runs ifnet_byindex_ref(), who takes the ifnet from index, and bumps refcount. When reader drops the lock, if_free_internal() proceeds with free. Then reader tries to free it a second time. Notes: svn path=/head/; revision=220317
* - Merge changes to the base system to support OFED. These includeJeff Roberson2011-03-211-0/+6
| | | | | | | | a wider arg2 for sysctl, updates to vlan code, IFT_INFINIBAND, and other miscellaneous small features. Notes: svn path=/head/; revision=219819
* Mfp4 CH=177274,177280,177284-177285,177297,177324-177325Bjoern A. Zeeb2011-02-161-15/+34
| | | | | | | | | | | | | | | | | | | | | | | | | VNET socket push back: try to minimize the number of places where we have to switch vnets and narrow down the time we stay switched. Add assertions to the socket code to catch possibly unset vnets as seen in r204147. While this reduces the number of vnet recursion in some places like NFS, POSIX local sockets and some netgraph, .. recursions are impossible to fix. The current expectations are documented at the beginning of uipc_socket.c along with the other information there. Sponsored by: The FreeBSD Foundation Sponsored by: CK Software GmbH Reviewed by: jhb Tested by: zec Tested by: Mikolaj Golub (to.my.trociny gmail.com) MFC after: 2 weeks Notes: svn path=/head/; revision=218757
* Mfp4 CH=177255:Bjoern A. Zeeb2011-02-111-2/+4
| | | | | | | | | | | | | | | | | | | | Make VNET_ASSERT() available with either VNET_DEBUG or INVARIANTS. Change the syntax to match KASSERT() to allow more flexible panic messages rather than having a printf with hardcoded arguments before panic. Adjust the few assertions we have to the new format (and enhance the output). Sponsored by: The FreeBSD Foundation Sponsored by: CK Software GmbH Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=218559
* Fix a LOR by dropping the global ifnet locks while allocating a new ifnetJohn Baldwin2011-01-241-6/+20
| | | | | | | | | | | table in if_grow(). The order of the SYSINIT's for ifnet state were swapped so that the various locks were initialized before being used. Reviewed by: pluknet, bz MFC after: 2 weeks Notes: svn path=/head/; revision=217805
* sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.Matthew D Fleming2011-01-121-1/+1
| | | | | | | Commit the net* piece. Notes: svn path=/head/; revision=217322
* After some off-list discussion, revert a number of changes to theDimitry Andric2010-11-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DPCPU_DEFINE and VNET_DEFINE macros, as these cause problems for various people working on the affected files. A better long-term solution is still being considered. This reversal may give some modules empty set_pcpu or set_vnet sections, but these are harmless. Changes reverted: ------------------------------------------------------------------------ r215318 | dim | 2010-11-14 21:40:55 +0100 (Sun, 14 Nov 2010) | 4 lines Instead of unconditionally emitting .globl's for the __start_set_xxx and __stop_set_xxx symbols, only emit them when the set_vnet or set_pcpu sections are actually defined. ------------------------------------------------------------------------ r215317 | dim | 2010-11-14 21:38:11 +0100 (Sun, 14 Nov 2010) | 3 lines Apply the STATIC_VNET_DEFINE and STATIC_DPCPU_DEFINE macros throughout the tree. ------------------------------------------------------------------------ r215316 | dim | 2010-11-14 21:23:02 +0100 (Sun, 14 Nov 2010) | 2 lines Add macros to define static instances of VNET_DEFINE and DPCPU_DEFINE. Notes: svn path=/head/; revision=215701
* Apply the STATIC_VNET_DEFINE and STATIC_DPCPU_DEFINE macros throughoutDimitry Andric2010-11-141-1/+1
| | | | | | | the tree. Notes: svn path=/head/; revision=215317
* Factor out DDB commands from r204145, r204279 into if_debug.c for furtherBjoern A. Zeeb2010-10-251-82/+1
| | | | | | | | | | | | | | enhancements (1). Switch to a standard 2-clause BSD license for this (2). Unfortunately we have to un-static the ifindex_table for this but do not publicly export it. Suggested by: rwatson (1) a while back. Approved by: thompsa (2) for the change from r204279. MFC after: 6 days Notes: svn path=/head/; revision=214333
* Reshuffle SIOCGIFCONF32 handler from r155224.Sergey Kandaurov2010-10-211-17/+29
| | | | | | | | | | | | | | | | - move all the chunks into one file, which allows to hide SIOCGIFCONF32 global definition as well. - replace __amd64__ with proper COMPAT_FREEBSD32 around. - handle 32bit capacity before going into the handler itself instead of doing internal 32bit specific changes within it (e.g. as it's done for SIOCGDEFIFACE32_IN6). - use explicitely sized types for ABI compat. Approved by: kib (mentor) MFC after: 2 weeks Notes: svn path=/head/; revision=214136
* Replace sbuf_overflowed() with sbuf_error(), which returns any errorMatthew D Fleming2010-09-101-2/+2
| | | | | | | | | code associated with overflow or with the drain function. While this function is not expected to be used often, it produces more information in the form of an errno that sbuf_overflowed() did. Notes: svn path=/head/; revision=212425
* When moving an ethernet ifnet from one vnet to another, destroy theMarko Zec2010-08-131-0/+9
| | | | | | | | | | | associated ng_ether netgraph node in the current vnet, and create a new one in the target vnet. Reviewed by: julian MFC after: 3 days Notes: svn path=/head/; revision=211283
* Unbreak LINT by moving all carp hooks to net/if.c / netinet/ip_carp.h, withWill Andrews2010-08-111-0/+16
| | | | | | | | | | the appropriate ifdefs. Reviewed by: bz Approved by: ken (mentor) Notes: svn path=/head/; revision=211193
* Allow carp(4) to be loaded as a kernel module. Follow precedent set byWill Andrews2010-08-111-21/+4
| | | | | | | | | | | | | | | | | | bridge(4), lagg(4) etc. and make use of function pointers and pf_proto_register() to hook carp into the network stack. Currently, because of the uncertainty about whether the unload path is free of race condition panics, unloads are disallowed by default. Compiling with CARPMOD_CAN_UNLOAD in CFLAGS removes this anti foot shooting measure. This commit requires IP6PROTOSPACER, introduced in r211115. Reviewed by: bz, simon Approved by: ken (mentor) MFC after: 2 weeks Notes: svn path=/head/; revision=211157
* Return NULL rather than 0 for a pointer.Bjoern A. Zeeb2010-07-271-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=210532
* This patch fixes the problem where proxy ARP entries cannot be addedQing Li2010-05-251-2/+3
| | | | | | | | | over the if_ng interface. MFC after: 3 days Notes: svn path=/head/; revision=208553
* Add new tunable 'net.link.ifqmaxlen' to set default send interfaceMaxim Sobolev2010-05-031-0/+4
| | | | | | | | | | | | | queue length. The default value for this parameter is 50, which is quite low for many of today's uses and the only way to modify this parameter right now is to edit if_var.h file. Also add read-only sysctl with the same name, so that it's possible to retrieve the current value. MFC after: 1 month Notes: svn path=/head/; revision=207554
* MFP4: @176978-176982, 176984, 176990-176994, 177441Bjoern A. Zeeb2010-04-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | "Whitspace" churn after the VIMAGE/VNET whirls. Remove the need for some "init" functions within the network stack, like pim6_init(), icmp_init() or significantly shorten others like ip6_init() and nd6_init(), using static initialization again where possible and formerly missed. Move (most) variables back to the place they used to be before the container structs and VIMAGE_GLOABLS (before r185088) and try to reduce the diff to stable/7 and earlier as good as possible, to help out-of-tree consumers to update from 6.x or 7.x to 8 or 9. This also removes some header file pollution for putatively static global variables. Revert VIMAGE specific changes in ipfilter::ip_auth.c, that are no longer needed. Reviewed by: jhb Discussed with: rwatson Sponsored by: The FreeBSD Foundation Sponsored by: CK Software GmbH MFC after: 6 days Notes: svn path=/head/; revision=207369
* When an underlying ioctl(2) handler returns an error, our ioctl(2)Xin LI2010-04-141-4/+3
| | | | | | | | | | | | | | | | | | | | interface considers that it hits a fatal error, and will not copyout the request structure back for _IOW and _IOWR ioctls, keeping them untouched. The previous implementation of the SIOCGIFDESCR ioctl intends to feed the buffer length back to userland. However, if we return an error, the feedback would be defeated and ifconfig(8) would trap into an infinite loop. This commit changes SIOCGIFDESCR to set buffer field to NULL to indicate the previous ENAMETOOLONG case. Reported by: bschmidt MFC after: 2 weeks Notes: svn path=/head/; revision=206637
* In if_detach_internal() we cannot hold the af_data lock over theBjoern A. Zeeb2010-04-111-3/+9
| | | | | | | | | | | | dom_ifdetach() calls as they might sleep for callout_drain(). Do as we do in if_attachdomain1() [r121470] and handle if_afdata_initialized earlier and call dom_ifdetach() unlocked. Discussed with: rwatson MFC after: 10 days Notes: svn path=/head/; revision=206470
* In if_detach_internal() only try to do the detach run if if_attachdomain1()Bjoern A. Zeeb2010-04-111-1/+1
| | | | | | | | | | | | has actually succeeded to initialize and attach. There is a theoretical possibility to drop out early in if_attachdomain1() leaving the array uninitialized if we cannot get the lock. Discussed with: rwatson MFC after: 10 days Notes: svn path=/head/; revision=206469
* Use the DB_SHOW_ALL_COMMAND() macro to register the formerly 'show ifnets'Bjoern A. Zeeb2010-02-241-1/+1
| | | | | | | | | | | in the db_show_all_table as 'show all ifnets' and with that follow the convention for showing complete lists. Submitted by: thompsa MFC after: 3 days Notes: svn path=/head/; revision=204279
* Start to implement ifnet DDB support:Bjoern A. Zeeb2010-02-201-0/+81
| | | | | | | | | | | | | | | | | - 'show ifnets' prints a list of ifnet *s per virtual network stack, - 'show ifnet <struct ifnet *>' prints fields matching the given ifp. We do not yet print the complete set of fields and might want to factor this out to an extra if_debug.c file in case this grows a lot[1]. We may also want to grow 'show ifnet <if_xname>' support[1]. Sponsored by: ISPsystem Suggested by: rwatson [1] Reviewed by: rwatson MFC after: 5 days Notes: svn path=/head/; revision=204145
* Enhance a panic string to contain more useful debugging information.Bjoern A. Zeeb2010-02-201-1/+2
| | | | | | | | | Sponsored by: ISPsystem Reviewed by: rwatson MFC after: 5 days Notes: svn path=/head/; revision=204142
* Revised revision 199201 (add interface description capability as inspiredXin LI2010-01-271-0/+70
| | | | | | | | | | | by OpenBSD), based on comments from many, including rwatson, jhb, brooks and others. Sponsored by: iXsystems, Inc. MFC after: 1 month Notes: svn path=/head/; revision=203052
* While flushing the multicast filter of an interface, do not zero the relevantShteryana Shopova2010-01-241-2/+19
| | | | | | | | | | | | | ifmultiaddr structures' reference to the parent interface, unless the parent interface is really detaching. While here, program only link layer multicast filters to a wlan's hardware parent interface. PR: kern/142391, kern/142392 Reviewed by: sam, rpaolo, bms MFC after: 1 week Notes: svn path=/head/; revision=202935
* Declare a new EVENTHANDLER called iflladdr_event which signals that the L2Andrew Thompson2010-01-181-0/+1
| | | | | | | | | | | | | | | | address on an interface has changed. This lets stacked interfaces such as vlan(4) detect that their lower interface has changed and adjust things in order to keep working. Previously this situation broke at least vlan(4) and lagg(4) configurations. The EVENTHANDLER_INVOKE call was not placed within if_setlladdr() due to the risk of a loop. PR: kern/142927 Submitted by: Nikolay Denev Notes: svn path=/head/; revision=202588
* The devices that supported EVFILT_NETDEV kqueue filters were removed inBrooks Davis2009-12-311-9/+2
| | | | | | | | | | | | | | | r195175. Remove all definitions, documentation, and usage. fifo_misc.c: Remove all kqueue tests as fifo_io.c performs all those that would have remained. Reviewed by: rwatson MFC after: 3 weeks X-MFC note: don't change vlan_link_state() function signature Notes: svn path=/head/; revision=201350
* Change vlan interfaces to cope more usefully with the parent interface beingJohn Baldwin2009-12-291-0/+10
| | | | | | | | | | | | | | | | | renamed. Previously the vlan interfaces would lose their configuration as if the parent interface had been physically removed. Now vlan interfaces ignore rename events. - Add a new ifnet flag (IFF_RENAMING) that is set while an ifnet is being renamed. This flag can be checked in ifnet departure/arrival event handlers to treat rename events differently. - Change the ifnet departure event handler in the if_vlan(4) driver to ignore departure events due to a trunk interface being renamed. Reviewed by: brooks, rwatson MFC after: 1 week Notes: svn path=/head/; revision=201196
* Remove if_timer/if_watchdog now that they are no longer used. The spaceJohn Baldwin2009-11-301-66/+0
| | | | | | | | | | used by if_timer is reserved for expanding if_index to an int in the future. Reviewed by: rwatson, brooks Notes: svn path=/head/; revision=199975
* Revert revision 199201 for now as it has introduced a kernel vulnerabilityXin LI2009-11-121-41/+0
| | | | | | | and requires more polishing. Notes: svn path=/head/; revision=199231
* Add interface description capability as inspired by OpenBSD.Xin LI2009-11-111-0/+41
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=199201
* A wrong variable is used when setting up the interfaceQing Li2009-09-201-2/+2
| | | | | | | | | | | | address route, which broke source address selection in some code paths. Submitted by: noted by bz Reviewed by: hrs MFC after: immediately Notes: svn path=/head/; revision=197364
* Self pointing routes are installed for configured interface addressesQing Li2009-09-151-0/+53
| | | | | | | | | | | | | and address aliases. After an interface is brought down and brought back up again, those self pointing routes disappeared. This patch ensures after an interface is brought back up, the loopback routes are reinstalled properly. Reviewed by: bz MFC after: immediately Notes: svn path=/head/; revision=197227
* Add IFNET_HOLD reserved pointer value for the ifindex ifnet array,Robert Watson2009-08-261-13/+39
| | | | | | | | | | | | | | | | | which allows an index to be reserved for an ifnet without making the ifnet available for management operations. Use this in if_alloc() while the ifnet lock is released between initial index allocation and completion of ifnet initialization. Add ifindex_free() to centralize the implementation of releasing an ifindex value. Use in if_free() and if_vmove(), as well as when releasing a held index in if_alloc(). Reviewed by: bz MFC after: 3 days Notes: svn path=/head/; revision=196559
* Break out allocation of new ifindex values from if_alloc() and if_vmove(),Robert Watson2009-08-251-34/+42
| | | | | | | | | | | | and centralize in a single function ifindex_alloc(). Assert the IFNET_WLOCK, and add missing IFNET_WLOCK in if_alloc(). This does not close all known races in this code. Reviewed by: bz MFC after: 3 days Notes: svn path=/head/; revision=196553