Skip to content

Commit 173a6e2

Browse files
ssahanipoettering
authored andcommitted
networkd: vxlan make use of parse_ip_port_range
Use parse_ip_port_range
1 parent ecb1a44 commit 173a6e2

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

src/network/netdev/vxlan.c

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netli
129129
if (r < 0)
130130
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VXLAN_PORT attribute: %m");
131131

132-
if (v->port_range.low || v->port_range.high) {
132+
if (v->port_range.low != 0 || v->port_range.high != 0) {
133133
struct ifla_vxlan_port_range port_range;
134134

135135
port_range.low = htobe16(v->port_range.low);
@@ -214,40 +214,19 @@ int config_parse_port_range(const char *unit,
214214
const char *rvalue,
215215
void *data,
216216
void *userdata) {
217-
_cleanup_free_ char *word = NULL;
218217
VxLan *v = userdata;
219-
unsigned low, high;
218+
uint16_t low, high;
220219
int r;
221220

222221
assert(filename);
223222
assert(lvalue);
224223
assert(rvalue);
225224
assert(data);
226225

227-
r = extract_first_word(&rvalue, &word, NULL, 0);
226+
r = parse_ip_port_range(rvalue, &low, &high);
228227
if (r < 0) {
229-
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to extract VXLAN port range, ignoring: %s", rvalue);
230-
return 0;
231-
}
232-
233-
if (r == 0)
234-
return 0;
235-
236-
r = parse_range(word, &low, &high);
237-
if (r < 0) {
238-
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse VXLAN port range '%s'", word);
239-
return 0;
240-
}
241-
242-
if (low <= 0 || low > 65535 || high <= 0 || high > 65535) {
243-
log_syntax(unit, LOG_ERR, filename, line, r,
244-
"Failed to parse VXLAN port range '%s'. Port should be greater than 0 and less than 65535.", word);
245-
return 0;
246-
}
247-
248-
if (high < low) {
249228
log_syntax(unit, LOG_ERR, filename, line, r,
250-
"Failed to parse VXLAN port range '%s'. Port range %u .. %u not valid", word, low, high);
229+
"Failed to parse VXLAN port range '%s'. Port should be greater than 0 and less than 65535.", rvalue);
251230
return 0;
252231
}
253232

0 commit comments

Comments
 (0)