• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 15263807472

26 May 2025 08:53PM UTC coverage: 72.046% (-0.002%) from 72.048%
15263807472

push

github

yuwata
src/core/manager.c: log preset activity on first boot

This gives us a little more information about what units were enabled
or disabled on that first boot and will be useful for OS developers
tracking down the source of unit state.

An example with this enabled looks like:

```
NET: Registered PF_VSOCK protocol family
systemd[1]: Applying preset policy.
systemd[1]: Unit /etc/systemd/system/dnsmasq.service is masked, ignoring.
systemd[1]: Unit /etc/systemd/system/systemd-repart.service is masked, ignoring.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket'.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir.mount' → '/etc/systemd/system/var-mnt-workdir.mount'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir\x2dtmp.mount' → '/etc/systemd/system/var-mnt-workdir\x2dtmp.mount'.
systemd[1]: Created symlink '/etc/systemd/system/afterburn-sshkeys.target.requires/afterburn-sshkeys@core.service' → '/usr/lib/systemd/system/afterburn-sshkeys@.service'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket' → '/usr/lib/systemd/system/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket' → '/usr/lib/systemd/system/systemd-resolved-monitor.socket'.
systemd[1]: Populated /etc with preset unit settings.
```

Considering it only happens on first boot and not on every boot I think
the extra information is worth the extra verbosity in the logs just for
that boot.

5 of 6 new or added lines in 1 file covered. (83.33%)

5463 existing lines in 165 files now uncovered.

299151 of 415222 relevant lines covered (72.05%)

702386.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/basic/in-addr-util.h
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
#pragma once
3

4
#include <netinet/in.h>
5

6
#include "forward.h"
7

8
union in_addr_union {
9
        struct in_addr in;
10
        struct in6_addr in6;
11
        uint8_t bytes[CONST_MAX(sizeof(struct in_addr), sizeof(struct in6_addr))];
12
};
13

14
struct in_addr_data {
15
        int family;
16
        union in_addr_union address;
17
};
18

19
bool in4_addr_is_null(const struct in_addr *a);
20
static inline bool in4_addr_is_set(const struct in_addr *a) {
67,263✔
21
        return !in4_addr_is_null(a);
67,263✔
22
}
23
bool in6_addr_is_null(const struct in6_addr *a);
24
static inline bool in6_addr_is_set(const struct in6_addr *a) {
10,455✔
25
        return !in6_addr_is_null(a);
10,455✔
26
}
27
int in_addr_is_null(int family, const union in_addr_union *u);
28
static inline bool in_addr_is_set(int family, const union in_addr_union *u) {
104,016✔
29
        return in_addr_is_null(family, u) == 0;
104,016✔
30
}
31
static inline int in_addr_data_is_null(const struct in_addr_data *a) {
212✔
32
        assert(a);
212✔
33
        return in_addr_is_null(a->family, &a->address);
212✔
34
}
35
static inline bool in_addr_data_is_set(const struct in_addr_data *a) {
36
        return in_addr_data_is_null(a);
37
}
38

39
bool in4_addr_is_multicast(const struct in_addr *a);
40
bool in6_addr_is_multicast(const struct in6_addr *a);
41
int in_addr_is_multicast(int family, const union in_addr_union *u);
42

43
bool in4_addr_is_link_local(const struct in_addr *a);
44
bool in4_addr_is_link_local_dynamic(const struct in_addr *a);
45
bool in6_addr_is_link_local(const struct in6_addr *a);
46
int in_addr_is_link_local(int family, const union in_addr_union *u);
47
bool in6_addr_is_link_local_all_nodes(const struct in6_addr *a);
48

49
bool in4_addr_is_localhost(const struct in_addr *a);
50
int in_addr_is_localhost(int family, const union in_addr_union *u);
51
int in_addr_is_localhost_one(int family, const union in_addr_union *u);
52

53
bool in4_addr_is_local_multicast(const struct in_addr *a);
54
bool in4_addr_is_non_local(const struct in_addr *a);
55
bool in6_addr_is_ipv4_mapped_address(const struct in6_addr *a);
56

