components/openvswitch/files/lib/netdev-solaris.c
changeset 7590 5461fab14904
parent 7000 22f549e6467a
equal deleted inserted replaced
7589:7eccd056eff6 7590:5461fab14904
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     3  */
     3  */
     4 
     4 
     5 /*
     5 /*
     6  * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
     6  * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
     7  *
     7  *
    79 	struct netdev up;
    79 	struct netdev up;
    80 
    80 
    81 	/* Protects all members below. */
    81 	/* Protects all members below. */
    82 	struct ovs_mutex mutex;
    82 	struct ovs_mutex mutex;
    83 
    83 
       
    84 	boolean_t rarp_sent;
       
    85 
    84 	/*
    86 	/*
    85 	 * Bit mask of cached properties. These can be cached because
    87 	 * Bit mask of cached properties. These can be cached because
    86 	 * nothing besides vswitchd is altering the properties.
    88 	 * nothing besides vswitchd is altering the properties.
    87 	 */
    89 	 */
    88 	unsigned int cache_valid;
    90 	unsigned int cache_valid;
   145 static boolean_t	kstat2_handle_initialized = B_FALSE;
   147 static boolean_t	kstat2_handle_initialized = B_FALSE;
   146 static struct ovs_mutex	kstat_mutex = OVS_MUTEX_INITIALIZER;
   148 static struct ovs_mutex	kstat_mutex = OVS_MUTEX_INITIALIZER;
   147 
   149 
   148 static int netdev_solaris_init(void);
   150 static int netdev_solaris_init(void);
   149 static struct netdev_solaris *netdev_solaris_cast(const struct netdev *);
   151 static struct netdev_solaris *netdev_solaris_cast(const struct netdev *);
       
   152 static void netdev_solaris_send_rarp(const struct netdev *);
   150 
   153 
   151 /* Maintaining a mapping of every netdev->name to its bridge name. */
   154 /* Maintaining a mapping of every netdev->name to its bridge name. */
   152 struct shash port_to_bridge_map = SHASH_INITIALIZER(&port_to_bridge_map);
   155 struct shash port_to_bridge_map = SHASH_INITIALIZER(&port_to_bridge_map);
   153 
   156 
   154 /*
   157 /*
   700 }
   703 }
   701 
   704 
   702 static void
   705 static void
   703 netdev_solaris_run(void)
   706 netdev_solaris_run(void)
   704 {
   707 {
       
   708 	struct shash device_shash;
       
   709 	struct shash_node *node;
       
   710 
       
   711 	shash_init(&device_shash);
       
   712 	netdev_get_devices(&netdev_solaris_class, &device_shash);
       
   713 	SHASH_FOR_EACH(node, &device_shash) {
       
   714 		struct netdev *netdev = node->data;
       
   715 		struct netdev_solaris *dev = netdev_solaris_cast(netdev);
       
   716 
       
   717 		/*
       
   718 		 * No lock is needed to protect dev->rarp_sent. Because
       
   719 		 * netdev_solaris_run() is called single threaded in the
       
   720 		 * main() function.
       
   721 		 */
       
   722 		if (!dev->rarp_sent) {
       
   723 			netdev_solaris_send_rarp(netdev);
       
   724 			dev->rarp_sent = B_TRUE;
       
   725 		}
       
   726 		netdev_close(netdev);
       
   727 	}
       
   728 
       
   729 	shash_destroy(&device_shash);
   705 }
   730 }
   706 
   731 
   707 static void
   732 static void
   708 netdev_solaris_wait(void)
   733 netdev_solaris_wait(void)
   709 {
   734 {
   712 static struct netdev *
   737 static struct netdev *
   713 netdev_solaris_alloc(void)
   738 netdev_solaris_alloc(void)
   714 {
   739 {
   715 	struct netdev_solaris *netdev = xzalloc(sizeof (*netdev));
   740 	struct netdev_solaris *netdev = xzalloc(sizeof (*netdev));
   716 
   741 
       
   742 	netdev->rarp_sent = B_FALSE;
   717 	return (&netdev->up);
   743 	return (&netdev->up);
   718 }
   744 }
   719 
   745 
   720 static void
   746 static void
   721 netdev_solaris_add_port_to_bridge_mapping(const struct netdev
   747 netdev_solaris_add_port_to_bridge_mapping(const struct netdev
  1194 
  1220 
  1195 	VLOG_DBG("netdev_solaris_is_uplink device %s", netdev_name);
  1221 	VLOG_DBG("netdev_solaris_is_uplink device %s", netdev_name);
  1196 	if (netdev_solaris_get_dlclass(netdev_) != 0)
  1222 	if (netdev_solaris_get_dlclass(netdev_) != 0)
  1197 		return (false);
  1223 		return (false);
  1198 	return (solaris_is_uplink_class(netdev->class));
  1224 	return (solaris_is_uplink_class(netdev->class));
       
  1225 }
       
  1226 
       
  1227 /*
       
  1228  * Send an Reverse ARP for this link, if it is not an uplink.
       
  1229  */
       
  1230 static void
       
  1231 netdev_solaris_send_rarp(const struct netdev *netdev_)
       
  1232 {
       
  1233 	const char		*netdev_name = netdev_get_name(netdev_);
       
  1234 
       
  1235 	VLOG_DBG("netdev_solaris_send_rarp:send RARP device %s", netdev_name);
       
  1236 
       
  1237 	if (netdev_solaris_is_uplink(netdev_)) {
       
  1238 		VLOG_DBG("netdev_solaris_send_rarp: uplink\n");
       
  1239 		return;
       
  1240 	}
       
  1241 
       
  1242 	dpif_solaris_send_rarp(netdev_name);
  1199 }
  1243 }
  1200 
  1244 
  1201 static int
  1245 static int
  1202 netdev_solaris_get_etheraddr(const struct netdev *netdev_,
  1246 netdev_solaris_get_etheraddr(const struct netdev *netdev_,
  1203     uint8_t mac[ETH_ADDR_LEN])
  1247     uint8_t mac[ETH_ADDR_LEN])