Commit Graph

1337 Commits

Author SHA1 Message Date
sbruno
9b2228166d MFC r299829
Use Node Information flag names instead of hard-coding their values.
2016-07-28 20:11:34 +00:00
sbruno
562868062b MFC r296063 r297397 r299213
296063:
Lock the NDP default router list and count defrouter references.

This addresses a number of race conditions that can cause crashes as a
result of unsynchronized access to the list.

297397
Modify nd6_llinfo_timer() to acquire the nd6 lock before the LLE lock.

When expiring a neighbour cache entry we may need to look up the associated
default router, which requires the nd6 read lock. To avoid an LOR, the nd6
lock should be acquired first.

299213
Clean up callers of nd6_prelist_add().

nd6_prelist_add() sets *newp if and only if it is successful, so there's no
need for code that handles the case where the return value is 0 and
*newp == NULL. Fix some style bugs in nd6_prelist_add() while here.

Submitted by:	Jason Wolfe <j@nitrology.com>
2016-07-28 20:08:01 +00:00
markj
5cba75d7c7 MFC r295583, r295584, r295729, r295730:
NDP code cleanup changes.

MFC r295732:
Fix an IPv6 DAD reference count leak.
2016-05-05 23:06:39 +00:00
markj
78b62c1962 MFC r295575, r295576, r295578, r295579, r295580:
Various NDP cleanups. No functional change intended.
2016-05-03 23:46:01 +00:00
ae
8dd17d694b MFC r296984:
Change in6_selectsrc() to allow usage of non-local IPv6 addresses in
  IPV6_PKTINFO ancillary data when IPV6_BINDANY socket option is set.
2016-03-31 09:55:21 +00:00
tuexen
42508cdc2e MFC r295549:
Loopback addresses are 127.0.0.0/8, not 127.0.0.1/32.

MFC r295668:
Improve the teardown of the SCTP stack.

MFC r295670:
Whitespace changes.

MFC r295708:
Address a warning reported by D5245 / PVS.

MFC r295709:
Code cleanup which will silence a warning in PVS / D5245.

MFC r295710:
Add protection code for issues reported by PVS / D5245.

MFC r295771:
Fix reporting of mapped addressed in getpeername() and getsockname() for
IPv6 SCTP sockets.
This bugs were found because of an issue reported by PVS / D5245.

MFC r295772:
Add some protection code.

MFC r295773:
Add protection code.

MFC r295805:
Use the SCTP level pointer, not the interface level.

MFC r295929:
Don't leak an address in an error path.

Approved by: re (marius)
2016-02-25 18:46:06 +00:00
bz
3078b388e3 MFC r292601,292654:
Since r256624 (head) we have been leaking routing table allocations
  on vnet enabled jail shutdown. Call the provided cleanup
  routines for IP versions 4 and 6 to plug these leaks.

  Sponsored by:         The FreeBSD Foundation
  Reviewed by:          gnn
  Differential Revision:https://reviews.freebsd.org/D4530

Approved by:		re (gjb)
2016-02-08 00:07:01 +00:00
bz
e8ebbaf6da MFC 292953:
This code is not in modules that need KPI stability so no need to use
 the wrapper functions as used in r252511 (head).  We can directly use
 the locking macros.
2016-01-21 14:11:01 +00:00
tuexen
70ab0ed557 MFC r291904:
Fix the allocation of outgoing streams:
* When processing a cookie, use the number of
  streams announced in the INIT-ACK.
* When sending an INIT-ACK for an existing
  association, use the value from the association,
  not from the end-point.
2016-01-17 12:15:41 +00:00
tuexen
a07b11560a MFC r285877:
Move including netinet/icmp6.h around to avoid a problem when including
netinet/icmp6.h and net/netmap.h. Both use ni_flags...
This allows to build multistack with SCTP support.
2016-01-16 12:33:45 +00:00
glebius
924e9fd65e o Fix SCTP ICMPv6 error message vulnerability. [SA-16:01.sctp]
o Fix Linux compatibility layer incorrect futex handling. [SA-16:03.linux]
o Fix Linux compatibility layer setgroups(2) system call. [SA-16:04.linux]
o Fix TCP MD5 signature denial of service. [SA-16:05.tcp]
o Fix insecure default bsnmpd.conf permissions. [SA-16:06.bsnmpd]

