/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* RCM module to prevent plumbed IP addresses from being removed.
*/
#include <stdlib.h>
#include <ctype.h>
#include <memory.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <thread.h>
#include <synch.h>
#include <assert.h>
#include <errno.h>
#include <libintl.h>
#include <libinetutil.h>
#include "rcm_module.h"
static int ip_anon_register(rcm_handle_t *);
static int ip_anon_unregister(rcm_handle_t *);
char **, char **, nvlist_t *, rcm_info_t **);
char **, rcm_info_t **);
char **, rcm_info_t **);
char **, rcm_info_t **);
char **, rcm_info_t **);
typedef struct ip_status {
int flags;
} ip_status_t;
{
NULL,
NULL,
};
struct rcm_mod_ops *
{
return (&ip_anon_ops);
}
const char *
{
return ("RCM IP address module 1.4");
}
int
{
/* free the registration list */
(void) mutex_lock(&ip_list_lock);
}
(void) mutex_unlock(&ip_list_lock);
(void) mutex_destroy(&ip_list_lock);
return (RCM_SUCCESS);
}
static int
{
int bootflags;
(void) mutex_lock(&ip_list_lock);
gettext("unable to check cluster status\n"));
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
}
"ip_anon: cladm bootflags=%d\n", bootflags);
if (bootflags == 3) {
/* build the exclusion list */
&num_exclude_addrs)) == 0) {
if (num_exclude_addrs == 0)
"ip_anon: no addresses excluded\n");
else {
malloc(sizeof (cladm_netaddr_entry_t) *
(num_exclude_addrs))) == NULL) {
gettext("out of memory\n"));
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
}
!= 0) {
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
}
}
} else {
"no _cladm() backend to get addrs\n");
} else {
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
}
}
"ip_anon: num exclude addrs: %d\n",
/* print the exclusion list for debugging purposes */
for (i = 0; i < exclude_addrs.cladm_num_netaddrs; i++) {
if (exclude_addrs.cladm_netaddrs_array[i].\
cl_ipversion == IPV4_VERSION) {
}
if (exclude_addrs.cladm_netaddrs_array[i].\
cl_ipversion == IPV6_VERSION) {
}
}
}
/* obtain a list of all IPv4 and IPv6 addresses in the system */
"ip_anon: obtaining list of IPv4 addresses.\n");
if (num_ifs == -1) {
gettext("cannot get IPv4 address list errno=%d (%s)\n"),
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
}
"ip_anon: obtaining list of IPv6 addresses.\n");
if (num_ifs6 == -1) {
gettext("cannot get IPv6 address list errno=%d (%s)\n"),
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
}
/* check the state of outstanding registrations against the list */
"ip_anon: checking outstanding registrations.\n");
}
/* IPv4 */
for (i = 0; i < num_ifs; i++) {
else
gettext("out of memory\n"));
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
}
}
/* IPv6 */
for (i = 0; i < num_ifs6; i++) {
else
gettext("out of memory\n"));
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
}
_S6_u32))
}
/* examine the list of ip address registrations and their state */
"ip_anon: unregistering interest in %s\n",
gettext("failed to unregister"));
}
}
/*
* If the registration is not a clustered devices and
* not already registered, then RCM doesn't
* currently know about it.
*/
"ip_anon: registering interest in %s\n",
if (rcm_register_interest(hdl,
RCM_SUCCESS) {
(void) mutex_unlock(&ip_list_lock);
return (RCM_FAILURE);
} else {
"ip_anon: registered %s\n",
}
}
/*
* If the entry is registered and clustered, then
* the configuration has been changed and it
* should be unregistered.
*/
"ip_anon: unregistering in %s\n",
gettext("failed to unregister"));
}
}
}
}
}
(void) mutex_unlock(&ip_list_lock);
return (RCM_SUCCESS);
}
static int
{
(void) mutex_lock(&ip_list_lock);
gettext("failed to unregister"));
}
}
}
(void) mutex_unlock(&ip_list_lock);
return (RCM_SUCCESS);
}
/*ARGSUSED*/
static int
{
return (RCM_SUCCESS);
}
/*ARGSUSED*/
static int
{
return (RCM_FAILURE);
}
/*ARGSUSED*/
static int
{
return (RCM_SUCCESS);
}
/*ARGSUSED*/
static int
{
return (RCM_FAILURE);
}
/*ARGSUSED*/
static int
{
return (RCM_SUCCESS);
}
/*ARGSUSED*/
static int
{
return (RCM_FAILURE);
}
/*
* Call with ip_list_lock held.
*/
static ip_status_t *
{
int done;
done = 0;
done = 1;
else
}
return (tlist);
}
static ip_status_t *
{
return (tentry);
else {
}
return (tentry);
}
static int
{
return (-1);
} else {
return (-1);
}
return (0);
}
static int
{
int i;
/*
* If this falls in the exclusion list, the IP_FLAG_CL
* bit should be set for the adapter.
*/
for (i = 0; i < exclude_addrs.cladm_num_netaddrs; i++) {
if (exclude_addrs.cladm_netaddrs_array[i].\
cl_ipversion == IPV4_VERSION) {
"ip_anon: matched %s:%s => %s\n",
return (1);
}
}
}
taddr);
return (0);
}
static int
{
int i, j, numequal;
/*
* If this falls in the exclusion list, the IP_FLAG_CL
* bit should be set for the adapter.
*/
for (i = 0; i < exclude_addrs.cladm_num_netaddrs; i++) {
if (exclude_addrs.cladm_netaddrs_array[i].\
cl_ipversion == IPV6_VERSION) {
numequal = 0;
for (j = 0; j < 4; j++) {
ipv6_netaddr[j] = exclude_addrs.\
cladm_netaddrs_array[i].\
ipv6_netmask[j] = exclude_addrs.\
cladm_netaddrs_array[i].\
if (addr[j] == ipv6_netaddr[j])
numequal++;
}
if (numequal == 4)
return (1);
}
}
taddr);
return (0);
}