57
bool in4_addr_equal(const struct in_addr *a, const struct in_addr *b);
58
bool in6_addr_equal(const struct in6_addr *a, const struct in6_addr *b);
59
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b);
60
bool in4_addr_prefix_intersect(
61
                const struct in_addr *a,
62
                unsigned aprefixlen,
63
                const struct in_addr *b,
64
                unsigned bprefixlen);
65
bool in6_addr_prefix_intersect(
66
                const struct in6_addr *a,
67
                unsigned aprefixlen,
68
                const struct in6_addr *b,
69
                unsigned bprefixlen);
70
int in_addr_prefix_intersect(
71
                int family,
72
                const union in_addr_union *a,
73
                unsigned aprefixlen,
74
                const union in_addr_union *b,
75
                unsigned bprefixlen);
76
int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen);
77
int in_addr_prefix_nth(int family, union in_addr_union *u, unsigned prefixlen, uint64_t nth);
78
int in_addr_random_prefix(int family, union in_addr_union *u, unsigned prefixlen_fixed_part, unsigned prefixlen);
79
int in_addr_prefix_range(
80
                int family,
81
                const union in_addr_union *in,
82
                unsigned prefixlen,
83
                union in_addr_union *ret_start,
84
                union in_addr_union *ret_end);
85

86
int in_addr_to_string(int family, const union in_addr_union *u, char **ret);
87
static inline int in6_addr_to_string(const struct in6_addr *u, char **ret) {
88
        return in_addr_to_string(AF_INET6, (const union in_addr_union*) u, ret);
89
}
90

91
const char* typesafe_inet_ntop(int family, const union in_addr_union *a, char *buf, size_t len);
92
const char* typesafe_inet_ntop4(const struct in_addr *a, char *buf, size_t len);
93
const char* typesafe_inet_ntop6(const struct in6_addr *a, char *buf, size_t len);
94

95
/* Note: the lifetime of the compound literal is the immediately surrounding block,
96
 * see C11 §6.5.2.5, and
97
 * https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks */
98
#define IN_ADDR_MAX CONST_MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN)
99
#define IN_ADDR_TO_STRING(family, addr) typesafe_inet_ntop(family, addr, (char[IN_ADDR_MAX]){}, IN_ADDR_MAX)
100
#define IN4_ADDR_TO_STRING(addr) typesafe_inet_ntop4(addr, (char[INET_ADDRSTRLEN]){}, INET_ADDRSTRLEN)
101
#define IN6_ADDR_TO_STRING(addr) typesafe_inet_ntop6(addr, (char[INET6_ADDRSTRLEN]){}, INET6_ADDRSTRLEN)
102

103
int in_addr_prefix_to_string(
104
                int family,
105
                const union in_addr_union *u,
106
                unsigned prefixlen,
107
                char *buf,
108
                size_t buf_len);
109

110
static inline const char* _in_addr_prefix_to_string(
414,547✔
111
                int family,
112
                const union in_addr_union *u,
113
                unsigned prefixlen,
114
                char *buf,
115
                size_t buf_len) {
116
        /* We assume that this is called with an appropriately sized buffer and can never fail. */
117
        assert_se(in_addr_prefix_to_string(family, u, prefixlen, buf, buf_len) == 0);
414,547✔
118
        return buf;
414,547✔
119
}
120
static inline const char* _in4_addr_prefix_to_string(const struct in_addr *a, unsigned prefixlen, char *buf, size_t buf_len) {
84✔
121
        return _in_addr_prefix_to_string(AF_INET, (const union in_addr_union *) a, prefixlen, buf, buf_len);
84✔
122
}
123
static inline const char* _in6_addr_prefix_to_string(const struct in6_addr *a, unsigned prefixlen, char *buf, size_t buf_len) {
76✔
124
        return _in_addr_prefix_to_string(AF_INET6, (const union in_addr_union *) a, prefixlen, buf, buf_len);
68✔
125
}
126