Security:	FreeBSD-SA-16:01.sctp, CVE-2016-1879
Security:	FreeBSD-SA-16:03.linux, CVE-2016-1880
Security:	FreeBSD-SA-16:04.linux, CVE-2016-1881
Security:	FreeBSD-SA-16:05.tcp, CVE-2016-1882
Security:	FreeBSD-SA-16:06.bsnmpd, CVE-2015-5677
2016-01-14 09:11:42 +00:00
wollman
b52158b80d MFH r292836:
in6_if2idlen: treat bridge(4) interfaces like other Ethernet interfaces

    bridge(4) interfaces have an if_type of IFT_BRIDGE, rather than
    IFT_ETHER, even though they only support Ethernet-style links.  This
    caused in6_if2idlen to emit an "unknown link type (209)" warning to
    the console every time it was called.  Add IFT_BRIDGE to the case
    statement in the appropriate place, indicating that it uses the same
    IPv6 address format as other Ethernet-like interfaces.
2016-01-07 20:43:45 +00:00
kp
37c817149c MFC r292219:
inet6: Do not assume every interface has ip6 enabled.

Certain interfaces (e.g. pfsync0) do not have ip6 addresses (in other words,
ifp->if_afdata[AF_INET6] is NULL). Ensure we don't panic when the MTU is
updated.

pfsync interfaces will never have ip6 support, because it's explicitly disabled
in in6_domifattach().

PR:         205194
2015-12-21 20:29:55 +00:00
ae
0f5a92c989 Fix typo in r291986.
(this is derect commit to stable/10)
2015-12-08 07:31:26 +00:00
ae
44a32abb98 MFC r291578:
mld_v2_dispatch_general_query() is used by mld_fasttimo_vnet() to send
  a reply to the MLDv2 General Query. In case when router has a lot of
  multicast groups, the reply can take several packets due to MTU limitation.
  Also we have a limit MLD_MAX_RESPONSE_BURST == 4, that limits the number
  of packets we send in one shot. Then we recalculate the timer value and
  schedule the remaining packets for sending.
  The problem is that when we call mld_v2_dispatch_general_query() to send
  remaining packets, we queue new reply in the same mbuf queue. And when
  number of packets is bigger than MLD_MAX_RESPONSE_BURST, we get endless
  reply of MLDv2 reports.
  To fix this, add the check for remaining packets in the queue.

  PR:		204831
2015-12-08 07:26:16 +00:00
hrs
3fe8aea7a4 MFC r288600:
- Schedule DAD for IN6_IFF_TENTATIVE addresses in nd6_timer().  This
    catches cases that DAD probes cannot be sent because of
    IFF_UP && !IFF_DRV_RUNNING.

  - nd6_dad_starttimer() now calls nd6_dad_ns_output(), instead of
    calling it before nd6_dad_starttimer().

  - Do not release an entry in dadq when a duplicate entry is being
    added.
2015-11-04 01:00:42 +00:00
garga
7b9023e28a Remove extra space introduced in r287734. This is a stable/10 only fix
since original commit (r287094) is correct.

Approved by:	loos
Sponsored by:	Rubicon Communications (Netgate)
2015-09-22 14:33:43 +00:00
hrs
bc4a1ace90 MFC 287094:
- Deprecate IN6_IFF_NODAD.  It was used to prevent DAD on a loopback
  interface but in6if_do_dad() already had a check for IFF_LOOPBACK.

- Remove in6if_do_dad() check in in6_broadcast_ifa().  An address
  which needs DAD always has IN6_IFF_TENTATIVE there.

- in6if_do_dad() now returns EAGAIN when the interface is not ready
  since DAD callout handler ignores such an interface.

- In DAD callout handler, mark an address as IN6_IFF_TENTATIVE
  when the interface has ND6_IFF_IFDISABLED.  And Do IFF_UP and
  IFF_DRV_RUNNING check consistently when DAD is required.

- draft-ietf-6man-enhanced-dad is now published as RFC 7527.

- Fix some typos.
2015-09-13 02:09:06 +00:00
hrs
8de92fe779 MFC 287095, 287610, 287611, 287617:
Remove obsolete API (SIOCGDRLST_IN6 and SIOCGPRLST_IN6) support.
2015-09-13 01:59:50 +00:00
hrs
2f4beaf9e8 MFC 287609:
Do not add IN6_IFF_TENTATIVE when ND6_IFF_NO_DAD.
2015-09-13 01:44:30 +00:00
hrs
ec83826da7 MFC 287608:
Remove IN6_IFF_NOPFX.  This flag was no longer used.
2015-09-13 01:39:37 +00:00
ae
2cbf021408 MFC r285710:
Invoke LLE event handler when entry is deleted.
2015-08-05 11:24:40 +00:00
hrs
b037e0b55c MFC r282805:
- Remove ND6_IFF_IGNORELOOP.  This functionality was useless in practice
  because a link where looped back NS messages are permanently observed
  does not work with either NDP or ARP for IPv4.

