4726 Commits

Author SHA1 Message Date
bz
f8953220b8 MFC r266619:
syncache_lookup() is a file local function.  Make it static and
 take it out of the public KPI; seems it was never used elsewhere.
2014-08-16 14:03:00 +00:00
bz
a0d3819845 MFC r266618:
Make tcp_twrespond() file local private;  this removes it from the
 public KPI; it is not used anywhere else and seems it never was.
2014-08-16 13:58:45 +00:00
bz
dd062e6c84 MFC r266597:
Remove the prototypes for things that are no longer file local but were
 moved to the header file.

 Was suppoed to be MFCed with: r266596
 Pointy hat to:	bz
2014-08-16 13:53:05 +00:00
bz
6f5b0b94bc MFC r266596:
Move the tcp_fields_to_host() and tcp_fields_to_net() (inline)
 functions to the tcp_var.h header file in order to avoid further
 duplication with upcoming commits.

 Reviewed by:	np
2014-08-16 13:50:15 +00:00
np
334efdc74b MFC r268450 (by glebius). The leak affects stable/10 too.
In several cases in ip_output() we obtain reference on ifa. Do not
leak it.
2014-07-21 20:38:21 +00:00
delphij
7642e9504a Fix kernel memory disclosure in control message and SCTP notifications.
Security:	FreeBSD-SA-14:17.kmem
Security:	CVE-2014-3952, CVE-2014-3953
2014-07-08 21:54:50 +00:00
tuexen
08c9939204 MFC r267688:
Fix a bug which incorrectly allowed two listening SCTP sockets on
the same port bound to the wildcard address.
2014-06-23 07:58:41 +00:00
tuexen
ba54ed0f05 MFC r267682:
Fix a bug in the setsockopt()-handling of the SCTP
specific option SCTP_PEER_ADDR_THLDS: Use the
provided address as intended.
2014-06-23 07:56:39 +00:00
tuexen
41ae4ee23b MFC r267674:
Honor jails for unbound SCTP sockets when selecting source addresses,
reporting IP-addresses to the peer during the handshake, adding
addresses to the host, reporting the addresses via the sysctl
interface (used by netstat, for example) and reporting the
addresses to the application via socket options.
This issue was reported by Bernd Walter.
2014-06-23 07:54:12 +00:00
tuexen
7225abb45f MFC r267105:
Use ENOBUFS instead of ENOMEM in error situations related to m_uiotombuf().
This was suggested by kevlo@.
2014-06-22 16:57:07 +00:00
tuexen
43d8b12efc MFC r265691:
For some UDP packets (for example with 200 byte payload) and IP options,
the IP header and the UDP header are not in the same mbuf.
Add code to in_delayed_cksum() to deal with this case.

MFC r265713:

Use KASSERTs as suggested by glebius@
2014-06-22 16:54:59 +00:00
tuexen
e27908d03e MFC r265455:
Remove unused code. This is triggered by the bugreport of Sylvestre Ledru
which deal with useless code in the user land stack:
https://bugzilla.mozilla.org/show_bug.cgi?id=1003929
2014-06-22 16:50:46 +00:00
tuexen
08bf577274 MFC r264838:
Don't free an mbuf twice. This only happens in very rare error
cases where the peer sends illegal sequencing information in
DATA chunks for an existing association.
2014-06-22 16:45:42 +00:00
tuexen
d6a02f0073 MFC r264704:
Add consistency checks to ensure that fragments of a user message
have the same U-bit.
2014-06-22 16:43:59 +00:00
tuexen
51d3c53b6e MFC r264701:
Send also a packet containing an ABORT chunk in response to an OOTB packet
containing a COOKIE-ECHO chunk.
2014-06-22 16:42:09 +00:00
tuexen
d64d9d1bce MFC r264682:
Use consistently debug output instead of an unconditional printf.
2014-06-22 16:40:36 +00:00
tuexen
d5831ca68c MFC r264679:
Send the correct error cause, when a DATA chunk with no user data
is received. This bug was reported by Irene Ruengeler.
2014-06-22 16:38:06 +00:00
tuexen
de3cc21706 MFC r264017:
Increment the SSN only after processing the last fragment of an
ordered user message.
2014-06-22 16:34:27 +00:00
tuexen
1831342aca MFC r263922:
Handle an edge case of address management similar to TCP.
This needs to be reconsidered when the address handling
will be reimplemented.
The patch is from rrs@.
2014-06-22 16:32:41 +00:00
tuexen
39c4d67449 MFC r263921:
Use SCTP_OVER_UDP_TUNNELING_PORT more consistently.
2014-06-22 16:30:52 +00:00
tuexen
bfa185cf87 MFC r263237:
* Provide information in error causes in ASCII instead of
  proprietary binary format.
