summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a bug in IPv4 address configuration exposed by refcounting.bms2007-03-291-13/+40
| | | | | | | | | | | | | | | | * Join the IPv4 all-hosts multicast group 224.0.0.1 once only; that is, when an IPv4 address is first configured on an interface. * Do not join it for subsequent IPv4 addresses as this violates IGMP. * Be sure to leave the group when all IPv4 addresses have been removed from the interface. * Add two DIAGNOSTIC printfs related to the issue. Further care and attention is needed in this area; it is suggested that netinet's attachment to the ifnet structure be compartmentalized and non-implicit. Bug found by: andre MFC after: 1 month
* Implement reference counting for ifmultiaddr, in_multi, and in6_multibms2007-03-201-74/+114
| | | | | | | | | | | | | | | | | | | structures. Detect when ifnet instances are detached from the network stack and perform appropriate cleanup to prevent memory leaks. This has been implemented in such a way as to be backwards ABI compatible. Kernel consumers are changed to use if_delmulti_ifma(); in_delmulti() is unable to detect interface removal by design, as it performs searches on structures which are removed with the interface. With this architectural change, the panics FreeBSD users have experienced with carp and pfsync should be resolved. Obtained from: p4 branch bms_netdev Reviewed by: andre Sponsored by: Garance A Drosehn Idea from: NetBSD MFC after: 1 month
* In regular forwarding path, reject packets destined for 169.254.0.0/16bms2007-02-031-1/+1
| | | | link-local addresses. See RFC 3927 section 2.7.
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningrwatson2006-11-061-7/+29
| | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
* The IPv4 code should clean up multicast group state when an interfacebms2006-09-281-2/+31
| | | | | | | | | | | | goes away. Without this change, it leaks in_multi (and often ether_multi state) if many clonable interfaces are created and destroyed in quick succession. The concept of this fix is borrowed from KAME. Detailed information about this behaviour, as well as test cases, are available in the PR. PR: kern/78227 MFC after: 1 week
* In in_control() remove the temporary in_ifaddr structure from theandre2006-01-241-1/+2
| | | | | | | | | ia_hash only if it actually is an AF_INET address. All other places test for sa_family == AF_INET but this one. PR: kern/92091 Submitted by: Seth Kingsley <sethk-at-meowfishies.com> MFC after: 3 days
* First fill in structure with valid values, and only then attach itglebius2005-10-281-2/+2
| | | | | | to the global list. Reviewed by: rwatson
* In in_addprefix() compare not only route addresses, but their masks,glebius2005-10-221-8/+13
| | | | | | | | too. This fixes problem when connected prefixes overlap. Obtained from: OpenBSD (rev. 1.40 by claudio); [ I came to this fix myself, and then found out that OpenBSD had already fixed it the same way.]
* Unlock Giant symmetrically with respect to lock acquire order as that'srwatson2005-10-031-1/+1
| | | | | | | generally nicer. Spotted by: johan MFC after: 1 week
* Acquire Giant conditionally in in_addmulti() and in_delmulti() based onrwatson2005-10-031-0/+9
| | | | | | | | | | | whether the interface being accessed is IFF_NEEDSGIANT or not. This avoids lock order reversals when calling into the interface ioctl handler, which could potentially lead to deadlock. The long term solution is to eliminate non-MPSAFE network drivers. Discussed with: jhb MFC after: 1 week
* Take a first cut at cleaning up ifnet removal and multicast socketrwatson2005-09-181-8/+12
| | | | | | | | | | | | | | | | | | | | | | | panics, which occur when stale ifnet pointers are left in struct moptions hung off of inpcbs: - Add in_ifdetach(), which matches in6_ifdetach(), and allows the protocol to perform early tear-down on the interface early in if_detach(). - Annotate that if_detach() needs careful consideration. - Remove calls to in_pcbpurgeif0() in the handling of SIOCDIFADDR -- this is not the place to detect interface removal! This also removes what is basically a nasty (and now unnecessary) hack. - Invoke in_pcbpurgeif0() from in_ifdetach(), in both raw and UDP IPv4 sockets. It is now possible to run the msocket_ifnet_remove regression test using HEAD without panicking. MFC after: 3 days
* In order to support CARP interfaces kernel was taught to handle moreglebius2005-08-181-2/+12
| | | | | | | | | | | | | than one interface in one subnet. However, some userland apps rely on the believe that this configuration is impossible. Add a sysctl switch net.inet.ip.same_prefix_carp_only. If the switch is on, then kernel will refuse to add an additional interface to already connected subnet unless the interface is CARP. Default value is off. PR: bin/82306 In collaboration with: mlaier
* Introduce in_multi_mtx, which will protect IPv4-layer multicast addressrwatson2005-08-031-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | lists, as well as accessor macros. For now, this is a recursive mutex due code sequences where IPv4 multicast calls into IGMP calls into ip_output(), which then tests for a multicast forwarding case. For support macros in in_var.h to check multicast address lists, assert that in_multi_mtx is held. Acquire in_multi_mtx around iteration over the IPv4 multicast address lists, such as in ip_input() and ip_output(). Acquire in_multi_mtx when manipulating the IPv4 layer multicast addresses, as well as over the manipulation of ifnet multicast address lists in order to keep the two layers in sync. Lock down accesses to IPv4 multicast addresses in IGMP, or assert the lock when performing IGMP join/leave events. Eliminate spl's associated with IPv4 multicast addresses, portions of IGMP that weren't previously expunged by IGMP locking. Add in_multi_mtx, igmp_mtx, and if_addr_mtx lock order to hard-coded lock order in WITNESS, in that order. Problem reported by: Ed Maste <emaste at phaedrus dot sandvine dot ca> MFC after: 10 days
* Use IFF_LOCKGIANT/IFF_UNLOCKGIANT around calls to the interfaceiedowse2005-06-021-14/+26
| | | | | | if_ioctl routine. This should fix a number of code paths through soo_ioctl() that could call into Giant-locked network drivers without first acquiring Giant.
* ifma_protospec is a pointer. Use NULL when assigning or compating it.glebius2005-03-201-2/+2
|
* Remove a workaround from previos revision. It proved to be incorrect.glebius2005-03-201-7/+16
| | | | | | | | Add two another workarounds for carp(4) interfaces: - do not add connected route when address is assigned to carp(4) interface - do not add connected route when other interface goes down Embrace workarounds with #ifdef DEV_CARP
* Add antifootshooting workaround, which will make all routes "connected"glebius2005-03-101-0/+6
| | | | | to carp(4) interfaces host routes. This prevents a problem, when connected network is routed to carp(4) interface.
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* Fix host route addition for more than one address to a loopback interfacemlaier2004-11-171-1/+1
| | | | | | | | after allowing more than one address with the same prefix. Reported by: Vladimir Grebenschikov <vova NO fbsd SPAM ru> Submitted by: ru (also NetBSD rev. 1.83) Pointyhat to: mlaier
* Merge copyright notices.mlaier2004-11-131-28/+1
| | | | Requested by: njl
* Change the way we automatically add prefix routes when adding a new address.mlaier2004-11-121-27/+147
| | | | | | | | | | | | | | | | This makes it possible to have more than one address with the same prefix. The first address added is used for the route. On deletion of an address with IFA_ROUTE set, we try to find a "fallback" address and hand over the route if possible. I plan to MFC this in 4 weeks, hence I keep the - now obsolete - argument to in_ifscrub as it must be considered KAPI as it is not static in in.c. I will clean this after the MFC. Discussed on: arch, net Tested by: many testers of the CARP patches Nits from: ru, Andrea Campi <andrea+freebsd_arch webcom it> Obtained from: WIDE via OpenBSD MFC after: 1 month
* White space cleanup for netinet before branch:rwatson2004-08-161-3/+3
| | | | | | | | | | | - Trailing tab/space cleanup - Remove spurious spaces between or before tabs This change avoids touching files that Andre likely has in his working set for PFIL hooks changes for IPFW/DUMMYNET. Approved by: re (scottl) Submitted by: Xin LI <delphij@frontfree.net>
* Add the function in_localip() which returns 1 if an internet address is forandre2004-08-111-0/+17
| | | | the local host and configured on one of its interfaces.
* Remove advertising clause from University of California Regent'simp2004-04-071-4/+0
| | | | | | | license, per letter dated July 22, 1999 and email from Peter Wemm, Alan Cox and Robert Watson. Approved by: core, peter, alc, rwatson
* Bring eventhandler callbacks for pf.mlaier2004-02-261-0/+5
| | | | | | | | This enables pf to track dynamic address changes on interfaces (dailup) with the "on (<ifname>)"-syntax. This also brings hooks in anticipation of tracking cloned interfaces, which will be in future versions of pf. Approved by: bms(mentor)
* Document the net.inet.ip.subnets_are_local sysctl.ru2003-12-301-1/+1
|
* Correct rev 1.56 which (incorrectly) reversed the test used tosam2003-11-031-1/+1
| | | | | | decide if in_pcbpurgeif0 should be invoked. Supported by: FreeBSD Foundation
* Back out M_* changes, per decision of the TRB.imp2003-02-191-2/+2
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-2/+2
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Lock up ifaddr reference counts.hsu2002-12-181-3/+5
|
* Remove unused and incorrectly maintained variable "in_interfaces"phk2002-12-171-4/+0
|
* fixed a kernel crash by "ifconfig stf0 inet 1.2.3.4"suz2002-10-221-5/+9
| | | | MFC after: 1 week
* Lock up inpcb.hsu2002-06-101-2/+2
| | | | Submitted by: Jennifer Yang <yangjihui@yahoo.com>
* Remove the code that masks an EEXIST returned from rtinit() whenbrian2002-04-101-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | calling ioctl(SIOC[AS]IFADDR). This allows the following: ifconfig xx0 inet 1.2.3.1 netmask 0xffffff00 ifconfig xx0 inet 1.2.3.17 netmask 0xfffffff0 alias ifconfig xx0 inet 1.2.3.25 netmask 0xfffffff8 alias ifconfig xx0 inet 1.2.3.26 netmask 0xffffffff alias but would (given the above) reject this: ifconfig xx0 inet 1.2.3.27 netmask 0xfffffff8 alias due to the conflicting netmasks. I would assert that it's wrong to mask the EEXIST returned from rtinit() as in the above scenario, the deletion of the 1.2.3.25 address will leave the 1.2.3.27 address as unroutable as it was in the first place. Offered for review on: -arch, -net Discussed with: stephen macmanus <stephenm@bayarea.net> MFC after: 3 weeks
* Don't add host routes for interface addresses of 0.0.0.0/8 -> 0.255.255.255.brian2002-04-101-6/+18
| | | | | | | | | | This change allows bootp to work with more than one interface, at the expense of some rather ``wrong'' looking code. I plan to MFC this in place of luigi's recent #ifdef BOOTP stuff that was committed to this file in -stable, as that's slightly more wrong that this is. Offered for review on: -arch, -net MFC after: 2 weeks
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-3/+3
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Remove __P.alfred2002-03-191-8/+8
|
* During SIOCAIFADDR, if in_ifinit() fails and we've already added anbrian2001-11-301-24/+39
| | | | | | | | | | interface address, blow the address away again before returning the error. In in_ifinit(), if we get an error from rtinit() and we've also got a destination address, return the error rather than masking EEXISTS. Failing to create a host route when configuring an interface should be treated as an error.
* Make sure the netmask always has an address family. This fixes Linuxdes2001-10-301-3/+4
| | | | | | | | | ifconfig, which expects the address returned by the SIOCGIFNETMASK ioctl to have a valid sa_family. Similar changes may be necessary for IPv6. While we're here, get rid of an unnecessary temp variable. MFC after: 2 weeks
* in_ifinit apparently can be used to rewrite an ip address; recalculatejlemon2001-10-011-1/+5
| | | | | | the correct hash bucket for the entry. Submitted by: iedowse (with some munging by me)
* Add a hash table that contains the list of internet addresses, and usejlemon2001-09-291-13/+19
| | | | | this in place of the in_ifaddr list when appropriate. This improves performance on hosts which have a large number of IP aliases.
* KSE Milestone 2julian2001-09-121-11/+11
| | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha
* Wrap array accesses in macros, which also happen to be lvalues:jlemon2001-09-061-1/+1
| | | | | | | ifnet_addrs[i - 1] -> ifaddr_byindex(i) ifindex2ifnet[i] -> ifnet_byindex(i) This is intended to ease the conversion to SMPng.
* When running aplication joined multicast address,ume2001-08-041-0/+12
| | | | | | | | | | | | | | removing network card, and kill aplication. imo_membership[].inm_ifp refer interface pointer after removing interface. When kill aplication, release socket,and imo_membership. imo_membership use already not exist interface pointer. Then, kernel panic. PR: 29345 Submitted by: Inoue Yuichi <inoue@nd.net.fujitsu.co.jp> Obtained from: KAME MFC after: 3 days
* Sync with recent KAME.ume2001-06-111-20/+3
| | | | | | | | | | | | | | | | | | This work was based on kame-20010528-freebsd43-snap.tgz and some critical problem after the snap was out were fixed. There are many many changes since last KAME merge. TODO: - The definitions of SADB_* in sys/net/pfkeyv2.h are still different from RFC2407/IANA assignment because of binary compatibility issue. It should be fixed under 5-CURRENT. - ip6po_m member of struct ip6_pktopts is no longer used. But, it is still there because of binary compatibility issue. It should be removed under 5-CURRENT. Reviewed by: itojun Obtained from: KAME MFC after: 3 weeks
* In in_ifadown(), differentiate between whether the interface goesru2001-05-111-1/+1
| | | | | | | down or interface address is deleted. Only delete static routes in the latter case. Reported by: Alexander Leidinger <Alexander@leidinger.net>
* <sys/queue.h> makeover.phk2001-03-161-6/+3
|
* net/route.c:ru2001-03-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A route generated from an RTF_CLONING route had the RTF_WASCLONED flag set but did not have a reference to the parent route, as documented in the rtentry(9) manpage. This prevented such routes from being deleted when their parent route is deleted. Now, for example, if you delete an IP address from a network interface, all ARP entries that were cloned from this interface route are flushed. This also has an impact on netstat(1) output. Previously, dynamically created ARP cache entries (RTF_STATIC flag is unset) were displayed as part of the routing table display (-r). Now, they are only printed if the -a option is given. netinet/in.c, netinet/in_rmx.c: When address is removed from an interface, also delete all routes that point to this interface and address. Previously, for example, if you changed the address on an interface, outgoing IP datagrams might still use the old address. The only solution was to delete and re-add some routes. (The problem is easily observed with the route(8) command.) Note, that if the socket was already bound to the local address before this address is removed, new datagrams generated from this socket will still be sent from the old address. PR: kern/20785, kern/21914 Reviewed by: wollman (the idea)
* Another round of the <sys/queue.h> FOREACH transmogriffer.phk2001-02-041-2/+1
| | | | | Created with: sed(1) Reviewed by: md5(1)
* Mechanical change to use <sys/queue.h> macro API instead ofphk2001-02-041-9/+9
| | | | | | | fondling implementation details. Created with: sed(1) Reviewed by: md5(1)
OpenPOWER on IntegriCloud