127
#define PREFIX_SUFFIX_MAX (1 + DECIMAL_STR_MAX(unsigned))
128
#define IN_ADDR_PREFIX_TO_STRING(family, addr, prefixlen) \
129
        _in_addr_prefix_to_string(family, addr, prefixlen, (char[IN_ADDR_MAX + PREFIX_SUFFIX_MAX]){}, IN_ADDR_MAX + PREFIX_SUFFIX_MAX)
130
#define IN4_ADDR_PREFIX_TO_STRING(addr, prefixlen) \
131
        _in4_addr_prefix_to_string(addr, prefixlen, (char[INET_ADDRSTRLEN + PREFIX_SUFFIX_MAX]){}, INET_ADDRSTRLEN + PREFIX_SUFFIX_MAX)
132
#define IN6_ADDR_PREFIX_TO_STRING(addr, prefixlen) \
133
        _in6_addr_prefix_to_string(addr, prefixlen, (char[INET6_ADDRSTRLEN + PREFIX_SUFFIX_MAX]){}, INET6_ADDRSTRLEN + PREFIX_SUFFIX_MAX)
134

135
int in_addr_port_ifindex_name_to_string(int family, const union in_addr_union *u, uint16_t port, int ifindex, const char *server_name, char **ret);
136
static inline int in_addr_ifindex_to_string(int family, const union in_addr_union *u, int ifindex, char **ret) {
1,216✔
137
        return in_addr_port_ifindex_name_to_string(family, u, 0, ifindex, NULL, ret);
1,216✔
138
}
UNCOV
139
static inline int in_addr_port_to_string(int family, const union in_addr_union *u, uint16_t port, char **ret) {
×
UNCOV
140
        return in_addr_port_ifindex_name_to_string(family, u, port, 0, NULL, ret);
×
141
}
142
int in_addr_from_string(int family, const char *s, union in_addr_union *ret);
143
int in_addr_from_string_auto(const char *s, int *ret_family, union in_addr_union *ret);
144

145
unsigned char in4_addr_netmask_to_prefixlen(const struct in_addr *addr);
146
struct in_addr* in4_addr_prefixlen_to_netmask(struct in_addr *addr, unsigned char prefixlen);
147
struct in6_addr* in6_addr_prefixlen_to_netmask(struct in6_addr *addr, unsigned char prefixlen);
148
int in_addr_prefixlen_to_netmask(int family, union in_addr_union *addr, unsigned char prefixlen);
149
int in4_addr_default_prefixlen(const struct in_addr *addr, unsigned char *prefixlen);
150
int in4_addr_default_subnet_mask(const struct in_addr *addr, struct in_addr *mask);
151
int in4_addr_mask(struct in_addr *addr, unsigned char prefixlen);
152
int in6_addr_mask(struct in6_addr *addr, unsigned char prefixlen);
153
int in_addr_mask(int family, union in_addr_union *addr, unsigned char prefixlen);
154
int in4_addr_prefix_covers_full(const struct in_addr *prefix, unsigned char prefixlen, const struct in_addr *address, unsigned char address_prefixlen);
155
int in6_addr_prefix_covers_full(const struct in6_addr *prefix, unsigned char prefixlen, const struct in6_addr *address, unsigned char address_prefixlen);
156
int in_addr_prefix_covers_full(int family, const union in_addr_union *prefix, unsigned char prefixlen, const union in_addr_union *address, unsigned char address_prefixlen);
157
static inline int in4_addr_prefix_covers(const struct in_addr *prefix, unsigned char prefixlen, const struct in_addr *address) {
158
        return in4_addr_prefix_covers_full(prefix, prefixlen, address, 32);
159
}
160
static inline int in6_addr_prefix_covers(const struct in6_addr *prefix, unsigned char prefixlen, const struct in6_addr *address) {
71✔
161
        return in6_addr_prefix_covers_full(prefix, prefixlen, address, 128);
71✔
162
}
163
static inline int in_addr_prefix_covers(int family, const union in_addr_union *prefix, unsigned char prefixlen, const union in_addr_union *address) {
5,911✔
164
        return in_addr_prefix_covers_full(family, prefix, prefixlen, address, family == AF_INET ? 32 : family == AF_INET6 ? 128 : 0);
5,911✔
165
}
166
int in_addr_parse_prefixlen(int family, const char *p, unsigned char *ret);
167
int in_addr_prefix_from_string(const char *p, int family, union in_addr_union *ret_prefix, unsigned char *ret_prefixlen);
168

