summaryrefslogtreecommitdiff
path: root/sys/netinet
Commit message (Collapse)AuthorAgeFilesLines
* MFC r198418Qing Li2009-10-282-4/+4
| | | | | | | | | | Use the correct option name in the preprocessor command to enable or disable diagnostic messages. Reviewed by: ru Notes: svn path=/stable/8/; revision=198567
* MFC 198301Qing Li2009-10-201-9/+9
| | | | | | | | | | | | | | | | | In the ARP callout timer expiration function, the current time_second is compared against the entry expiration time value (that was set based on time_second) to check if the current time is larger than the set expiration time. Due to the +/- timer granularity value, the comparison returns false, causing the alternative code to be executed. The alternative code path freed the memory without removing that entry from the table list, causing a use-after-free bug. Reviewed by: discussed with kmacy Approved by: re Verified by: rnoland, yongari Notes: svn path=/stable/8/; revision=198308
* MFC r198111Qing Li2009-10-202-10/+18
| | | | | | | | | | | | | | | | | | | | This patch fixes the following issues in the ARP operation: 1. There is a regression issue in the ARP code. The incomplete ARP entry was timing out too quickly (1 second timeout), as such, a new entry is created each time arpresolve() is called. Therefore the maximum attempts made is always 1. Consequently the error code returned to the application is always 0. 2. Set the expiration of each incomplete entry to a 20-second lifetime. 3. Return "incomplete" entries to the application. 4. The return error code was incorrect. Reviewed by: kmacy Approved by: re Notes: svn path=/stable/8/; revision=198298
* Merge r198196 from head to stable/8:Robert Watson2009-10-201-3/+3
| | | | | | | | | Rewrap ip_input() comment so that it prints more nicely. Approved by: re (kib) Notes: svn path=/stable/8/; revision=198293
* MFC r197868.Michael Tuexen2009-10-141-2/+2
| | | | | | | | Use correct arguments when calling SCTP_RTALLOC(). Approved by: re, rrs (mentor) Notes: svn path=/stable/8/; revision=198088
* Merge r197814 from head to stable/8:Robert Watson2009-10-091-32/+2
| | | | | | | | | | | Remove tcp_input lock statistics; these are intended for debugging only and are not intended to ship in 8.0 as they dirty additional cache lines in a performance-critical per-packet path. Approved by: re (kib, bz) Notes: svn path=/stable/8/; revision=197895
* Merge r197795 from head to stable/8:Robert Watson2009-10-081-1/+4
| | | | | | | | | | | | | | | | | In tcp_input(), we acquire a global write lock at first only if a segment is likely to trigger a TCP state change (i.e., FIN/RST/SYN). If we later have to upgrade the lock, we acquire an inpcb reference and drop both global/inpcb locks before reacquiring in-order. In that gap, the connection may transition into TIMEWAIT, so we need to loop back and reevaluate the inpcb after relocking. Reported by: Kamigishi Rei <spambox at haruhiism.net> Reviewed by: bz Approved by: re (kib) Notes: svn path=/stable/8/; revision=197854
* MFC r197696Qing Li2009-10-061-0/+2
| | | | | | | | | | | | Remove a log message from production code. This log message can be triggered by a misconfigured host that is sending out gratuious ARPs. This log message can also be triggered during a network renumbering event when multiple prefixes co-exist on a single network segment. Approved by: re Notes: svn path=/stable/8/; revision=197813
* MFC 197695Qing Li2009-10-061-2/+2
| | | | | | | | | | | | | | | Previously, if an address alias is configured on an interface, and this address alias has a prefix matching that of another address configured on the same interface, then the ARP entry for the alias is not deleted from the ARP table when that address alias is removed. This patch fixes the aforementioned issue. PR: kern/139113 Reviewed by: bz Approved by: re Notes: svn path=/stable/8/; revision=197811
* MFC r197341.Michael Tuexen2009-09-281-6/+12
| | | | | | | | | Fix errnos. Approved by: re (bz), rrs (mentor) Notes: svn path=/stable/8/; revision=197582
* MFC revs 197129,197130,197132:Bruce M Simpson2009-09-171-17/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes to mcast userland API. -- Fix an API issue in leave processing for IPv4 multicast groups. * Do not assume that the group lookup performed by imo_match_group() is valid when ifp is NULL in this case. * Instead, return EADDRNOTAVAIL if the ifp cannot be resolved for the membership we are being asked to leave. Caveat user: * The way IPv4 multicast memberships are implemented in the inpcb layer at the moment, has the side-effect that struct ip_moptions will still hold the membership, under the old ifp, until ip_freemoptions() is called for the parent inpcb. * The underlying issue is: the inpcb layer does not get notification of ifp being detached going away in a thread-safe manner. This is non-trivial to fix. -- Fix an obvious logic error in the IPv4 multicast leave processing, where the filter mode vector was not updated correctly after the leave. -- Tighten input checking in inp_join_group(): * Don't try to use the source address, when its family is unspecified. * If we get a join without a source, on an existing inclusive mode group, this is an error, as it would change the filter mode. Fix a problem with the handling of in_mfilter for new memberships: * Do not rely on imf being NULL; it is explicitly initialized to a non-NULL pointer when constructing a membership. * Explicitly initialize *imf to EX mode when the source address is unspecified. This fixes a problem with in_mfilter slot recycling in the join path. -- Don't allow joins w/o source on an existing group. This is almost always pilot error. We don't need to check for group filter UNDEFINED state at t1, because we only ever allocate filters with their groups, so we unconditionally reject such calls with EINVAL. Trying to change the active filter mode w/o going through IP_MSFILTER is also disallowed. Deals with the case described in PR 137164 upfront, cumulative with the fix in svn rev 197132 which only calls imo_match_source() if the source address family was not unspecified. -- Revision 197136 has a text conflict, however it is a comment only change. PR: 137164, 138689, 138690, 138691 Submitted by: Stef Walter (with fixups) Approved by: re (kib) Notes: svn path=/stable/8/; revision=197280
* MFC 197257:Michael Tuexen2009-09-161-2/+7
| | | | | | | | | | | | Fix a bug reported by Daniel Mentz: When authenticating DATA chunks some DATA chunks might get stuck when the MTU gets decreased via an ICMP message. Approved by: re, rrs (mentor) Notes: svn path=/stable/8/; revision=197258
* Fixes two bugs:Michael Tuexen2009-09-161-1/+9
| | | | | | | | | | | | | | 1) A lock issue, if we ever had to try again we would double lock the INP lock. 2) We were allowing (at wrap) associd 0... which really we cannot allow since 0 normally means in most socket API calls that we are wishing to effect something on the INP not TCB. Approved by: re, rrs (mentor) Notes: svn path=/stable/8/; revision=197256
* MFC r197227Qing Li2009-09-152-37/+6
| | | | | | | | | | | | | | Self pointing routes are installed for configured interface addresses 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 Approved by: re Notes: svn path=/stable/8/; revision=197239
* MFC r197225Qing Li2009-09-151-46/+54
| | | | | | | | | | | This patch enables the node to respond to ARP requests for configured proxy ARP entries. Reviewed by: bz Approved by: re Notes: svn path=/stable/8/; revision=197238
* MFC r197210, 197212, 197235Qing Li2009-09-151-0/+11
| | | | | | | | | | | | | | | | | The bootp code installs an interface address and the nfs client module tries to install the same address again. This extra code is removed, which was discovered by the removal of a call to in_ifscrub() in r196714. This call to in_ifscrub is put back here because the SIOCAIFADDR command can be used to change the prefix length of an existing alias. r197235 reverts file nfs_vfsops.c Reviewed by: kmacy Approved by: re Notes: svn path=/stable/8/; revision=197237
* MFC r196714Qing Li2009-09-151-5/+48
| | | | | | | | | | | | | | | | | This patch fixes the following issues: - Routing messages are not generated when adding and removing interface address aliases. - Loopback route installed for an interface address alias is not deleted from the routing table when that address alias is removed from the associated interface. - Function in_ifscrub() is called extraneously. Reviewed by: gnn, kmacy, sam Approved by: re Notes: svn path=/stable/8/; revision=197231
* MFC r197203Qing Li2009-09-151-0/+2
| | | | | | | | | | | | | | | | Previously local end of point-to-point interface is not reachable within the system that owns the interface. Packets destined to the local end point leak to the wire towards the default gateway if one exists. This behavior is changed as part of the L2/L3 rewrite efforts. The local end point is now reachable within the system. The inpcb code needs to consider this fact during the address selection process. Reviewed by: bz Approved by: re Notes: svn path=/stable/8/; revision=197229
* MFC 196610:Michael Tuexen2009-09-121-0/+1
| | | | | | | | | Fix a bug where vlan interfaces are not supported by SCTP. Approved by: re, rrs (mentor) Notes: svn path=/stable/8/; revision=197125
* This fixes a bug where the value set by SCTP_PARTIAL_DELIVERY_POINTMichael Tuexen2009-09-121-3/+3
| | | | | | | | | | was not honored, if the socket buffer size was not 4 times that large. MFC of 196509. Approved by: re, rrs (mentor)` Notes: svn path=/stable/8/; revision=197122
* MFC r196932:Shteryana Shopova2009-09-111-3/+6
| | | | | | | | | | | | | | | When joining a multicast group, the inp_lookup_mcast_ifp call does a KASSERT that the group address is multicast, so the check if this is indeed true and eventually return a EINVAL if not, should be done before calling inp_lookup_mcast_ifp. This fixes a kernel crash when calling setsockopt (sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,...) with invalid group address. Reviewed by: bms Approved by: re (kib) Notes: svn path=/stable/8/; revision=197089
* MFC r196738:Bjoern A. Zeeb2009-09-021-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case an upper layer protocol tries to send a packet but the L2 code does not have the ethernet address for the destination within the broadcast domain in the table, we remember the original mbuf in `la_hold' in arpresolve() and send out a different packet with an arp request. In case there will be more upper layer packets to send we will free an earlier one held in `la_hold' and queue the new one. Once we get a packet in, with which we can perfect our arp table entry we send out the original 'on hold' packet, should there be any. Rather than continuing to process the packet that we received, we returned without freeing the packet that came in, which basically means that we leaked an mbuf for every arp request we sent. Rather than freeing the received packet and returning, continue to process the incoming arp packet as well. This should (a) improve some setups, also proxy-arp, in case it was an incoming arp request and (b) resembles the behaviour FreeBSD had from day 1, which alignes with RFC826 "Packet reception" (merge case). Rename 'm0' to 'hold' to make the code more understandable as well as diffable to earlier versions more easily. Handle the link-layer entry 'la' lock comepletely in the block where needed and release it as early as possible, rather than holding it longer, down to the end of the function. Found by: pointyhat, ns1 Bug hunting session with: erwin, simon, rwatson Tested by: simon on cluster machines Reviewed by: ratson, kmacy, julian Approved by: re (kib) Notes: svn path=/stable/8/; revision=196770
* MFC r196608Qing Li2009-08-301-3/+1
| | | | | | | | | | | | | Do not try to free the rt_lle entry of the cached route in ip_output() if the cached route was not initialized from the flow-table. The rt_lle entry is invalid unless it has been initialized through the flow-table. Reviewed by: kmacy, rwatson Approved by: re Notes: svn path=/stable/8/; revision=196672
* Merge r196535 from head to stable/8:Robert Watson2009-08-281-1/+1
| | | | | | | | | | | | | | Use locks specific to the lltable code, rather than borrow the ifnet list/index locks, to protect link layer address tables. This avoids lock order issues during interface teardown, but maintains the bug that sysctl copy routines may be called while a non-sleepable lock is held. Reviewed by: bz, kmacy, qingli Approved by: re (kib) Notes: svn path=/stable/8/; revision=196630
* Merge r196481 from head to stable/8:Robert Watson2009-08-281-6/+1
| | | | | | | | | | | | | | | | | | | Rework global locks for interface list and index management, correcting several critical bugs, including race conditions and lock order issues: Replace the single rwlock, ifnet_lock, with two locks, an rwlock and an sxlock. Either can be held to stablize the lists and indexes, but both are required to write. This allows the list to be held stable in both network interrupt contexts and sleepable user threads across sleeping memory allocations or device driver interactions. As before, writes to the interface list must occur from sleepable contexts. Reviewed by: bz, julian Approved by: re (kib) Notes: svn path=/stable/8/; revision=196626
* MFC r196502:Marko Zec2009-08-282-6/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a div_destroy() function which takes over per-vnet cleanup tasks from the existing modevent / MOD_UNLOAD handler, and register div_destroy() in protosw as per-vnet .pr_destroy() handler for options VIMAGE builds. In nooptions VIMAGE builds, div_destroy() will be invoked from the modevent handler, resulting in effectively identical operation as it was prior this change. div_destroy() also tears down hashtables used by ipdivert, which were previously left behind on ipdivert kldunloads. For options VIMAGE builds only, temporarily disable kldunloading of ipdivert, because without introducing additional locking logic it is impossible to atomically check whether all ipdivert instances in all vnets are idle, and proceed with cleanup without opening a race window for a vnet to open an ipdivert socket while ipdivert tear-down is in progress. While here, staticize div_init(), because it is not used outside of ip_divert.c. In cooperation with: julian Approved by: re (rwatson), julian (mentor) Approved by: re (rwatson) Notes: svn path=/stable/8/; revision=196621
* MFC r196423Julian Elischer2009-08-213-69/+123
| | | | | | | | | | | | | | | | | | | Fix ipfw's initialization functions to get the correct order of evaluation to allow vnet and non vnet operation. Move some functions from ip_fw_pfil.c to ip_fw2.c and mode to mostly using the SYSINIT and VNET_SYSINIT handlers instead of the modevent handler. Correct some spelling errors in comments in the affected code. Note this bug fixes a crash in NON VIMAGE kernels when ipfw is unloaded. This patch is a minimal patch for 8.0 I have a much larger patch that actually fixes the underlying problems that will be applied after 8.0 Reviewed by: zec@, rwatson@, bz@(earlier version) Approved by: re (rwatson) Notes: svn path=/stable/8/; revision=196424
* MFC rev 196410 - deal with 'ticks' going negative after 24 days of uptimePeter Wemm2009-08-201-1/+1
| | | | | | | | | with the default 1000hz clock in the timewait expiration code. Approved by: re (kensmith) Notes: svn path=/stable/8/; revision=196414
* MFC r196397 from head:Will Andrews2009-08-201-3/+3
| | | | | | | | | | | Fix CARP memory leaks on carp_if's malloc'd using M_CARP. This occurs when CARP tries to free them using M_IFADDR after the last address for a virtual host is removed and when detaching from the parent interface. Approved by: re (kib), ken (mentor) Notes: svn path=/stable/8/; revision=196398
* Fix a bug in the handling of unreliable messages whichMichael Tuexen2009-08-191-5/+9
| | | | | | | | | results in stalled associations. Approved by: re, rrs (mentor) Notes: svn path=/stable/8/; revision=196377
* MFC 196368Kip Macy2009-08-181-1/+1
| | | | | | | | | | | | | | | | | | | | | - change the interface to flowtable_lookup so that we don't rely on the mbuf for obtaining the fib index - check that a cached flow corresponds to the same fib index as the packet for which we are doing the lookup - at interface detach time flush any flows referencing stale rtentrys associated with the interface that is going away (fixes reported panics) - reduce the time between cleans in case the cleaner is running at the time the eventhandler is called and the wakeup is missed less time will elapse before the eventhandler returns - separate per-vnet initialization from global initialization (pointed out by jeli@) Reviewed by: sam@ Approved by: re@ Notes: svn path=/stable/8/; revision=196369
* Fix a panic when using one-to-one style sockets in non-blockingMichael Tuexen2009-08-181-1/+2
| | | | | | | | | mode and there is no listening server. PR: 137795 Approved by: re, rrs (mentor) Notes: svn path=/stable/8/; revision=196365
* MFC r196260.Michael Tuexen2009-08-157-99/+176
| | | | | | | | | | | | | | | | | | * Fix a bug where PR-SCTP settings are ignore when using implicit association setup. * Fix a bug where message with illegal stream ids are not deleted. * Fix a crash when reporting back unsent messages from the send_queue. * Fix a bug related to INIT retransmission when the socket is already closed. * Fix a bug where associations were stalled when partial delivery API was enabled. * Fix a bug where the receive buffer size was smaller than the partial_delivery_point. Approved by: re, rrs (mentor) Notes: svn path=/stable/8/; revision=196261
* MFC 196234Qing Li2009-08-151-1/+5
| | | | | | | | | | | | | | In function ip_output(), the cached route is flushed when there is a mismatch between the cached entry and the intended destination. The cached rtentry{} is flushed but the associated llentry{} is not. This causes the wrong destination MAC address being used in the output packets. The fix is to flush the llentry{} when rtentry{} is cleared. Reviewed by: kmacy, rwatson Approved by: re Notes: svn path=/stable/8/; revision=196235
* MFC r196229:Marko Zec2009-08-141-0/+4
| | | | | | | | | | | | | SCTP is not yet compatible with options VIMAGE kernels although it compiles with VIMAGE defined, so explicitly disallow building such kernels. Reviewed by: rrs Approved by: re (rwatson), julian (mentor) Approved by: re (rwatson) Notes: svn path=/stable/8/; revision=196232
* MFC of r196201Julian Elischer2009-08-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | URL: http://svn.freebsd.org/changeset/base/196201 Fix ipfw crash on uid or gid check. Receiving any ip packet for which there is no existing socket will crash if ipfw has a uid or gid test rule, as the uid/gid of the non existent owner of said non existent socket is tested. Brooks introduced this error as part of his >16 gids patch. It appears to be a cut-n-paste error from similar code a few lines before. The old code used the 'pcb' variable here, but in the new code that switched the 'inp' variable, which is often NULL and what is tested in the code further up. The rest of the multi-gid patch for ipfw seems solid (and cleaner than previous code). p.s. What's up with all the properties changing? It is a fresh checkout. Reviewed by: brooks Approved by: re (rwatson) Notes: svn path=/stable/8/; revision=196202
* Add padding to struct inpcb, missed during our padding sweep earlier inRobert Watson2009-08-021-1/+2
| | | | | | | | | the release cycle. Approved by: re (kensmith) Notes: svn path=/head/; revision=196041
* Many network stack subsystems use a single global data structure to holdRobert Watson2009-08-0211-8/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | all pertinent statatistics for the subsystem. These structures are sometimes "borrowed" by kernel modules that require a place to store statistics for similar events. Add KPI accessor functions for statistics structures referenced by kernel modules so that they no longer encode certain specifics of how the data structures are named and stored. This change is intended to make it easier to move to per-CPU network stats following 8.0-RELEASE. The following modules are affected by this change: if_bridge if_cxgb if_gif ip_mroute ipdivert pf In practice, most of these statistics consumers should, in fact, maintain their own statistics data structures rather than borrowing structures from the base network stack. However, that change is too agressive for this point in the release cycle. Reviewed by: bz Approved by: re (kib) Notes: svn path=/head/; revision=196039
* Merge the remainder of kern_vimage.c and vimage.h into vnet.c andRobert Watson2009-08-0134-34/+20
| | | | | | | | | | | | | vnet.h, we now use jails (rather than vimages) as the abstraction for virtualization management, and what remained was specific to virtual network stacks. Minor cleanups are done in the process, and comments updated to reflect these changes. Reviewed by: bz Approved by: re (vimage blanket) Notes: svn path=/head/; revision=196019
* Show interface name which received short CARP packet (e.g. a VRRP packet),Xin LI2009-07-301-2/+3
| | | | | | | | | | | in order to match other codepaths nearby. This makes troubleshooting easier. Approved by: re (kib) MFC after: 1 month Notes: svn path=/head/; revision=195976
* Startup the vnet part of initialization a bit after the global part.Julian Elischer2009-07-281-2/+2
| | | | | | | | | | | Fixes crash on boot if ipfw compiled in. Submitted by: tegge@ Reviewed by: tegge@ Approved by: re (kib) Notes: svn path=/head/; revision=195923
* Somewhere along the line accept sockets stopped honoring theJulian Elischer2009-07-282-4/+3
| | | | | | | | | | | FIB selected for them. Fix this. Reviewed by: ambrisko Approved by: re (kib) MFC after: 3 days Notes: svn path=/head/; revision=195922
* Fix a bug where wrong initialization valueMichael Tuexen2009-07-282-4/+4
| | | | | | | | | | in used for an SCTP specific sysctl variable. Approved by: re, rrs(mentor). MFC after: 2 weeks. Notes: svn path=/head/; revision=195919
* Turns out that when a receiver forwards through its TNS's theRandall Stewart2009-07-284-22/+40
| | | | | | | | | | | | | | | | | | processing code holds the read lock (when processing a FWD-TSN for pr-sctp). If it finds stranded data that can be given to the application, it calls sctp_add_to_readq(). The readq function also grabs this lock. So if INVAR is on we get a double recurse on a non-recursive lock and panic. This fix will change it so that readq() function gets a flag to tell if the lock is held, if so then it does not get the lock. Approved by: re@freebsd.org (Kostik Belousov) MFC after: 1 week Notes: svn path=/head/; revision=195918
* This patch does the following:Qing Li2009-07-272-5/+16
| | | | | | | | | | | | | | | | | - Allow loopback route to be installed for address assigned to interface of IFF_POINTOPOINT type. - Install loopback route for an IPv4 interface addreess when the "useloopback" sysctl variable is enabled. Similarly, install loopback route for an IPv6 interface address when the sysctl variable "nd6_useloopback" is enabled. Deleting loopback routes for interface addresses is unconditional in case these sysctl variables were disabled after an interface address has been assigned. Reviewed by: bz Approved by: re Notes: svn path=/head/; revision=195914
* Fix the handling of unordered messages when usingMichael Tuexen2009-07-271-1/+7
| | | | | | | | | | PR-SCTP. Approved by: re, rrs (mentor) MFC after: 3 weeks. Notes: svn path=/head/; revision=195906
* Get rid of unused field. This will also be deletedMichael Tuexen2009-07-271-1/+0
| | | | | | | | | in the official speciication of the SCTP socket API. Approved by:re, rrs (mentor) Notes: svn path=/head/; revision=195904
* Add a missing unlock for the inp lock whenMichael Tuexen2009-07-261-0/+1
| | | | | | | | | | returning early from sctp_add_to_readq(). Approved by: re, rrs (mentor) MFC after: 2 weeks. Notes: svn path=/head/; revision=195894
* Catch ipfw up to the rest of the vimage code.Julian Elischer2009-07-251-109/+163
| | | | | | | | | It got left behind when it moved to its new location. Approved by: re (kensmith) Notes: svn path=/head/; revision=195862
* Introduce and use a sysinit-based initialization scheme for virtualRobert Watson2009-07-232-41/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | network stacks, VNET_SYSINIT: - Add VNET_SYSINIT and VNET_SYSUNINIT macros to declare events that will occur each time a network stack is instantiated and destroyed. In the !VIMAGE case, these are simply mapped into regular SYSINIT/SYSUNINIT. For the VIMAGE case, we instead use SYSINIT's to track their order and properties on registration, using them for each vnet when created/ destroyed, or immediately on module load for already-started vnets. - Remove vnet_modinfo mechanism that existed to serve this purpose previously, as well as its dependency scheme: we now just use the SYSINIT ordering scheme. - Implement VNET_DOMAIN_SET() to allow protocol domains to declare that they want init functions to be called for each virtual network stack rather than just once at boot, compiling down to DOMAIN_SET() in the non-VIMAGE case. - Walk all virtualized kernel subsystems and make use of these instead of modinfo or DOMAIN_SET() for init/uninit events. In some cases, convert modular components from using modevent to using sysinit (where appropriate). In some cases, do minor rejuggling of SYSINIT ordering to make room for or better manage events. Portions submitted by: jhb (VNET_SYSINIT), bz (cleanup) Discussed with: jhb, bz, julian, zec Reviewed by: bz Approved by: re (VIMAGE blanket) Notes: svn path=/head/; revision=195837