all: avoid using global string buffer for to-string methods
These string functions allow to omit the string buffer. This is for convenience, to use a global (thread-local) buffer. I think that is error prone and we should drop that "convenience" feature. At various places, pass a stack allocated buffer.
This commit is contained in:
@@ -297,6 +297,7 @@ process_classful_routes(const char *iface, GHashTable *options, NML3ConfigData *
|
||||
}
|
||||
|
||||
for (s = searches; *s; s += 2) {
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
NMPlatformIP4Route route;
|
||||
guint32 rt_addr, rt_route;
|
||||
|
||||
@@ -338,7 +339,7 @@ process_classful_routes(const char *iface, GHashTable *options, NML3ConfigData *
|
||||
_LOG2I(LOGD_DHCP,
|
||||
iface,
|
||||
" static route %s",
|
||||
nm_platform_ip4_route_to_string(&route, NULL, 0));
|
||||
nm_platform_ip4_route_to_string(&route, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -67,9 +67,12 @@ dm_watch_cb(GPid pid, int status, gpointer user_data)
|
||||
guint err;
|
||||
|
||||
if (WIFEXITED(status)) {
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
err = WEXITSTATUS(status);
|
||||
if (err != 0) {
|
||||
_LOGW("dnsmasq exited with error: %s", nm_utils_dnsmasq_status_to_string(err, NULL, 0));
|
||||
_LOGW("dnsmasq exited with error: %s",
|
||||
nm_utils_dnsmasq_status_to_string(err, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
} else if (WIFSTOPPED(status)) {
|
||||
_LOGW("dnsmasq stopped unexpectedly with signal %d", WSTOPSIG(status));
|
||||
|
@@ -2870,6 +2870,7 @@ _set_config_data(NMConfig *self, NMConfigData *new_data, NMConfigChangeFlags rel
|
||||
NMConfigData *old_data = priv->config_data;
|
||||
NMConfigChangeFlags changes, changes_diff;
|
||||
gboolean had_new_data = !!new_data;
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
nm_assert(reload_flags);
|
||||
nm_assert(!NM_FLAGS_ANY(reload_flags, ~NM_CONFIG_CHANGE_CAUSES));
|
||||
@@ -2901,15 +2902,15 @@ _set_config_data(NMConfig *self, NMConfigData *new_data, NMConfigChangeFlags rel
|
||||
|
||||
if (new_data) {
|
||||
_LOGI("signal: %s (%s)",
|
||||
nm_config_change_flags_to_string(changes, NULL, 0),
|
||||
nm_config_change_flags_to_string(changes, sbuf, sizeof(sbuf)),
|
||||
nm_config_data_get_config_description(new_data));
|
||||
nm_config_data_log(new_data, "CONFIG: ", " ", priv->no_auto_default_file, NULL);
|
||||
priv->config_data = new_data;
|
||||
} else if (had_new_data)
|
||||
_LOGI("signal: %s (no changes from disk)",
|
||||
nm_config_change_flags_to_string(changes, NULL, 0));
|
||||
nm_config_change_flags_to_string(changes, sbuf, sizeof(sbuf)));
|
||||
else
|
||||
_LOGI("signal: %s", nm_config_change_flags_to_string(changes, NULL, 0));
|
||||
_LOGI("signal: %s", nm_config_change_flags_to_string(changes, sbuf, sizeof(sbuf)));
|
||||
g_signal_emit(self, signals[SIGNAL_CONFIG_CHANGED], 0, new_data ?: old_data, changes, old_data);
|
||||
if (new_data)
|
||||
g_object_unref(old_data);
|
||||
|
@@ -211,12 +211,13 @@ nmtst_platform_ip4_routes_equal(const NMPlatformIP4Route *a,
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (nm_platform_ip4_route_cmp_full(&a[i], &b[i]) != 0) {
|
||||
char buf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
char buf1[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
char buf2[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
g_error("Error comparing IPv4 route[%lu]: %s vs %s",
|
||||
(unsigned long) i,
|
||||
nm_platform_ip4_route_to_string(&a[i], NULL, 0),
|
||||
nm_platform_ip4_route_to_string(&b[i], buf, sizeof(buf)));
|
||||
nm_platform_ip4_route_to_string(&a[i], buf1, sizeof(buf1)),
|
||||
nm_platform_ip4_route_to_string(&b[i], buf2, sizeof(buf2)));
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
@@ -280,12 +281,13 @@ nmtst_platform_ip6_routes_equal(const NMPlatformIP6Route *a,
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (nm_platform_ip6_route_cmp_full(&a[i], &b[i]) != 0) {
|
||||
char buf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
char buf1[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
char buf2[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
g_error("Error comparing IPv6 route[%lu]: %s vs %s",
|
||||
(unsigned long) i,
|
||||
nm_platform_ip6_route_to_string(&a[i], NULL, 0),
|
||||
nm_platform_ip6_route_to_string(&b[i], buf, sizeof(buf)));
|
||||
nm_platform_ip6_route_to_string(&a[i], buf1, sizeof(buf1)),
|
||||
nm_platform_ip6_route_to_string(&b[i], buf2, sizeof(buf2)));
|
||||
g_assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
@@ -1535,6 +1535,7 @@ _rule_fuzzy_equal(const NMPObject *obj, const NMPObject *obj_comp, int op_type)
|
||||
static void
|
||||
test_rule(gconstpointer test_data)
|
||||
{
|
||||
char sbuf1[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
const int TEST_IDX = GPOINTER_TO_INT(test_data);
|
||||
const gboolean TEST_SYNC = (TEST_IDX == 4);
|
||||
gs_unref_ptrarray GPtrArray *objs = NULL;
|
||||
@@ -1763,7 +1764,7 @@ again:
|
||||
|
||||
g_print(">>> failing... errno=%d, rule=%s\n",
|
||||
r,
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_ALL, NULL, 0));
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_ALL, sbuf1, sizeof(sbuf1)));
|
||||
|
||||
nmp_lookup_init_obj_type(&lookup, NMP_OBJECT_TYPE_ROUTING_RULE);
|
||||
head_entry = nm_platform_lookup(platform, &lookup);
|
||||
@@ -1775,9 +1776,10 @@ again:
|
||||
&& NMP_OBJECT_CAST_ROUTING_RULE(o)->priority
|
||||
== NMP_OBJECT_CAST_ROUTING_RULE(obj)->priority)
|
||||
ch = '*';
|
||||
g_print(">>> existing rule: %c %s\n",
|
||||
ch,
|
||||
nmp_object_to_string(o, NMP_OBJECT_TO_STRING_ALL, NULL, 0));
|
||||
g_print(
|
||||
">>> existing rule: %c %s\n",
|
||||
ch,
|
||||
nmp_object_to_string(o, NMP_OBJECT_TO_STRING_ALL, sbuf1, sizeof(sbuf1)));
|
||||
}
|
||||
|
||||
nmtstp_run_command_check("ip rule");
|
||||
@@ -1836,11 +1838,14 @@ again:
|
||||
|
||||
if (!_rule_fuzzy_equal(obj, objs->pdata[k], RTM_DELRULE)) {
|
||||
g_print(">>> failing...\n");
|
||||
g_print(">>> no fuzzy match between: %s\n",
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_ALL, NULL, 0));
|
||||
g_print(
|
||||
">>> and: %s\n",
|
||||
nmp_object_to_string(objs->pdata[k], NMP_OBJECT_TO_STRING_ALL, NULL, 0));
|
||||
">>> no fuzzy match between: %s\n",
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_ALL, sbuf1, sizeof(sbuf1)));
|
||||
g_print(">>> and: %s\n",
|
||||
nmp_object_to_string(objs->pdata[k],
|
||||
NMP_OBJECT_TO_STRING_ALL,
|
||||
sbuf1,
|
||||
sizeof(sbuf1)));
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
|
@@ -6342,6 +6342,7 @@ cache_prune_one_type(NMPlatform *platform, const NMPLookup *lookup)
|
||||
|
||||
nm_dedup_multi_iter_init(&iter, nmp_cache_lookup(cache, lookup));
|
||||
while (nm_dedup_multi_iter_next(&iter)) {
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
const NMDedupMultiEntry *main_entry;
|
||||
|
||||
/* we only track the dirty flag for the OBJECT-TYPE index. That means,
|
||||
@@ -6353,7 +6354,7 @@ cache_prune_one_type(NMPlatform *platform, const NMPLookup *lookup)
|
||||
obj = main_entry->obj;
|
||||
|
||||
_LOGt("cache-prune: prune %s",
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_ALL, NULL, 0));
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_ALL, sbuf, sizeof(sbuf)));
|
||||
|
||||
{
|
||||
nm_auto_nmpobj const NMPObject *obj_old = NULL;
|
||||
@@ -7026,6 +7027,7 @@ event_seq_check(NMPlatform *platform,
|
||||
static void
|
||||
event_valid_msg(NMPlatform *platform, struct nl_msg *msg, gboolean handle_events)
|
||||
{
|
||||
char sbuf1[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
NMLinuxPlatformPrivate *priv;
|
||||
nm_auto_nmpobj NMPObject *obj = NULL;
|
||||
NMPCacheOpsType cache_op;
|
||||
@@ -7082,8 +7084,8 @@ event_valid_msg(NMPlatform *platform, struct nl_msg *msg, gboolean handle_events
|
||||
is_dump ? ", in-dump" : "",
|
||||
nmp_object_to_string(obj,
|
||||
is_del ? NMP_OBJECT_TO_STRING_ID : NMP_OBJECT_TO_STRING_PUBLIC,
|
||||
NULL,
|
||||
0));
|
||||
sbuf1,
|
||||
sizeof(sbuf1)));
|
||||
|
||||
while (TRUE) {
|
||||
nm_auto_nmpobj const NMPObject *obj_old = NULL;
|
||||
@@ -7309,6 +7311,7 @@ do_add_addrroute(NMPlatform *platform,
|
||||
struct nl_msg *nlmsg,
|
||||
gboolean suppress_netlink_failure)
|
||||
{
|
||||
char sbuf1[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
||||
gs_free char *errmsg = NULL;
|
||||
int nle;
|
||||
@@ -7331,7 +7334,7 @@ do_add_addrroute(NMPlatform *platform,
|
||||
if (nle < 0) {
|
||||
_LOGE("do-add-%s[%s]: failure sending netlink request \"%s\" (%d)",
|
||||
NMP_OBJECT_GET_CLASS(obj_id)->obj_type_name,
|
||||
nmp_object_to_string(obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
|
||||
nmp_object_to_string(obj_id, NMP_OBJECT_TO_STRING_ID, sbuf1, sizeof(sbuf1)),
|
||||
nm_strerror(nle),
|
||||
-nle);
|
||||
return -NME_PL_NETLINK;
|
||||
@@ -7347,7 +7350,7 @@ do_add_addrroute(NMPlatform *platform,
|
||||
: LOGL_WARN,
|
||||
"do-add-%s[%s]: %s",
|
||||
NMP_OBJECT_GET_CLASS(obj_id)->obj_type_name,
|
||||
nmp_object_to_string(obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
|
||||
nmp_object_to_string(obj_id, NMP_OBJECT_TO_STRING_ID, sbuf1, sizeof(sbuf1)),
|
||||
wait_for_nl_response_to_string(seq_result, errmsg, s_buf, sizeof(s_buf)));
|
||||
|
||||
if (NMP_OBJECT_GET_TYPE(obj_id) == NMP_OBJECT_TYPE_IP6_ADDRESS) {
|
||||
@@ -7368,6 +7371,7 @@ do_add_addrroute(NMPlatform *platform,
|
||||
static gboolean
|
||||
do_delete_object(NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *nlmsg)
|
||||
{
|
||||
char sbuf1[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
|
||||
gs_free char *errmsg = NULL;
|
||||
int nle;
|
||||
@@ -7386,7 +7390,7 @@ do_delete_object(NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *n
|
||||
if (nle < 0) {
|
||||
_LOGE("do-delete-%s[%s]: failure sending netlink request \"%s\" (%d)",
|
||||
NMP_OBJECT_GET_CLASS(obj_id)->obj_type_name,
|
||||
nmp_object_to_string(obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
|
||||
nmp_object_to_string(obj_id, NMP_OBJECT_TO_STRING_ID, sbuf1, sizeof(sbuf1)),
|
||||
nm_strerror(nle),
|
||||
-nle);
|
||||
return FALSE;
|
||||
@@ -7418,7 +7422,7 @@ do_delete_object(NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *n
|
||||
_NMLOG(success ? LOGL_DEBUG : LOGL_WARN,
|
||||
"do-delete-%s[%s]: %s%s",
|
||||
NMP_OBJECT_GET_CLASS(obj_id)->obj_type_name,
|
||||
nmp_object_to_string(obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
|
||||
nmp_object_to_string(obj_id, NMP_OBJECT_TO_STRING_ID, sbuf1, sizeof(sbuf1)),
|
||||
wait_for_nl_response_to_string(seq_result, errmsg, s_buf, sizeof(s_buf)),
|
||||
log_detail);
|
||||
|
||||
|
@@ -1875,9 +1875,10 @@ nm_platform_link_set_sriov_vfs(NMPlatform *self, int ifindex, const NMPlatformVF
|
||||
|
||||
_LOG3D("link: setting VFs");
|
||||
for (i = 0; vfs[i]; i++) {
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
const NMPlatformVF *vf = vfs[i];
|
||||
|
||||
_LOG3D("link: VF %s", nm_platform_vf_to_string(vf, NULL, 0));
|
||||
_LOG3D("link: VF %s", nm_platform_vf_to_string(vf, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
return klass->link_set_sriov_vfs(self, ifindex, vfs);
|
||||
@@ -1899,9 +1900,11 @@ nm_platform_link_set_bridge_vlans(NMPlatform *self,
|
||||
on_master ? "master" : "self");
|
||||
if (vlans) {
|
||||
for (i = 0; vlans[i]; i++) {
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
const NMPlatformBridgeVlan *vlan = vlans[i];
|
||||
|
||||
_LOG3D("link: bridge VLAN %s", nm_platform_bridge_vlan_to_string(vlan, NULL, 0));
|
||||
_LOG3D("link: bridge VLAN %s",
|
||||
nm_platform_bridge_vlan_to_string(vlan, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3543,6 +3546,7 @@ nm_platform_ip4_address_add(NMPlatform *self,
|
||||
FALSE);
|
||||
|
||||
if (_LOGD_ENABLED()) {
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
NMPlatformIP4Address addr;
|
||||
|
||||
addr = (NMPlatformIP4Address){
|
||||
@@ -3561,7 +3565,7 @@ nm_platform_ip4_address_add(NMPlatform *self,
|
||||
g_strlcpy(addr.label, label, sizeof(addr.label));
|
||||
|
||||
_LOG3D("address: adding or updating IPv4 address: %s",
|
||||
nm_platform_ip4_address_to_string(&addr, NULL, 0));
|
||||
nm_platform_ip4_address_to_string(&addr, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
return klass->ip4_address_add(self,
|
||||
ifindex,
|
||||
@@ -3593,6 +3597,7 @@ nm_platform_ip6_address_add(NMPlatform *self,
|
||||
g_return_val_if_fail(preferred <= lifetime, FALSE);
|
||||
|
||||
if (_LOGD_ENABLED()) {
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
NMPlatformIP6Address addr = {0};
|
||||
|
||||
addr.ifindex = ifindex;
|
||||
@@ -3605,7 +3610,7 @@ nm_platform_ip6_address_add(NMPlatform *self,
|
||||
addr.n_ifa_flags = flags;
|
||||
|
||||
_LOG3D("address: adding or updating IPv6 address: %s",
|
||||
nm_platform_ip6_address_to_string(&addr, NULL, 0));
|
||||
nm_platform_ip6_address_to_string(&addr, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
return klass
|
||||
->ip6_address_add(self, ifindex, address, plen, peer_address, lifetime, preferred, flags);
|
||||
@@ -5126,7 +5131,8 @@ nm_platform_ip6_route_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformI
|
||||
gboolean
|
||||
nm_platform_object_delete(NMPlatform *self, const NMPObject *obj)
|
||||
{
|
||||
int ifindex;
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
int ifindex;
|
||||
|
||||
_CHECK_SELF(self, klass, FALSE);
|
||||
|
||||
@@ -5134,7 +5140,7 @@ nm_platform_object_delete(NMPlatform *self, const NMPObject *obj)
|
||||
case NMP_OBJECT_TYPE_ROUTING_RULE:
|
||||
_LOGD("%s: delete %s",
|
||||
NMP_OBJECT_GET_CLASS(obj)->obj_type_name,
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
break;
|
||||
case NMP_OBJECT_TYPE_IP4_ROUTE:
|
||||
case NMP_OBJECT_TYPE_IP6_ROUTE:
|
||||
@@ -5143,7 +5149,7 @@ nm_platform_object_delete(NMPlatform *self, const NMPObject *obj)
|
||||
ifindex = NMP_OBJECT_CAST_OBJ_WITH_IFINDEX(obj)->ifindex;
|
||||
_LOG3D("%s: delete %s",
|
||||
NMP_OBJECT_GET_CLASS(obj)->obj_type_name,
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
break;
|
||||
default:
|
||||
g_return_val_if_reached(FALSE);
|
||||
@@ -5161,6 +5167,7 @@ nm_platform_ip_route_get(NMPlatform *self,
|
||||
int oif_ifindex,
|
||||
NMPObject **out_route)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
nm_auto_nmpobj NMPObject *route = NULL;
|
||||
int result;
|
||||
char buf[NM_UTILS_INET_ADDRSTRLEN];
|
||||
@@ -5197,7 +5204,7 @@ nm_platform_ip_route_get(NMPlatform *self,
|
||||
_LOGD("route: get IPv%c route for: %s succeeded: %s",
|
||||
nm_utils_addr_family_to_char(addr_family),
|
||||
inet_ntop(addr_family, address, buf, sizeof(buf)),
|
||||
nmp_object_to_string(route, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(route, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
NM_SET_OUT(out_route, g_steal_pointer(&route));
|
||||
}
|
||||
return result;
|
||||
@@ -5224,6 +5231,7 @@ _ip4_dev_route_blacklist_timeout_ms_marked(gint64 timeout_msec)
|
||||
static gboolean
|
||||
_ip4_dev_route_blacklist_check_cb(gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
NMPlatform *self = user_data;
|
||||
NMPlatformPrivate *priv = NM_PLATFORM_GET_PRIVATE(self);
|
||||
GHashTableIter iter;
|
||||
@@ -5254,7 +5262,7 @@ again:
|
||||
continue;
|
||||
|
||||
_LOGT("ip4-dev-route: delete %s",
|
||||
nmp_object_to_string(p_obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(p_obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
nm_platform_object_delete(self, p_obj);
|
||||
goto again;
|
||||
}
|
||||
@@ -5317,6 +5325,7 @@ _ip4_dev_route_blacklist_notify_route(NMPlatform *self, const NMPObject *obj)
|
||||
static gboolean
|
||||
_ip4_dev_route_blacklist_gc_timeout_handle(gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
NMPlatform *self = user_data;
|
||||
NMPlatformPrivate *priv = NM_PLATFORM_GET_PRIVATE(self);
|
||||
GHashTableIter iter;
|
||||
@@ -5332,7 +5341,7 @@ _ip4_dev_route_blacklist_gc_timeout_handle(gpointer user_data)
|
||||
while (g_hash_table_iter_next(&iter, (gpointer *) &p_obj, (gpointer *) &p_timeout_ms)) {
|
||||
if (now_ms > _ip4_dev_route_blacklist_timeout_ms_get(*p_timeout_ms)) {
|
||||
_LOGT("ip4-dev-route: cleanup %s",
|
||||
nmp_object_to_string(p_obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(p_obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
g_hash_table_iter_remove(&iter);
|
||||
}
|
||||
}
|
||||
@@ -5392,6 +5401,7 @@ nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self,
|
||||
int ifindex,
|
||||
GPtrArray *ip4_dev_route_blacklist)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
NMPlatformPrivate *priv;
|
||||
GHashTableIter iter;
|
||||
const NMPObject *p_obj;
|
||||
@@ -5447,14 +5457,17 @@ nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self,
|
||||
if (nmp_object_equal(p_obj, o)) {
|
||||
/* un-expire and reuse the entry. */
|
||||
_LOGT("ip4-dev-route: register %s (update)",
|
||||
nmp_object_to_string(p_obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(p_obj,
|
||||
NMP_OBJECT_TO_STRING_PUBLIC,
|
||||
sbuf,
|
||||
sizeof(sbuf)));
|
||||
*p_timeout_ms = timeout_msec_val;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
_LOGT("ip4-dev-route: register %s",
|
||||
nmp_object_to_string(o, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(o, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
p_timeout_ms = g_slice_new(gint64);
|
||||
*p_timeout_ms = timeout_msec_val;
|
||||
g_hash_table_replace(priv->ip4_dev_route_blacklist_hash,
|
||||
@@ -5476,12 +5489,13 @@ nm_platform_routing_rule_add(NMPlatform *self,
|
||||
NMPNlmFlags flags,
|
||||
const NMPlatformRoutingRule *routing_rule)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
_CHECK_SELF(self, klass, -NME_BUG);
|
||||
|
||||
g_return_val_if_fail(routing_rule, -NME_BUG);
|
||||
|
||||
_LOGD("routing-rule: adding or updating: %s",
|
||||
nm_platform_routing_rule_to_string(routing_rule, NULL, 0));
|
||||
nm_platform_routing_rule_to_string(routing_rule, sbuf, sizeof(sbuf)));
|
||||
return klass->routing_rule_add(self, flags, routing_rule);
|
||||
}
|
||||
|
||||
@@ -5490,13 +5504,15 @@ nm_platform_routing_rule_add(NMPlatform *self,
|
||||
int
|
||||
nm_platform_qdisc_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformQdisc *qdisc)
|
||||
{
|
||||
int ifindex = qdisc->ifindex;
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
int ifindex = qdisc->ifindex;
|
||||
_CHECK_SELF(self, klass, -NME_BUG);
|
||||
|
||||
/* Note: @qdisc must not be copied or kept alive because the lifetime of qdisc.kind
|
||||
* is undefined. */
|
||||
|
||||
_LOG3D("adding or updating a qdisc: %s", nm_platform_qdisc_to_string(qdisc, NULL, 0));
|
||||
_LOG3D("adding or updating a qdisc: %s",
|
||||
nm_platform_qdisc_to_string(qdisc, sbuf, sizeof(sbuf)));
|
||||
return klass->qdisc_add(self, flags, qdisc);
|
||||
}
|
||||
|
||||
@@ -5514,13 +5530,15 @@ nm_platform_qdisc_delete(NMPlatform *self, int ifindex, guint32 parent, gboolean
|
||||
int
|
||||
nm_platform_tfilter_add(NMPlatform *self, NMPNlmFlags flags, const NMPlatformTfilter *tfilter)
|
||||
{
|
||||
int ifindex = tfilter->ifindex;
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
int ifindex = tfilter->ifindex;
|
||||
_CHECK_SELF(self, klass, -NME_BUG);
|
||||
|
||||
/* Note: @tfilter must not be copied or kept alive because the lifetime of tfilter.kind
|
||||
* and tfilter.action.kind is undefined. */
|
||||
|
||||
_LOG3D("adding or updating a tfilter: %s", nm_platform_tfilter_to_string(tfilter, NULL, 0));
|
||||
_LOG3D("adding or updating a tfilter: %s",
|
||||
nm_platform_tfilter_to_string(tfilter, sbuf, sizeof(sbuf)));
|
||||
return klass->tfilter_add(self, flags, tfilter);
|
||||
}
|
||||
|
||||
@@ -8945,9 +8963,11 @@ log_link(NMPlatform *self,
|
||||
NMPlatformSignalChangeType change_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
_LOG3D("signal: link %7s: %s",
|
||||
nm_platform_signal_change_type_to_string(change_type),
|
||||
nm_platform_link_to_string(device, NULL, 0));
|
||||
nm_platform_link_to_string(device, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -8958,9 +8978,11 @@ log_ip4_address(NMPlatform *self,
|
||||
NMPlatformSignalChangeType change_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
_LOG3D("signal: address 4 %7s: %s",
|
||||
nm_platform_signal_change_type_to_string(change_type),
|
||||
nm_platform_ip4_address_to_string(address, NULL, 0));
|
||||
nm_platform_ip4_address_to_string(address, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -8971,9 +8993,11 @@ log_ip6_address(NMPlatform *self,
|
||||
NMPlatformSignalChangeType change_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
_LOG3D("signal: address 6 %7s: %s",
|
||||
nm_platform_signal_change_type_to_string(change_type),
|
||||
nm_platform_ip6_address_to_string(address, NULL, 0));
|
||||
nm_platform_ip6_address_to_string(address, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -8984,9 +9008,11 @@ log_ip4_route(NMPlatform *self,
|
||||
NMPlatformSignalChangeType change_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
_LOG3D("signal: route 4 %7s: %s",
|
||||
nm_platform_signal_change_type_to_string(change_type),
|
||||
nm_platform_ip4_route_to_string(route, NULL, 0));
|
||||
nm_platform_ip4_route_to_string(route, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -8997,9 +9023,11 @@ log_ip6_route(NMPlatform *self,
|
||||
NMPlatformSignalChangeType change_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
_LOG3D("signal: route 6 %7s: %s",
|
||||
nm_platform_signal_change_type_to_string(change_type),
|
||||
nm_platform_ip6_route_to_string(route, NULL, 0));
|
||||
nm_platform_ip6_route_to_string(route, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -9010,10 +9038,12 @@ log_routing_rule(NMPlatform *self,
|
||||
NMPlatformSignalChangeType change_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
/* routing rules don't have an ifindex. We probably should refactor the signals that are emitted for platform changes. */
|
||||
_LOG3D("signal: rt-rule %7s: %s",
|
||||
nm_platform_signal_change_type_to_string(change_type),
|
||||
nm_platform_routing_rule_to_string(routing_rule, NULL, 0));
|
||||
nm_platform_routing_rule_to_string(routing_rule, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -9024,9 +9054,11 @@ log_qdisc(NMPlatform *self,
|
||||
NMPlatformSignalChangeType change_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
_LOG3D("signal: qdisc %7s: %s",
|
||||
nm_platform_signal_change_type_to_string(change_type),
|
||||
nm_platform_qdisc_to_string(qdisc, NULL, 0));
|
||||
nm_platform_qdisc_to_string(qdisc, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -9037,9 +9069,11 @@ log_tfilter(NMPlatform *self,
|
||||
NMPlatformSignalChangeType change_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
_LOG3D("signal: tfilter %7s: %s",
|
||||
nm_platform_signal_change_type_to_string(change_type),
|
||||
nm_platform_tfilter_to_string(tfilter, NULL, 0));
|
||||
nm_platform_tfilter_to_string(tfilter, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -9050,6 +9084,7 @@ nm_platform_cache_update_emit_signal(NMPlatform *self,
|
||||
const NMPObject *obj_old,
|
||||
const NMPObject *obj_new)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
gboolean visible_new;
|
||||
gboolean visible_old;
|
||||
const NMPObject *o;
|
||||
@@ -9112,7 +9147,7 @@ nm_platform_cache_update_emit_signal(NMPlatform *self,
|
||||
_LOG3t("emit signal %s %s: %s",
|
||||
klass->signal_type,
|
||||
nm_platform_signal_change_type_to_string((NMPlatformSignalChangeType) cache_op),
|
||||
nmp_object_to_string(o, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(o, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
|
||||
nmp_object_ref(o);
|
||||
g_signal_emit(self,
|
||||
|
@@ -397,14 +397,17 @@ nmp_route_manager_track(NMPRouteManager *self,
|
||||
_track_data_assert(track_data, TRUE);
|
||||
|
||||
if (changed) {
|
||||
_LOGD("track [" NM_HASH_OBFUSCATE_PTR_FMT ",%s%u] %s \"%s\"",
|
||||
NM_HASH_OBFUSCATE_PTR(track_data->user_tag),
|
||||
(track_data->track_priority_val == 0
|
||||
? ""
|
||||
: (track_data->track_priority_present ? "+" : "-")),
|
||||
(guint) track_data->track_priority_val,
|
||||
NMP_OBJECT_GET_CLASS(track_data->obj)->obj_type_name,
|
||||
nmp_object_to_string(track_data->obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
|
||||
_LOGD(
|
||||
"track [" NM_HASH_OBFUSCATE_PTR_FMT ",%s%u] %s \"%s\"",
|
||||
NM_HASH_OBFUSCATE_PTR(track_data->user_tag),
|
||||
(track_data->track_priority_val == 0
|
||||
? ""
|
||||
: (track_data->track_priority_present ? "+" : "-")),
|
||||
(guint) track_data->track_priority_val,
|
||||
NMP_OBJECT_GET_CLASS(track_data->obj)->obj_type_name,
|
||||
nmp_object_to_string(track_data->obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
}
|
||||
|
||||
return changed || changed_untrack;
|
||||
@@ -416,6 +419,7 @@ _track_data_untrack(NMPRouteManager *self,
|
||||
gboolean remove_user_tag_data,
|
||||
gboolean make_owned_by_us)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
TrackObjData *obj_data;
|
||||
|
||||
nm_assert(NMP_IS_ROUTE_MANAGER(self));
|
||||
@@ -426,7 +430,7 @@ _track_data_untrack(NMPRouteManager *self,
|
||||
_LOGD("untrack [" NM_HASH_OBFUSCATE_PTR_FMT "] %s \"%s\"",
|
||||
NM_HASH_OBFUSCATE_PTR(track_data->user_tag),
|
||||
NMP_OBJECT_GET_CLASS(track_data->obj)->obj_type_name,
|
||||
nmp_object_to_string(track_data->obj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(track_data->obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
{
|
||||
@@ -552,6 +556,7 @@ nmp_route_manager_untrack_all(NMPRouteManager *self,
|
||||
void
|
||||
nmp_route_manager_sync(NMPRouteManager *self, NMPObjectType obj_type, gboolean keep_deleted)
|
||||
{
|
||||
char sbuf[NM_UTILS_TO_STRING_BUFFER_SIZE];
|
||||
const NMDedupMultiHeadEntry *pl_head_entry;
|
||||
NMDedupMultiIter pl_iter;
|
||||
const NMPObject *plobj;
|
||||
@@ -608,7 +613,7 @@ nmp_route_manager_sync(NMPRouteManager *self, NMPObjectType obj_type, gboolean k
|
||||
if (keep_deleted) {
|
||||
_LOGD("forget/leak object added by us: %s \"%s\"",
|
||||
NMP_OBJECT_GET_CLASS(plobj)->obj_type_name,
|
||||
nmp_object_to_string(plobj, NMP_OBJECT_TO_STRING_PUBLIC, NULL, 0));
|
||||
nmp_object_to_string(plobj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf)));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user