- draft-ietf-6man-enhanced-dad is now RFC 7527.

Approved by:	re (gjb)
2015-07-23 19:58:56 +00:00
hrs
1bf10917ef MFC r273992:
Fix a bug which prevented ND6_IFF_IFDISABLED flag from clearing when
the newly-added IPv6 address was /128.

Approved by:	re (gjb)
2015-07-23 19:54:42 +00:00
tuexen
103d48d60e MFC r284515:
Add FIB support for SCTP.
This fixes https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=200379

PR:	200379
2015-06-20 08:25:27 +00:00
kp
1af840c38e Merge r281234
Evaluate packet size after the firewall had its chance

Defer the packet size check until after the firewall has had a look at it. This
means that the firewall now has the opportunity to (re-)fragment an oversized
packet.

Differential Revision:	https://reviews.freebsd.org/D2821
Reviewed by:	gnn
2015-06-18 20:57:21 +00:00
kp
801d5721d1 Merge r281165
Remove duplicate code

We'll just fall into the same local delivery block under the
'if (m->m_flags & M_FASTFWD_OURS)'.

Suggested by:       ae
Differential Revision:	https://reviews.freebsd.org/D2820
Reviewed by:	gnn
2015-06-18 20:45:37 +00:00
kp
ad9eb0c77b Merge r280955
Preserve IPv6 fragment IDs accross reassembly and refragmentation

When forwarding fragmented IPv6 packets and filtering with PF we
reassemble and refragment. That means we generate new fragment headers
and a new fragment ID.

We already save the fragment IDs so we can do the reassembly so it's
straightforward to apply the incoming fragment ID on the refragmented
packets.

Differential Revision:	https://reviews.freebsd.org/D2817
Reviewed by:	gnn
2015-06-18 20:40:36 +00:00
kp
80d7588d81 Merge r278842
Factor out ip6_fragment() function, to be used in IPv6 stack and pf(4).

Differential Revision:	https://reviews.freebsd.org/D2815
Reviewed by:	gnn
2015-06-18 20:32:53 +00:00
kp
37f96b7312 Merge r278828, r278832
- Factor out ip6_deletefraghdr() function, to be shared between IPv6 stack and pf(4).
 - Move ip6_deletefraghdr() to frag6.c. (Suggested by bz)

Differential Revision:	https://reviews.freebsd.org/D2813
Reviewed by:	gnn
2015-06-18 20:21:02 +00:00
ae
f1be259e6a MFC r276148:
Remove in_gif.h and in6_gif.h files. They only contain function
  declarations used by gif(4). Instead declare these functions in C files.
  Also make some variables static.

MFC r276215:
  Extern declarations in C files loses compile-time checking that
  the functions' calls match their definitions. Move them to header files.
2015-06-06 13:26:13 +00:00
ae
920800a21f MFC r274246:
Overhaul if_gre(4).

  Split it into two modules: if_gre(4) for GRE encapsulation and
  if_me(4) for minimal encapsulation within IP.

  gre(4) changes:
  * convert to if_transmit;
  * rework locking: protect access to softc with rmlock,
    protect from concurrent ioctls with sx lock;
  * correct interface accounting for outgoing datagramms (count only payload size);
  * implement generic support for using IPv6 as delivery header;
  * make implementation conform to the RFC 2784 and partially to RFC 2890;
  * add support for GRE checksums - calculate for outgoing datagramms and check
    for inconming datagramms;
  * add support for sending sequence number in GRE header;
  * remove support of cached routes. This fixes problem, when gre(4) doesn't
    work at system startup. But this also removes support for having tunnels with
    the same addresses for inner and outer header.
  * deprecate support for various GREXXX ioctls, that doesn't used in FreeBSD.
    Use our standard ioctls for tunnels.

  me(4):
  * implementation conform to RFC 2004;
  * use if_transmit;
  * use the same locking model as gre(4);

  PR:		164475

MFC r274289 (by bz):
  gcc requires variables to be initialised in two places.  One of them
  is correctly  used only under the same conditional though.

  For module builds properly check if the kernel supports INET or INET6,
  as otherwise various mips kernels without IPv6 support would fail to build.

