1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
* 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
* or http://www.opensolaris.org/os/licensing.
* 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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2017 Joyent, Inc.
*/
/*
* Functions to maintain a table of datalink configuration information.
*/
#ifndef _DLMGMT_IMPL_H
#define _DLMGMT_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <door.h>
#include <libdllink.h>
#include <sys/avl.h>
/*
* datalink attribute structure
*/
typedef struct dlmgmt_linkattr_s {
struct dlmgmt_linkattr_s *lp_next;
struct dlmgmt_linkattr_s *lp_prev;
char lp_name[MAXLINKATTRLEN];
void *lp_val;
dladm_datatype_t lp_type;
uint_t lp_sz;
boolean_t lp_linkprop;
} dlmgmt_linkattr_t;
/*
* datalink structure
*/
typedef struct dlmgmt_link_s {
dlmgmt_linkattr_t *ll_head;
char ll_link[MAXLINKNAMELEN];
datalink_class_t ll_class;
uint32_t ll_media;
datalink_id_t ll_linkid;
/*
* The zone that owns the link. If this is set to the id of
* an NGZ and ll_onloan is set then the link was created and
* is owned by the GZ but is currently being loaned out to an
* NGZ. E.g., when the GZ admin creates a VNIC for exclusive
* use by an NGZ. If ll_onloan is set then ll_zoneid cannot be 0.
*
* If ll_zoneid is set to the id of an NGZ but ll_onloan is
* not set then the link was created and is owned by the NGZ.
*/
zoneid_t ll_zoneid;
boolean_t ll_onloan;
avl_node_t ll_name_node;
avl_node_t ll_id_node;
uint32_t ll_flags;
uint32_t ll_gen; /* generation number */
boolean_t ll_trans; /* transient link */
} dlmgmt_link_t;
/*
* datalink configuration request structure
*/
typedef struct dlmgmt_dlconf_s {
dlmgmt_linkattr_t *ld_head;
char ld_link[MAXLINKNAMELEN];
datalink_id_t ld_linkid;
datalink_class_t ld_class;
uint32_t ld_media;
int ld_id;
zoneid_t ld_zoneid;
uint32_t ld_gen;
avl_node_t ld_node;
} dlmgmt_dlconf_t;
extern boolean_t debug;
extern const char *progname;
extern char cachefile[];
extern dladm_handle_t dld_handle;
extern datalink_id_t dlmgmt_nextlinkid;
extern avl_tree_t dlmgmt_name_avl;
extern avl_tree_t dlmgmt_id_avl;
extern avl_tree_t dlmgmt_dlconf_avl;
boolean_t linkattr_equal(dlmgmt_linkattr_t **, const char *, void *,
size_t);
dlmgmt_linkattr_t *linkattr_find(dlmgmt_linkattr_t *, const char *);
void linkattr_unset(dlmgmt_linkattr_t **, const char *);
int linkattr_set(dlmgmt_linkattr_t **, const char *, void *,
size_t, dladm_datatype_t);
int linkattr_get(dlmgmt_linkattr_t **, const char *, void **,
size_t *, dladm_datatype_t *);
void linkattr_destroy(dlmgmt_link_t *);
void link_destroy(dlmgmt_link_t *);
int link_activate(dlmgmt_link_t *);
boolean_t link_is_visible(dlmgmt_link_t *, zoneid_t);
dlmgmt_link_t *link_by_id(datalink_id_t, zoneid_t);
dlmgmt_link_t *link_by_name(const char *, zoneid_t);
int dlmgmt_create_common(const char *, datalink_class_t,
uint32_t, zoneid_t, uint32_t, dlmgmt_link_t **);
int dlmgmt_destroy_common(dlmgmt_link_t *, uint32_t);
int dlmgmt_getattr_common(dlmgmt_linkattr_t **, const char *,
dlmgmt_getattr_retval_t *);
void dlmgmt_advance(dlmgmt_link_t *);
void dlmgmt_table_lock(boolean_t);
void dlmgmt_table_unlock();
int dlconf_create(const char *, datalink_id_t, datalink_class_t,
uint32_t, zoneid_t, dlmgmt_dlconf_t **);
void dlconf_destroy(dlmgmt_dlconf_t *);
void dlmgmt_advance_dlconfid(dlmgmt_dlconf_t *);
void dlmgmt_dlconf_table_lock(boolean_t);
void dlmgmt_dlconf_table_unlock(void);
int dlmgmt_generate_name(const char *, char *, size_t, zoneid_t);
void dlmgmt_linktable_init(void);
void dlmgmt_linktable_fini(void);
int dlmgmt_zone_init(zoneid_t);
int dlmgmt_elevate_privileges(void);
int dlmgmt_drop_privileges();
void dlmgmt_handler(void *, char *, size_t, door_desc_t *, uint_t);
void dlmgmt_log(int, const char *, ...);
int dlmgmt_write_db_entry(const char *, dlmgmt_link_t *, uint32_t);
int dlmgmt_delete_db_entry(dlmgmt_link_t *, uint32_t);
int dlmgmt_db_init(zoneid_t, char *);
void dlmgmt_db_fini(zoneid_t);
#ifdef __cplusplus
}
#endif
#endif /* _DLMGMT_IMPL_H */
|