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

systemd / systemd / 14766779411

30 Apr 2025 04:55PM UTC coverage: 72.225% (-0.06%) from 72.282%
14766779411

push

github

web-flow
wait-online: handle varlink connection errors while waiting for DNS (#37283)

Currently, if systemd-networkd-wait-online is started with --dns, and
systemd-resolved is not running, it will exit with an error right away.
Similarly, if systemd-resolved is restarted while waiting for DNS
configuration, systemd-networkd-wait-online will not attempt to
re-connect, and will potentially never see subsequent DNS
configurations.

Improve this by adding socket units for the systemd-resolved varlink
servers, and re-establish the connection in systemd-networkd-wait-online
when we receive `SD_VARLINK_ERROR_DISCONNECTED`.

8 of 16 new or added lines in 2 files covered. (50.0%)

5825 existing lines in 217 files now uncovered.

297168 of 411450 relevant lines covered (72.22%)

695892.62 hits per line

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

82.88
/src/network/netdev/vlan.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <errno.h>
4
#include <linux/if_arp.h>
5
#include <linux/if_vlan.h>
6
#include <net/if.h>
7

8
#include "parse-util.h"
9
#include "vlan.h"
10
#include "vlan-util.h"
11

12
static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) {
11✔
13
        assert(link);
11✔
14
        assert(req);
11✔
15

16
        struct ifla_vlan_flags flags = {};
11✔
17
        VLan *v = VLAN(netdev);
11✔
18
        int r;
11✔
19

20
        r = sd_netlink_message_append_u16(req, IFLA_VLAN_ID, v->id);
11✔
21
        if (r < 0)
11✔
22
                return r;
11✔
23

24
        if (v->protocol >= 0) {
11✔
UNCOV
25
                r = sd_netlink_message_append_u16(req, IFLA_VLAN_PROTOCOL, htobe16(v->protocol));
×
26
                if (r < 0)
×
27
                        return r;
28
        }
29

30
        if (v->gvrp != -1) {
11✔
31
                flags.mask |= VLAN_FLAG_GVRP;
10✔
32
                SET_FLAG(flags.flags, VLAN_FLAG_GVRP, v->gvrp);
10✔
33
        }
34

35
        if (v->mvrp != -1) {
11✔
36
                flags.mask |= VLAN_FLAG_MVRP;
10✔
37
                SET_FLAG(flags.flags, VLAN_FLAG_MVRP, v->mvrp);
10✔
38
        }
39

40
        if (v->reorder_hdr != -1) {
11✔
41
                flags.mask |= VLAN_FLAG_REORDER_HDR;
10✔
42
                SET_FLAG(flags.flags, VLAN_FLAG_REORDER_HDR, v->reorder_hdr);
10✔
43
        }
44

45
        if (v->loose_binding != -1) {
11✔
46
                flags.mask |= VLAN_FLAG_LOOSE_BINDING;
10✔
47
                SET_FLAG(flags.flags, VLAN_FLAG_LOOSE_BINDING, v->loose_binding);
10✔
48
        }
49

50
        r = sd_netlink_message_append_data(req, IFLA_VLAN_FLAGS, &flags, sizeof(struct ifla_vlan_flags));
11✔
51
        if (r < 0)
11✔
52
                return r;
53

54
        if (!set_isempty(v->egress_qos_maps)) {
11✔
55
                struct ifla_vlan_qos_mapping *m;
10✔
56

57
                r = sd_netlink_message_open_container(req, IFLA_VLAN_EGRESS_QOS);
10✔
58
                if (r < 0)
10✔
UNCOV
59
                        return r;
×
60

61
                SET_FOREACH(m, v->egress_qos_maps) {
60✔
62
                        r = sd_netlink_message_append_data(req, IFLA_VLAN_QOS_MAPPING, m, sizeof(struct ifla_vlan_qos_mapping));
50✔
63
                        if (r < 0)
50✔
UNCOV
64
                                return r;
×
65
                }
66

67
                r = sd_netlink_message_close_container(req);
10✔
68
                if (r < 0)
10✔
69
                        return r;
70
        }
71

72
        if (!set_isempty(v->ingress_qos_maps)) {
11✔
73
                struct ifla_vlan_qos_mapping *m;
10✔
74

75
                r = sd_netlink_message_open_container(req, IFLA_VLAN_INGRESS_QOS);
10✔
76
                if (r < 0)
10✔
UNCOV
77
                        return r;
×
78

79
                SET_FOREACH(m, v->ingress_qos_maps) {
30✔
80
                        r = sd_netlink_message_append_data(req, IFLA_VLAN_QOS_MAPPING, m, sizeof(struct ifla_vlan_qos_mapping));
20✔
81
                        if (r < 0)
20✔
UNCOV
82
                                return r;
×
83
                }
84

85
                r = sd_netlink_message_close_container(req);
10✔
86
                if (r < 0)
10✔
87
                        return r;
88
        }
89

90
        return 0;
91
}
92

93
static void vlan_qos_maps_hash_func(const struct ifla_vlan_qos_mapping *x, struct siphash *state) {
120✔
94
        siphash24_compress_typesafe(x->from, state);
120✔
95
        siphash24_compress_typesafe(x->to, state);
120✔
96
}
120✔
97

98
static int vlan_qos_maps_compare_func(const struct ifla_vlan_qos_mapping *a, const struct ifla_vlan_qos_mapping *b) {
29✔
99
        int r;
29✔
100

101
        r = CMP(a->from, b->from);
29✔
102
        if (r != 0)
5✔
103
                return r;
29✔
104

UNCOV
105
        return CMP(a->to, b->to);
×
106
}
107

108
DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(
70✔
109
                vlan_qos_maps_hash_ops,
110
                struct ifla_vlan_qos_mapping,
111
                vlan_qos_maps_hash_func,
112
                vlan_qos_maps_compare_func,
113
                free);
114

115
int config_parse_vlan_qos_maps(
20✔
116
                const char *unit,
117
                const char *filename,
118
                unsigned line,
119
                const char *section,
120
                unsigned section_line,
121
                const char *lvalue,
122
                int ltype,
123
                const char *rvalue,
124
                void *data,
125
                void *userdata) {
126

127
        Set **s = ASSERT_PTR(data);
20✔
128
        int r;
20✔
129

130
        assert(filename);
20✔
131
        assert(lvalue);
20✔
132
        assert(rvalue);
20✔
133

134
        if (isempty(rvalue)) {
20✔
UNCOV
135
                *s = set_free(*s);
×
136
                return 0;
×
137
        }
138

139
        for (const char *p = rvalue;;) {
20✔
140
                _cleanup_free_ struct ifla_vlan_qos_mapping *m = NULL;
180✔
141
                _cleanup_free_ char *w = NULL;
90✔
142
                unsigned from, to;
90✔
143

144
                r = extract_first_word(&p, &w, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
90✔
145
                if (r == -ENOMEM)
90✔
UNCOV
146
                        return log_oom();
×
147
                if (r < 0) {
90✔
UNCOV
148
                        log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue);
×
149
                        return 0;
×
150
                }
151
                if (r == 0)
90✔
152
                        return 0;
153

154
                r = parse_range(w, &from, &to);
70✔
155
                if (r < 0) {
70✔
UNCOV
156
                        log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, w);
×
157
                        continue;
×
158
                }
159

160
                m = new(struct ifla_vlan_qos_mapping, 1);
70✔
161
                if (!m)
70✔
UNCOV
162
                        return log_oom();
×
163

164
                *m = (struct ifla_vlan_qos_mapping) {
70✔
165
                        .from = from,
166
                        .to = to,
167
                };
168

169
                r = set_ensure_consume(s, &vlan_qos_maps_hash_ops, TAKE_PTR(m));
70✔
170
                if (r < 0) {
70✔
UNCOV
171
                        log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to store %s, ignoring: %s", lvalue, w);
×
172
                        continue;
×
173
                }
174
        }
175
}
176

177
static int netdev_vlan_verify(NetDev *netdev, const char *filename) {
12✔
178
        assert(filename);
12✔
179

180
        VLan *v = VLAN(netdev);
12✔
181

182
        if (v->id == VLANID_INVALID) {
12✔
UNCOV
183
                log_netdev_warning(netdev, "VLAN without valid Id (%"PRIu16") configured in %s.", v->id, filename);
×
184
                return -EINVAL;
×
185
        }
186

187
        return 0;
188
}
189

190
static void vlan_done(NetDev *netdev) {
12✔
191
        VLan *v = VLAN(netdev);
12✔
192

193
        set_free(v->egress_qos_maps);
12✔
194
        set_free(v->ingress_qos_maps);
12✔
195
}
12✔
196

197
static void vlan_init(NetDev *netdev) {
12✔
198
        VLan *v = VLAN(netdev);
12✔
199

200
        v->id = VLANID_INVALID;
12✔
201
        v->protocol = -1;
12✔
202
        v->gvrp = -1;
12✔
203
        v->mvrp = -1;
12✔
204
        v->loose_binding = -1;
12✔
205
        v->reorder_hdr = -1;
12✔
206
}
12✔
207

208
const NetDevVTable vlan_vtable = {
209
        .object_size = sizeof(VLan),
210
        .init = vlan_init,
211
        .sections = NETDEV_COMMON_SECTIONS "VLAN\0",
212
        .fill_message_create = netdev_vlan_fill_message_create,
213
        .create_type = NETDEV_CREATE_STACKED,
214
        .config_verify = netdev_vlan_verify,
215
        .done = vlan_done,
216
        .iftype = ARPHRD_ETHER,
217
};
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