MFC r274964:
  Add ip_gre.h to ObsoleteFiles.inc.
2015-06-06 12:44:42 +00:00
ae
200ce7d836 Rework r281868 to not skip RTM announces for tunneling interfaces.
This is direct commit to stable/10.

Tested by:	tuexen@
2015-06-05 07:23:32 +00:00
ae
fcbaea9548 MFC r275392:
Remove route chaching support from ipsec code. It isn't used for some time.
  * remove sa_route_union declaration and route_cache member from struct secashead;
  * remove key_sa_routechange() call from ICMP and ICMPv6 code;
  * simplify ip_ipsec_mtu();
  * remove #include <net/route.h>;

Sponsored by:	Yandex LLC
2015-06-02 03:14:42 +00:00
ae
8272d42d32 MFC r282965:
Add an ability accept encapsulated packets from different sources by one
  gif(4) interface. Add new option "ignore_source" for gif(4) interface.
  When it is enabled, gif's encapcheck function requires match only for
  packet's destination address.

  Differential Revision:	https://reviews.freebsd.org/D2004
  Sponsored by:	Yandex LLC
2015-05-31 22:58:41 +00:00
tuexen
beb47cc587 MFC r283650:
Fix and cleanup the debug information. This has no user-visible changes.
Thanks to Irene Ruengeler for proving a patch.
2015-05-31 12:46:40 +00:00
tuexen
369d8e1e68 MFC r276914:
Minimize the usage of SCTP_BUF_IS_EXTENDED.
This should help Robert...
2015-05-29 12:03:02 +00:00
tuexen
551a3dd3e4 MFC r275868:
Plug a memory leak in an error code path.

Reported by:	Coverity
CID:		1018936
2015-05-29 11:25:38 +00:00
ae
d29714b5d5 MFC r282578:
Mark data checksum as valid for multicast packets, that we send back
  to myself via simloop.
  Also remove duplicate check under #ifdef DIAGNOSTIC.

  PR:		180065
2015-05-14 11:47:18 +00:00
hrs
c4b11b866f MFC r274223 (by glebius):
Remove VNET_SYSCTL_ARG(). The generic sysctl(9) code handles that.

A panic could occur by "sysctl -a" when using VIMAGE-enabled stable/10
kernel after r262734 because of this missing MFC.
2015-05-12 03:49:18 +00:00
hiren
e545513c3e MFC r261708, r261847, r268525, r274316, r274347, r275593,
r276844, r276847, r279531, r279559, r279564, r279676

A bunch of IPv6 fixes by melifaro, hrs and ae

Major changes:
Simplify nd6_output_lle()
Add refcounting to DAD and fix races and other errors
Implement Enhanced DAD algorithm for IPv6

Suggested by: 	ae
Tested by: 	Jason Wolfe <j at nitrology.com>
Sponsored by:	Limelight Networks
2015-05-08 08:35:06 +00:00
markj
f0172891ff MFC r281483:
Fix a possible refcount leak in regen_tmpaddr().
2015-05-05 03:17:32 +00:00
hiren
b09afc6f3f MFC r275358 r275483 r276982 - Removing M_FLOWID by hps@
r275358:
Start process of removing the use of the deprecated "M_FLOWID" flag
from the FreeBSD network code. The flag is still kept around in the
"sys/mbuf.h" header file, but does no longer have any users. Instead
the "m_pkthdr.rsstype" field in the mbuf structure is now used to
decide the meaning of the "m_pkthdr.flowid" field. To modify the
"m_pkthdr.rsstype" field please use the existing "M_HASHTYPE_XXX"
macros as defined in the "sys/mbuf.h" header file.

This patch introduces new behaviour in the transmit direction.
Previously network drivers checked if "M_FLOWID" was set in "m_flags"
before using the "m_pkthdr.flowid" field. This check has now now been
replaced by checking if "M_HASHTYPE_GET(m)" is different from
"M_HASHTYPE_NONE". In the future more hashtypes will be added, for
example hashtypes for hardware dedicated flows.

"M_HASHTYPE_OPAQUE" indicates that the "m_pkthdr.flowid" value is
valid and has no particular type. This change removes the need for an
"if" statement in TCP transmit code checking for the presence of a
valid flowid value. The "if" statement mentioned above is now a direct
variable assignment which is then later checked by the respective
network drivers like before.