* Add support for a diagnostic information error cause.
  The code is sysctlable and the default is 0, which
  means it is not sent.

This is joint work with rrs@.
2014-06-22 16:28:52 +00:00
tuexen
23098a703a MFC r263096:
Put the offset of the CRC32C in csum_data instead of 0.
The virtio driver needs the offset to be stored in csum_data,
like in the case for UDP and TCP.

The virtio problem was reported by
Niu Zhixiong <kaiaixi@gmail.com>, who helped in debugging
and testing the patch.
2014-06-22 16:26:16 +00:00
tuexen
c9ffc26041 MFC r263094:
SCTP uses CRC32C and not Adler anymore. While there change the reference
to RFC 4960.
This does not change any code, just comments.
2014-06-22 16:22:44 +00:00
tuexen
c6eec1dbae MFC r262252:
Remove redundant code and fix a style error.
2014-06-22 16:21:14 +00:00
asomers
218f93e5f8 MFC changes related to PR kern/189089. Unlike CURRENT, stable/10 does not
panic when you attempt to remove the IP address.  But it still fails to
remove the address.

MFC r265094

Add regression test for PR kern/189088.

MFC r265092

Fix a panic when removing an IP address from an interface, if the same
address exists on another interface.  The panic was introduced by change
264887, which changed the fibnum parameter in the call to rtalloc1_fib() in
ifa_switch_loopback_route() from RT_DEFAULT_FIB to RT_ALL_FIBS.  The
solution is to use the interface fib in that call.  For the majority of
users, that will be equivalent to the legacy behavior.
2014-06-06 22:14:25 +00:00
asomers
322a1ee4a0 MFC r264887
Fix host and network routes for new interfaces when net.add_addr_allfibs=0

sys/net/route.c
        In rtinit1, use the interface fib instead of the process fib.  The
        latter wasn't very useful because ifconfig(8) is usually invoked
        with the default process fib.  Changing ifconfig(8) to use setfib(2)
        would be redundant, because it already sets the interface fib.

tests/sys/netinet/fibs_test.sh
        Clear the expected ATF failure

sys/net/if.c
        Pass the interface fib in calls to rtrequest1_fib and rtalloc1_fib

sys/netinet/in.c
sys/net/if_var.h
        Add a fibnum argument to ifa_switch_loopback_route, a subroutine of
        in_scrubprefix.  Pass it the interface fib.
2014-06-06 21:45:14 +00:00
asomers
a8aa481895 MFC changes relating to running multiple interfaces on different fibs but
with addresses on the same subnet.

MFC r266860

Fix unintended KBI change from r264905.  Add _fib versions of
ifa_ifwithnet() and ifa_ifwithdstaddr()  The legacy functions will call the
_fib() versions with RT_ALL_FIBS, preserving legacy behavior.

sys/net/if_var.h
sys/net/if.c
        Add legacy-compatible functions as described above.  Ensure legacy
        behavior when RT_ALL_FIBS is passed as fibnum.

sys/netinet/in_pcb.c
sys/netinet/ip_output.c
sys/netinet/ip_options.c
sys/net/route.c
sys/net/rtsock.c
sys/netinet6/nd6.c
        Call with _fib() functions if we must use a specific fib, or the
        legacy functions otherwise.

tests/sys/netinet/fibs_test.sh
tests/sys/netinet/udp_dontroute.c
        Improve the udp_dontroute test.  The bug that this test exercises is
        that ifa_ifwithnet() will return the wrong address, if multiple
        interfaces have addresses on the same subnet but with different
        fibs.  The previous version of the test only considered one possible
        failure mode: that ifa_ifwithnet_fib() might fail to find any
        suitable address at all.  The new version also checks whether
        ifa_ifwithnet_fib() finds the correct address by checking where the
        ARP request goes.

MFC r264917

Style fixes, mostly trailing whitespace elimination.  No functional change.

MFC r264905

Fix subnet and default routes on different FIBs on the same subnet.

These two bugs are closely related.  The root cause is that ifa_ifwithnet
does not consider FIBs when searching for an interface address.

sys/net/if_var.h
sys/net/if.c
        Add a fib argument to ifa_ifwithnet and ifa_ifwithdstadddr.  Those
        functions will only return an address whose interface fib equals the
        argument.