169
typedef enum InAddrPrefixLenMode {
170
        PREFIXLEN_FULL,   /* Default to prefixlen of address size, 32 for IPv4 or 128 for IPv6, if not specified. */
171
        PREFIXLEN_REFUSE, /* Fail with -ENOANO if prefixlen is not specified. */
172
} InAddrPrefixLenMode;
173

174
int in_addr_prefix_from_string_auto_full(const char *p, InAddrPrefixLenMode mode, int *ret_family, union in_addr_union *ret_prefix, unsigned char *ret_prefixlen);
175
static inline int in_addr_prefix_from_string_auto(const char *p, int *ret_family, union in_addr_union *ret_prefix, unsigned char *ret_prefixlen) {
134,898✔
176
        return in_addr_prefix_from_string_auto_full(p, PREFIXLEN_FULL, ret_family, ret_prefix, ret_prefixlen);
134,898✔
177
}
178

179
static inline size_t FAMILY_ADDRESS_SIZE(int family) {
1,456,495✔
180
        switch (family) {
1,456,495✔
181
                case AF_INET:
182
                        return 4;
183
                case AF_INET6:
689,615✔
184
                        return 16;
689,615✔
UNCOV
185
                default:
×
UNCOV
186
                        assert_not_reached();
×
187
        }
188
}
189

190
#define FAMILY_ADDRESS_SIZE_SAFE(f)                                     \
191
        ({                                                              \
192
                int _f = (f);                                           \
193
                _f == AF_INET ? sizeof(struct in_addr) :                \
194
                _f == AF_INET6 ? sizeof(struct in6_addr) : 0;           \
195
        })
196

197
/* Workaround for clang, explicitly specify the maximum-size element here.
198
 * See also oss-fuzz#11344. */
199
#define IN_ADDR_NULL ((union in_addr_union) { .in6 = {} })
200

201
void in_addr_hash_func(const union in_addr_union *u, int family, struct siphash *state);
202
void in_addr_data_hash_func(const struct in_addr_data *a, struct siphash *state);
203
int in_addr_data_compare_func(const struct in_addr_data *x, const struct in_addr_data *y);
204
void in6_addr_hash_func(const struct in6_addr *addr, struct siphash *state);
205
int in6_addr_compare_func(const struct in6_addr *a, const struct in6_addr *b);
206

207
extern const struct hash_ops in_addr_data_hash_ops;
208
extern const struct hash_ops in_addr_data_hash_ops_free;
209
extern const struct hash_ops in6_addr_hash_ops;
210
extern const struct hash_ops in6_addr_hash_ops_free;
211

212
static inline void PTR_TO_IN4_ADDR(const void *p, struct in_addr *ret) {
213
        assert(ret);
214
        ret->s_addr = (uint32_t) ((uintptr_t) p);
215
}
216

217
static inline void* IN4_ADDR_TO_PTR(const struct in_addr *a) {
218
        assert(a);
219
        return (void*) ((uintptr_t) a->s_addr);
220
}
221

222
#define IPV4_ADDRESS_FMT_STR     "%u.%u.%u.%u"
223
#define IPV4_ADDRESS_FMT_VAL(address)              \
224
        be32toh((address).s_addr) >> 24,           \
225
        (be32toh((address).s_addr) >> 16) & 0xFFu, \
226
        (be32toh((address).s_addr) >> 8) & 0xFFu,  \
227
        be32toh((address).s_addr) & 0xFFu
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc