Index: src/wp-includes/class-wp-network-query.php
===================================================================
--- src/wp-includes/class-wp-network-query.php	(revision 40483)
+++ src/wp-includes/class-wp-network-query.php	(working copy)
@@ -92,54 +92,57 @@
 	 * Sets up the network query, based on the query vars passed.
 	 *
 	 * @since 4.6.0
+	 * @since 4.8.0 Introduced the `update_network_meta_cache` parameter.
 	 * @access public
 	 *
 	 * @param string|array $query {
 	 *     Optional. Array or query string of network query parameters. Default empty.
 	 *
-	 *     @type array        $network__in          Array of network IDs to include. Default empty.
-	 *     @type array        $network__not_in      Array of network IDs to exclude. Default empty.
- 	 *     @type bool         $count                Whether to return a network count (true) or array of network objects.
- 	 *                                              Default false.
- 	 *     @type string       $fields               Network fields to return. Accepts 'ids' (returns an array of network IDs)
- 	 *                                              or empty (returns an array of complete network objects). Default empty.
- 	 *     @type int          $number               Maximum number of networks to retrieve. Default empty (no limit).
- 	 *     @type int          $offset               Number of networks to offset the query. Used to build LIMIT clause.
- 	 *                                              Default 0.
- 	 *     @type bool         $no_found_rows        Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
- 	 *     @type string|array $orderby              Network status or array of statuses. Accepts 'id', 'domain', 'path',
- 	 *                                              'domain_length', 'path_length' and 'network__in'. Also accepts false,
- 	 *                                              an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
- 	 *     @type string       $order                How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
- 	 *     @type string       $domain               Limit results to those affiliated with a given domain. Default empty.
- 	 *     @type array        $domain__in           Array of domains to include affiliated networks for. Default empty.
- 	 *     @type array        $domain__not_in       Array of domains to exclude affiliated networks for. Default empty.
- 	 *     @type string       $path                 Limit results to those affiliated with a given path. Default empty.
- 	 *     @type array        $path__in             Array of paths to include affiliated networks for. Default empty.
- 	 *     @type array        $path__not_in         Array of paths to exclude affiliated networks for. Default empty.
- 	 *     @type string       $search               Search term(s) to retrieve matching networks for. Default empty.
-	 *     @type bool         $update_network_cache Whether to prime the cache for found networks. Default true.
+	 *     @type array        $network__in               Array of network IDs to include. Default empty.
+	 *     @type array        $network__not_in           Array of network IDs to exclude. Default empty.
+ 	 *     @type bool         $count                     Whether to return a network count (true) or array of network objects.
+ 	 *                                                   Default false.
+ 	 *     @type string       $fields                    Network fields to return. Accepts 'ids' (returns an array of network IDs)
+ 	 *                                                   or empty (returns an array of complete network objects). Default empty.
+ 	 *     @type int          $number                    Maximum number of networks to retrieve. Default empty (no limit).
+ 	 *     @type int          $offset                    Number of networks to offset the query. Used to build LIMIT clause.
+ 	 *                                                   Default 0.
+ 	 *     @type bool         $no_found_rows             Whether to disable the `SQL_CALC_FOUND_ROWS` query. Default true.
+ 	 *     @type string|array $orderby                   Network status or array of statuses. Accepts 'id', 'domain', 'path',
+ 	 *                                                   'domain_length', 'path_length' and 'network__in'. Also accepts false,
+ 	 *                                                   an empty array, or 'none' to disable `ORDER BY` clause. Default 'id'.
+ 	 *     @type string       $order                     How to order retrieved networks. Accepts 'ASC', 'DESC'. Default 'ASC'.
+ 	 *     @type string       $domain                    Limit results to those affiliated with a given domain. Default empty.
+ 	 *     @type array        $domain__in                Array of domains to include affiliated networks for. Default empty.
+ 	 *     @type array        $domain__not_in            Array of domains to exclude affiliated networks for. Default empty.
+ 	 *     @type string       $path                      Limit results to those affiliated with a given path. Default empty.
+ 	 *     @type array        $path__in                  Array of paths to include affiliated networks for. Default empty.
+ 	 *     @type array        $path__not_in              Array of paths to exclude affiliated networks for. Default empty.
+ 	 *     @type string       $search                    Search term(s) to retrieve matching networks for. Default empty.
+	 *     @type bool         $update_network_cache      Whether to prime the cache for found networks. Default true.
+	 *     @type bool         $update_network_meta_cache Whether to prime meta caches for found networks. Default true.
 	 * }
 	 */
 	public function __construct( $query = '' ) {
 		$this->query_var_defaults = array(
-			'network__in'          => '',
-			'network__not_in'      => '',
-			'count'                => false,
-			'fields'               => '',
-			'number'               => '',
-			'offset'               => '',
-			'no_found_rows'        => true,
-			'orderby'              => 'id',
-			'order'                => 'ASC',
-			'domain'               => '',
-			'domain__in'           => '',
-			'domain__not_in'       => '',
-			'path'                 => '',
-			'path__in'             => '',
-			'path__not_in'         => '',
-			'search'               => '',
-			'update_network_cache' => true,
+			'network__in'               => '',
+			'network__not_in'           => '',
+			'count'                     => false,
+			'fields'                    => '',
+			'number'                    => '',
+			'offset'                    => '',
+			'no_found_rows'             => true,
+			'orderby'                   => 'id',
+			'order'                     => 'ASC',
+			'domain'                    => '',
+			'domain__in'                => '',
+			'domain__not_in'            => '',
+			'path'                      => '',
+			'path__in'                  => '',
+			'path__not_in'              => '',
+			'search'                    => '',
+			'update_network_cache'      => true,
+			'update_network_meta_cache' => true,
 		);
 
 		if ( ! empty( $query ) ) {
@@ -248,7 +251,7 @@
 		}
 
 		if ( $this->query_vars['update_network_cache'] ) {
-			_prime_network_caches( $network_ids );
+			_prime_network_caches( $network_ids, $this->query_vars['update_network_meta_cache'] );
 		}
 
 		// Fetch full network objects from the primed cache.
Index: src/wp-includes/load.php
===================================================================
--- src/wp-includes/load.php	(revision 40483)
+++ src/wp-includes/load.php	(working copy)
@@ -515,7 +515,7 @@
 	}
 
 	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
-		wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites' ) );
+		wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'site-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site_meta' ) );
 		wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
 	}
 }
Index: src/wp-includes/ms-blogs.php
===================================================================
--- src/wp-includes/ms-blogs.php	(revision 40483)
+++ src/wp-includes/ms-blogs.php	(working copy)
@@ -842,7 +842,7 @@
 			if ( is_array( $global_groups ) ) {
 				wp_cache_add_global_groups( $global_groups );
 			} else {
-				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );
+				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'site_meta' ) );
 			}
 			wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
 		}
@@ -916,7 +916,7 @@
 			if ( is_array( $global_groups ) ) {
 				wp_cache_add_global_groups( $global_groups );
 			} else {
-				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );
+				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'site_meta' ) );
 			}
 			wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) );
 		}
@@ -1153,6 +1153,92 @@
 }
 
 /**
+ * Add metadata to a network.
+ *
+ * @since 4.8.0
+ *
+ * @param int    $id         Network ID.
+ * @param string $meta_key   Metadata name.
+ * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
+ * @param bool   $unique     Optional. Whether the same key should not be added.
+ *                           Default false.
+ * @return int|false Meta ID on success, false on failure.
+ */
+function add_network_meta( $id, $meta_key, $meta_value, $unique = false ) {
+	return add_metadata( 'site', $id, $meta_key, $meta_value, $unique );
+}
+
+/**
+ * Remove from a network, metadata matching key and/or value.
+ *
+ * You can match based on the key, or key and value. Removing based on key and
+ * value, will keep from removing duplicate metadata with the same key. It also
+ * allows removing all metadata matching key, if needed.
+ *
+ * @since 4.8.0
+ *
+ * @param int    $id         Network ID.
+ * @param string $meta_key   Metadata name.
+ * @param mixed  $meta_value Optional. Metadata value. Must be serializable if
+ *                           non-scalar. Default empty.
+ * @return bool True on success, false on failure.
+ */
+function delete_network_meta( $id, $meta_key, $meta_value = '' ) {
+	return delete_metadata( 'site', $id, $meta_key, $meta_value );
+}
+
+/**
+ * Retrieve from a network, metadata value by key.
+ *
+ * @since 4.8.0
+ *
+ * @param int    $id        Network ID.
+ * @param string $meta_key  Optional. The meta key to retrieve. By default, returns
+ *                          data for all keys. Default empty.
+ * @param bool   $single    Optional. Whether to return a single value. Default false.
+ * @return mixed Will be an array if $single is false. Will be value of meta data
+ *               field if $single is true.
+ */
+function get_network_meta( $id, $meta_key = '', $single = false ) {
+	return get_metadata( 'site', $id, $meta_key, $single );
+}
+
+/**
+ * Update metadata for a network ID, and/or key, and/or value.
+ *
+ * Use the $prev_value parameter to differentiate between meta fields with the
+ * same key and network ID.
+ *
+ * If the meta field for the network does not exist, it will be added.
+ *
+ * @since 4.8.0
+ *
+ * @param int    $id         Network ID.
+ * @param string $meta_key   Metadata key.
+ * @param mixed  $meta_value Metadata value. Must be serializable if non-scalar.
+ * @param mixed  $prev_value Optional. Previous value to check before removing.
+ *                           Default empty.
+ * @return int|bool Meta ID if the key didn't exist, true on successful update,
+ *                  false on failure.
+ */
+function update_network_meta( $id, $meta_key, $meta_value, $prev_value = '' ) {
+	return update_metadata( 'site', $id, $meta_key, $meta_value, $prev_value );
+}
+
+/**
+ * Delete everything from network meta matching meta key.
+ *
+ * @since 4.8.0
+ *
+ * @param string $network_meta_key Key to search for when deleting.
+ *
+ * @return bool Whether the network meta key was deleted from the database.
+ */
+function delete_network_meta_by_key( $network_meta_key ) {
+	return delete_metadata( 'site', null, $network_meta_key, '', true );
+}
+
+/**
  * Removes a network from the object cache.
  *
  * @since 4.6.0
@@ -1170,6 +1256,7 @@
 
 	foreach ( (array) $ids as $id ) {
 		wp_cache_delete( $id, 'networks' );
+		wp_cache_delete( $id, 'site_meta' );
 
 		/**
 		 * Fires immediately after a network has been removed from the object cache.
@@ -1192,34 +1279,59 @@
  * cache using the network group with the key using the ID of the networks.
  *
  * @since 4.6.0
+ * @since 4.8.0 Introduced the `$update_meta_cache` parameter.
  *
- * @param array $networks Array of network row objects.
+ * @param array $networks          Array of network row objects.
+ * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
  */
-function update_network_cache( $networks ) {
+function update_network_cache( $networks, $update_meta_cache = true ) {
 	foreach ( (array) $networks as $network ) {
 		wp_cache_add( $network->id, $network, 'networks' );
 	}
+
+	if ( $update_meta_cache ) {
+		update_networkmeta_cache( wp_list_pluck( $networks, 'id' ) );
+	}
 }
 
 /**
+ * Updates metadata cache for list of network IDs.
+ *
+ * Performs SQL query to retrieve the metadata for the network IDs and updates the
+ * metadata cache for the posts. Therefore, the functions, which call this
+ * function, do not need to perform SQL queries on their own.
+ *
+ * @since 4.8.0
+ *
+ * @param array $network_ids List of network IDs.
+ * @return array|false Returns false if there is nothing to update or an array
+ *                     of metadata.
+ */
+function update_networkmeta_cache( $network_ids) {
+	return update_meta_cache( 'site', $network_ids );
+}
+
+/**
  * Adds any networks from the given IDs to the cache that do not already exist in cache.
  *
  * @since 4.6.0
+ * @since 4.8.0 Introduced the `$update_meta_cache` parameter.
  * @access private
  *
  * @see update_network_cache()
  * @global wpdb $wpdb WordPress database abstraction object.
  *
- * @param array $network_ids Array of network IDs.
+ * @param array $network_ids       Array of network IDs.
+ * @param bool  $update_meta_cache Optional. Whether to update the meta cache. Default true.
  */
-function _prime_network_caches( $network_ids ) {
+function _prime_network_caches( $network_ids, $update_meta_cache = true ) {
 	global $wpdb;
 
 	$non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' );
-	if ( !empty( $non_cached_ids ) ) {
-		$fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
+	if ( ! empty( $non_cached_ids ) ) {
+		$fresh_networks = $wpdb->get_results( sprintf( "SELECT * FROM {$wpdb->site} WHERE id IN (%s)", join( ",", array_map( 'intval', $non_cached_ids ) ) ) );
 
-		update_network_cache( $fresh_networks );
+		update_network_cache( $fresh_networks, $update_meta_cache );
 	}
 }
 
Index: tests/phpunit/includes/testcase.php
===================================================================
--- tests/phpunit/includes/testcase.php	(revision 40483)
+++ tests/phpunit/includes/testcase.php	(working copy)
@@ -301,7 +301,7 @@
 			$wp_object_cache->__remoteset();
 		}
 		wp_cache_flush();
-		wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );
+		wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'site_meta' ) );
 		wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
 	}
 
Index: tests/phpunit/tests/cache.php
===================================================================
--- tests/phpunit/tests/cache.php	(revision 40483)
+++ tests/phpunit/tests/cache.php	(working copy)
@@ -22,7 +22,7 @@
 		global $wp_object_cache;
 		$cache_class = get_class( $wp_object_cache );
 		$cache = new $cache_class();
-		$cache->add_global_groups( array( 'global-cache-test', 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) );
+		$cache->add_global_groups( array( 'global-cache-test', 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'site_meta' ) );
 		return $cache;
 	}
 
Index: tests/phpunit/tests/multisite/networkMeta.php
===================================================================
--- tests/phpunit/tests/multisite/networkMeta.php	(nonexistent)
+++ tests/phpunit/tests/multisite/networkMeta.php	(working copy)
@@ -0,0 +1,127 @@
+<?php
+
+if ( is_multisite() ) :
+/**
+ * @group ms-network
+ * @group multisite
+ * @group meta
+ * @ticket 25344
+ */
+class Tests_Multisite_Network_Meta extends WP_UnitTestCase {
+	protected static $network_id;
+	protected static $network_id2;
+
+	public static function wpSetUpBeforeClass( $factory ) {
+		self::$network_id = $factory->network->create( array( 'domain' => 'wordpress.org', 'path' => '/' ) );
+		self::$network_id2 = $factory->network->create( array( 'domain' => 'wordpress.org', 'path' => '/foo/' ) );
+	}
+
+	public static function wpTearDownAfterClass() {
+		global $wpdb;
+
+		$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", self::$network_id ) );
+		$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", self::$network_id ) );
+
+		$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", self::$network_id2 ) );
+		$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", self::$network_id2 ) );
+	}
+
+	public function test_add() {
+		$this->assertNotEmpty( add_network_meta( self::$network_id, 'foo', 'bar' ) );
+	}
+
+	public function test_add_unique() {
+		$this->assertNotEmpty( add_network_meta( self::$network_id, 'foo', 'bar' ) );
+		$this->assertFalse( add_network_meta( self::$network_id, 'foo', 'bar', true ) );
+	}
+
+	public function test_delete() {
+		add_network_meta( self::$network_id, 'foo', 'bar' );
+
+		$this->assertTrue( delete_network_meta( self::$network_id, 'foo' ) );
+	}
+
+	public function test_delete_with_invalid_meta_key_should_return_false() {
+		$this->assertFalse( delete_network_meta( self::$network_id, 'foo' ) );
+	}
+
+	public function test_delete_should_respect_meta_value() {
+		add_network_meta( self::$network_id, 'foo', 'bar' );
+		add_network_meta( self::$network_id, 'foo', 'baz' );
+
+		$this->assertTrue( delete_network_meta( self::$network_id, 'foo', 'bar' ) );
+
+		$metas = get_network_meta( self::$network_id, 'foo', false );
+		$this->assertSame( array( 'baz' ), $metas );
+	}
+
+	public function test_get_with_no_key_should_fetch_all_keys() {
+		add_network_meta( self::$network_id, 'foo', 'bar' );
+		add_network_meta( self::$network_id, 'foo1', 'baz' );
+
+		$found = get_network_meta( self::$network_id );
+
+		$expected = array(
+			'foo' => array( 'bar' ),
+			'foo1' => array( 'baz' ),
+		);
+
+		// Ignore default network options.
+		$found = array_intersect_key( $found, $expected );
+
+		$this->assertEqualSets( $expected, $found );
+	}
+
+	public function test_get_with_key_should_fetch_all_for_key() {
+		add_network_meta( self::$network_id, 'foo', 'bar' );
+		add_network_meta( self::$network_id, 'foo', 'baz' );
+		add_network_meta( self::$network_id, 'foo1', 'baz' );
+
+		$found = get_network_meta( self::$network_id, 'foo' );
+		$expected = array( 'bar', 'baz' );
+
+		$this->assertEqualSets( $expected, $found );
+	}
+
+	public function test_get_should_respect_single_true() {
+		add_network_meta( self::$network_id, 'foo', 'bar' );
+		add_network_meta( self::$network_id, 'foo', 'baz' );
+
+		$found = get_network_meta( self::$network_id, 'foo', true );
+		$this->assertEquals( 'bar', $found );
+	}
+
+	public function test_update_should_pass_to_add_when_no_value_exists_for_key() {
+		$actual = update_network_meta( self::$network_id, 'foo', 'bar' );
+		$this->assertInternalType( 'int', $actual );
+		$this->assertNotEmpty( $actual );
+
+		$meta = get_network_meta( self::$network_id, 'foo', true );
+		$this->assertSame( 'bar', $meta );
+	}
+
+	public function test_update_should_return_true_when_updating_existing_value_for_key() {
+		add_network_meta( self::$network_id, 'foo', 'bar' );
+
+		$actual = update_network_meta( self::$network_id, 'foo', 'baz' );
+		$this->assertTrue( $actual );
+
+		$meta = get_network_meta( self::$network_id, 'foo', true );
+		$this->assertSame( 'baz', $meta );
+	}
+
+	public function test_delete_by_key() {
+		add_network_meta( self::$network_id, 'unique_delete_by_key', 'value', true );
+		add_network_meta( self::$network_id2, 'unique_delete_by_key', 'value', true );
+
+		$this->assertEquals( 'value', get_network_meta( self::$network_id, 'unique_delete_by_key', true ) );
+		$this->assertEquals( 'value', get_network_meta( self::$network_id2, 'unique_delete_by_key', true ) );
+
+		$this->assertTrue( delete_network_meta_by_key( 'unique_delete_by_key' ) );
+
+		$this->assertEquals( '', get_network_meta( self::$network_id, 'unique_delete_by_key', true ) );
+		$this->assertEquals( '', get_network_meta( self::$network_id2, 'unique_delete_by_key', true ) );
+	}
+}
+
+endif;