sys/net/route.c
        Update calls to ifa_ifwithnet and ifa_ifwithdstaddr with fib
        arguments.

sys/netinet/in.c
        Update in_addprefix to consider the interface fib when adding
        prefixes.  This will prevent it from not adding a subnet route when
        one already exists on a different fib.

sys/net/rtsock.c
sys/netinet/in_pcb.c
sys/netinet/ip_output.c
sys/netinet/ip_options.c
sys/netinet6/nd6.c
        Add RT_DEFAULT_FIB arguments to ifa_ifwithdstaddr and ifa_ifwithnet.
        In some cases it there wasn't a clear specific fib number to use.
        In others, I was unable to test those functions so I chose
        RT_DEFAULT_FIB to minimize divergence from current behavior.  I will
        fix some of the latter changes along with PR kern/187553.

tests/sys/netinet/fibs_test.sh
tests/sys/netinet/udp_dontroute.c
tests/sys/netinet/Makefile
        Revert r263738.  The udp_dontroute test was right all along.
        However, bugs kern/187550 and kern/187553 cancelled each other out
        when it came to this test.  Because of kern/187553, ifa_ifwithnet
        searched the default fib instead of the requested one, but because
        of kern/187550, there was an applicable subnet route on the default
        fib.  The new test added in r263738 doesn't work right, however.  I
        can verify with dtrace that ifa_ifwithnet returned the wrong address
        before I applied this commit, but route(8) miraculously found the
        correct interface to use anyway.  I don't know how.

        Clear expected failure messages for kern/187550 and kern/187552.

MFC r263738

tests/sys/netinet/Makefile
tests/sys/netinet/fibs.sh
        Replace fibs:udp_dontroute with fibs:src_addr_selection_by_subnet.
        The original test was poorly written; it was actually testing
        kern/167947 instead of the desired kern/187553.  The root cause of the
        bug is that ifa_ifwithnet did not have a fib argument.  The new test
        more directly targets that behavior.

tests/sys/netinet/udp_dontroute.c
        Delete the auxilliary binary used by the old test
2014-06-06 20:35:40 +00:00
asomers
a03c4d3869 MFC r263779
Correct ARP update handling when the routes for network interfaces are
restricted to a single FIB in a multifib system.

Restricting an interface's routes to the FIB to which it is assigned (by
setting net.add_addr_allfibs=0) causes ARP updates to fail with "arpresolve:
can't allocate llinfo for x.x.x.x".  This is due to the ARP update code hard
coding it's lookup for existing routing entries to FIB 0.

sys/netinet/in.c:
	When dealing with RTM_ADD (add route) requests for an interface, use
	the interface's assigned FIB instead of the default (FIB 0).

sys/netinet/if_ether.c:
	In arpresolve(), enhance error message generated when an
	lla_lookup() fails so that the interface causing the error is
	visible in logs.

tests/sys/netinet/fibs_test.sh
	Clear ATF expected error.
2014-06-06 17:42:55 +00:00
smh
873b20c0ff MFC r264879
Fix jailed raw sockets not setting the correct source address by
calling in_pcbladdr instead of prison_get_ip4.

Sponsored by:	Multiplay
2014-05-26 22:54:15 +00:00
yongari
9c37e88860 MFC r265942:
Fix checksum computation.  Previously it didn't include carry.
2014-05-16 05:05:53 +00:00
kevlo
69da76e9e5 MFC r264212,r264213,r264248,r265776,r265811,r265909:
- Add support for UDP-Lite protocol (RFC 3828) to IPv4 and IPv6 stacks.
  Tested with vlc and a test suite [1].
  [1] http://www.erg.abdn.ac.uk/~gerrit/udp-lite/files/udplite_linux.tar.gz

  Reviewed by:	jhb, glebius, adrian

- Fix a logic bug which prevented the sending of UDP packet with 0 checksum.

- Disable TX checksum offload for UDP-Lite completely. It wasn't used for
  partial checksum coverage, but even for full checksum coverage it doesn't
  work.
2014-05-13 06:05:53 +00:00
melifaro
aaa6b80bb3 Merge 260488, r260508.
r260488:
  Split rt_newaddrmsg_fib() into two different functions.
  Adding/deleting interface addresses involves access to 3 different subsystems,
  int different parts of code. Each call can fail, so reporting successful
  operation by rtsock in the middle of the process error-prone.

  Further split routing notification API and actual rtsock calls via creating
  public-available rt_addrmsg() / rt_routemsg() functions with "private"
  rtsock_* backend.

r260508:
  Simplify inet alias handling code: if we're adding/removing alias which
  has the same prefix as some other alias on the same interface, use
  newly-added rt_addrmsg() instead of hand-rolled in_addralias_rtmsg().

  This eliminates the following rtsock messages:

  Pinned RTM_ADD for prefix (for alias addition).
  Pinned RTM_DELETE for prefix (for alias withdrawal).

  Example (got 10.0.0.1/24 on vlan4, playing with 10.0.0.2/24):

  before commit, addition:

    got message of size 116 on Fri Jan 10 14:13:15 2014
    RTM_NEWADDR: address being added to iface: len 116, metric 0, flags:
    sockaddrs: <NETMASK,IFP,IFA,BRD>
     255.255.255.0 vlan4:8.0.27.c5.29.d4 10.0.0.2 10.0.0.255

    got message of size 192 on Fri Jan 10 14:13:15 2014
    RTM_ADD: Add Route: len 192, pid: 0, seq 0, errno 0, flags:<UP,PINNED>
    locks:  inits:
    sockaddrs: <DST,GATEWAY,NETMASK>
     10.0.0.0 10.0.0.2 (255) ffff ffff ff

  after commit, addition:

    got message of size 116 on Fri Jan 10 13:56:26 2014
    RTM_NEWADDR: address being added to iface: len 116, metric 0, flags:
    sockaddrs: <NETMASK,IFP,IFA,BRD>
     255.255.255.0 vlan4:8.0.27.c5.29.d4 14.0.0.2 14.0.0.255

  before commit, wihdrawal:

    got message of size 192 on Fri Jan 10 13:58:59 2014
    RTM_DELETE: Delete Route: len 192, pid: 0, seq 0, errno 0, flags:<UP,PINNED>
    locks:  inits:
    sockaddrs: <DST,GATEWAY,NETMASK>
     10.0.0.0 10.0.0.2 (255) ffff ffff ff

    got message of size 116 on Fri Jan 10 13:58:59 2014
    RTM_DELADDR: address being removed from iface: len 116, metric 0, flags:
    sockaddrs: <NETMASK,IFP,IFA,BRD>
     255.255.255.0 vlan4:8.0.27.c5.29.d4 10.0.0.2 10.0.0.255

  adter commit, withdrawal:

    got message of size 116 on Fri Jan 10 14:14:11 2014
    RTM_DELADDR: address being removed from iface: len 116, metric 0, flags:
    sockaddrs: <NETMASK,IFP,IFA,BRD>
     255.255.255.0 vlan4:8.0.27.c5.29.d4 10.0.0.2 10.0.0.255

  Sending both RTM_ADD/RTM_DELETE messages to rtsock is completely wrong
  (and requires some hacks to keep prefix in route table on RTM_DELETE).

  I've tested this change with quagga (no change) and bird (*).

  bird alias handling is already broken in *BSD sysdep code, so nothing
  changes here, too.

  I'm going to MFC this change if there will be no complains about behavior
  change.

  While here, fix some style(9) bugs introduced by r260488
  (pointed by glebius and bde).
2014-05-08 21:03:31 +00:00
rmacklem
d706690fda MFC: r264739
Add {} braces so that the code conforms to the indentation.
Fortunately, I don't think doing the assignment of cap->tsomax
unconditionally causes any problem.
2014-05-06 22:04:50 +00:00
delphij
acd7398463 Fix devfs rules not applied by default for jails.
Fix OpenSSL use-after-free vulnerability.

Fix TCP reassembly vulnerability.

Security:	FreeBSD-SA-14:07.devfs
Security:	CVE-2014-3001
Security:	FreeBSD-SA-14:08.tcp
Security:	CVE-2014-3000
Security:	FreeBSD-SA-14:09.openssl
Security:	CVE-2010-5298
2014-04-30 04:03:05 +00:00
ae
92efc4b623 MFC r263966:
Don't copy the MF flag from original IP header to ICMP error message.

PR:		188092
Sponsored by:	Yandex LLC
2014-04-07 12:50:08 +00:00
glebius
be0e4274f5 Merge r262341:
- Improve logging of send errors, reporting error code and interface.
  - Reduce code duplication between INET and INET6.
2014-04-04 10:33:59 +00:00
glebius
03fdc2934e Merge r262763, r262767, r262771, r262806 from head:
- Remove rt_metrics_lite and simply put its members into rtentry.
  - Use counter(9) for rt_pksent (former rt_rmx.rmx_pksent). This
    removes another cache trashing ++ from packet forwarding path.
  - Create zini/fini methods for the rtentry UMA zone. Via initialize
    mutex and counter in them.
  - Fix reporting of rmx_pksent to routing socket.
  - Fix netstat(1) to report "Use" both in kvm(3) and sysctl(3) mode.
2014-03-21 15:15:30 +00:00
glebius
73a339242d Merge r262747: remove extraneous ifa_ref()/ifa_free(). 2014-03-19 09:23:58 +00:00
glebius
ad70c4103e Merge r263091: fix mbuf flags clash that lead to failure of operation
of IPSEC and packet filters.

PR:		kern/185876
PR:		kern/186755
2014-03-18 16:56:05 +00:00
glebius
ed41469327 Merge r261582, r261601, r261610, r261613, r261627, r261640, r261641, r261823,
r261825, r261859, r261875, r261883, r261911, r262027, r262028, r262029,
      r262030, r262162 from head.

  Large flowtable revamp. See commit messages for merged revisions for
  details.

Sponsored by:	Netflix
2014-03-04 15:14:47 +00:00
glebius
352d508b16 Merge r261590: Fixup for r261590 (vnet sysctl handlers cleanup) 2014-03-04 14:05:37 +00:00
glebius
4b9e17c3ef Merge r261590, r261592 from head:
Remove identical vnet sysctl handlers, and handle CTLFLAG_VNET
  in the sysctl_root().

  Note: SYSCTL_VNET_* macros can be removed as well. All is
    needed to virtualize a sysctl oid is set CTLFLAG_VNET on it.
    But for now keep macros in place to avoid large code churn.
2014-03-04 14:01:12 +00:00
adrian
3ee8d78c97 MFC r260871:
If the flowid is available for the mbuf that finalised the creation
  of a syncache connection, copy it into the inp_flowid field.

  Without this, an incoming TCP connection won't have an inp_flowid marked
  until some data comes in, and this means that things like the per-CPU
  TCP timer option will choose a different CPU for the timer work.
  (It also means that if one grabbed the flowid via an ioctl from userland,
  it won't be available until some data has been received.)

Sponsored by:	Netflix, Inc.
2014-02-10 06:29:05 +00:00
ae
88938f44a0 MFC r260702 (by melifaro):
Fix ipfw fwd for IPv4 traffic broken by r249894.

  Problem case:
  Original lookup returns route with GW set, so gw points to
  rte->rt_gateway.
  After that we're changing dst and performing lookup another time.
  Since fwd host is most probably directly reachable, resulting
  rte does not contain rt_gateway, so gw is not set. Finally, we
  end with packet transmitted to proper interface but wrong
  link-layer address.
2014-02-06 10:48:55 +00:00
gnn
dbf0fc2c51 MFC 260796
Fix various places where we don't properly release a lock

PR:		185043
Submitted by:	Michael Bentkofsky
2014-02-03 03:31:35 +00:00
glebius
6e1079d8b4 Merge 261024: fix PIM input regression. 2014-01-27 09:33:30 +00:00
glebius
34e36d1706 Merge r257846:
Make TCP_KEEP* socket options readable. At least PostgreSQL wants
  to read the values.
2014-01-22 10:08:33 +00:00
avg
c1dbdbde60 MFC r258622: dtrace sdt: remove the ugly sname parameter of SDT_PROBE_DEFINE 2014-01-17 10:58:59 +00:00
avg
c2040a08a9 MFC r258605: Convert over the TCP probes to use mtod()
MFC slacker:	adrian
2014-01-17 10:48:44 +00:00
ae
65169ca8a0 MFC r260151 (by adrian):
Use an RLOCK here instead of an RWLOCK - matching all the other calls
  to lla_lookup().

  This drastically reduces the very high lock contention when doing parallel
  TCP throughput tests (> 1024 sockets) with IPv6.

MFC r260187:
  lla_lookup() does modification only when LLE_CREATE is specified.
  Thus we can use IF_AFDATA_RLOCK() instead of IF_AFDATA_LOCK() when doing
  lla_lookup() without LLE_CREATE flag.

MFC r260217:
  Add IF_AFDATA_WLOCK_ASSERT() in case lla_lookup() is called with
  LLE_CREATE flag.
2014-01-10 09:45:28 +00:00