r275483:
Remove M_FLOWID from SCTP code.

r276982:
Remove no longer used "M_FLOWID" flag from mbuf.h and update the netisr
manpage.

Note: The FreeBSD version has been bumped.

Reviewed by:    hps, tuexen
Sponsored by:   Limelight Networks
2015-04-24 23:26:44 +00:00
ae
8ace1d30e5 MFC r281380:
Fix the IPV6_MULTICAST_IF sockopt handling. RFC 3493 says when the
  interface index is specified as zero, the system should select the
  interface to use for outgoing multicast packets. Even the comment
  for the in6p_set_multicast_if() function says about index of zero.
  But in fact for zero index the function just returns EADDRNOTAVAIL.

  I.e. if you first set some interface and then will try reset it
  with zero ifindex, you will get EADDRNOTAVAIL.

  Reset im6o_multicast_ifp to NULL when interface index specified as
  zero. Also return EINVAL in case when ifnet_byindex() returns NULL.
  This will be the same behaviour as when ifindex is bigger than
  V_if_index. And return EADDRNOTAVAIL only when interface is not
  multicast capable.
2015-04-24 02:12:25 +00:00
ae
a09a1acc01 MFC r274988 (with modification):
Skip L2 addresses lookups for tunneling interfaces.

PR:		197286
2015-04-22 20:42:17 +00:00
ae
1350ebc78f MFC r281309:
Fix the check for maximum mbuf's size needed to send ND6 NA and NS.
  It is acceptable that the size can be equal to MCLBYTES. In the later
  KAME's code this check has been moved under DIAGNOSTIC ifdef, because
  the size of NA and NS is much smaller than MCLBYTES. So, it is safe to
  replace the check with KASSERT.

  PR:		199304
2015-04-22 19:41:29 +00:00
delphij
e5ee1c2b41 Improve patch for SA-15:04.igmp to solve a potential buffer overflow.
Fix multiple vulnerabilities of ntp. [SA-15:07]

Fix bsdinstall(8) insecure default GELI keyfile permissions. [SA-15:08]

Fix Denial of Service with IPv6 Router Advertisements. [SA-15:09]
2015-04-07 20:20:24 +00:00
ae
159c9364d9 MFC r280236:
To avoid a possible race, release the reference to ifa after return
  from nd6_dad_na_input().
2015-03-26 18:44:59 +00:00
ae
86de47baf2 MFC r279588:
Fix deadlock in IPv6 PCB code.

  When several threads are trying to send datagram to the same destination,
  but fragmentation is disabled and datagram size exceeds link MTU,
  ip6_output() calls pfctlinput2(PRC_MSGSIZE). It does notify all
  sockets wanted to know MTU to this destination. And since all threads
  hold PCB lock while sending, taking the lock for each PCB in the
  in6_pcbnotify() leads to deadlock.

  RFC 3542 p.11.3 suggests notify all application wanted to receive
  IPV6_PATHMTU ancillary data for each ICMPv6 packet too big message.
  But it doesn't require this, when we don't receive ICMPv6 message.

  Change ip6_notify_pmtu() function to be able use it directly from
  ip6_output() to notify only one socket, and to notify all sockets
  when ICMPv6 packet too big message received.

MFC r279684:
  tcp6_ctlinput() doesn't pass MTU value to in6_pcbnotify().
  Check cmdarg isn't NULL before dereference, this check was in the
  ip6_notify_pmtu() before r279588.

PR:		197059
Sponsored by:	Yandex LLC
2015-03-12 09:04:19 +00:00
rrs
3a3039379c MFC of r278472
This fixes a bug in the way that the LLE timers for nd6
and arp were being used. They basically would pass in the
mutex to the callout_init. Because they used this method
to the callout system, it was possible to "stop" the callout.
When flushing the table and you stopped the running callout, the
callout_stop code would return 1 indicating that it was going
to stop the callout (that was about to run on the callout_wheel blocked
by the function calling the stop). Now when 1 was returned, it would
lower the reference count one extra time for the stopped timer, then
a few lines later delete the memory. Of course the callout_wheel was
stuck in the lock code and would then crash since it was accessing
freed memory. By using callout_init(c, 1) we always get a 0 back
and the reference counting bug does not rear its head. We do have
to make a few adjustments to the callouts themselves though to make
sure it does the proper thing if rescheduled as well as gets the lock.

Sponsored by:	Netflix Inc.
2015-02-15 13:57:44 +00:00