4 Copyright (C) Andrew Tridgell 2007
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include "system/network.h"
25 #include "lib/util/debug.h"
27 #include "ctdb_private.h"
29 #include "common/common.h"
30 #include "common/logging.h"
31 #include "common/tunable.h"
34 set all tunables to defaults
36 void ctdb_tunables_set_defaults(struct ctdb_context
*ctdb
)
38 ctdb_tunable_set_defaults(&ctdb
->tunable
);
45 int32_t ctdb_control_get_tunable(struct ctdb_context
*ctdb
, TDB_DATA indata
,
48 struct ctdb_control_get_tunable
*t
=
49 (struct ctdb_control_get_tunable
*)indata
.dptr
;
54 if (indata
.dsize
< sizeof(*t
) ||
55 t
->length
> indata
.dsize
- offsetof(struct ctdb_control_get_tunable
, name
)) {
56 DEBUG(DEBUG_ERR
,("Bad indata in ctdb_control_get_tunable\n"));
60 name
= talloc_strndup(ctdb
, (char*)t
->name
, t
->length
);
61 CTDB_NO_MEMORY(ctdb
, name
);
63 ret
= ctdb_tunable_get_value(&ctdb
->tunable
, name
, &val
);
69 outdata
->dptr
= (uint8_t *)talloc(outdata
, uint32_t);
70 CTDB_NO_MEMORY(ctdb
, outdata
->dptr
);
72 *(uint32_t *)outdata
->dptr
= val
;
73 outdata
->dsize
= sizeof(uint32_t);
82 int32_t ctdb_control_set_tunable(struct ctdb_context
*ctdb
, TDB_DATA indata
)
84 struct ctdb_tunable_old
*t
=
85 (struct ctdb_tunable_old
*)indata
.dptr
;
90 if (indata
.dsize
< sizeof(*t
) ||
91 t
->length
> indata
.dsize
- offsetof(struct ctdb_tunable_old
, name
)) {
92 DEBUG(DEBUG_ERR
,("Bad indata in ctdb_control_set_tunable\n"));
96 name
= talloc_strndup(ctdb
, (char *)t
->name
, t
->length
);
97 CTDB_NO_MEMORY(ctdb
, name
);
99 ret
= ctdb_tunable_set_value(&ctdb
->tunable
, name
, t
->value
,
108 ("Setting obsolete tunable \"%s\"\n", name
));
120 int32_t ctdb_control_list_tunables(struct ctdb_context
*ctdb
, TDB_DATA
*outdata
)
123 struct ctdb_control_list_tunable
*t
;
125 list
= ctdb_tunable_names_to_string(outdata
);
126 CTDB_NO_MEMORY(ctdb
, list
);
128 outdata
->dsize
= offsetof(struct ctdb_control_list_tunable
, data
) +
130 outdata
->dptr
= talloc_size(outdata
, outdata
->dsize
);
131 CTDB_NO_MEMORY(ctdb
, outdata
->dptr
);
133 t
= (struct ctdb_control_list_tunable
*)outdata
->dptr
;
134 t
->length
= strlen(list
)+1;
136 memcpy(t
->data
, list
, t
->length
);