1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

sd-dhcp6: drop empty 'error' label

This commit is contained in:
Yu Watanabe 2018-10-19 06:11:49 +09:00
parent 9a25416479
commit aae1fa5cc8

View File

@ -354,10 +354,8 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
switch (iatype) { switch (iatype) {
case SD_DHCP6_OPTION_IA_NA: case SD_DHCP6_OPTION_IA_NA:
if (len < DHCP6_OPTION_IA_NA_LEN) { if (len < DHCP6_OPTION_IA_NA_LEN)
r = -ENOBUFS; return -ENOBUFS;
goto error;
}
iaaddr_offset = DHCP6_OPTION_IA_NA_LEN; iaaddr_offset = DHCP6_OPTION_IA_NA_LEN;
memcpy(&ia->ia_na, iaoption->data, sizeof(ia->ia_na)); memcpy(&ia->ia_na, iaoption->data, sizeof(ia->ia_na));
@ -368,18 +366,15 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
if (lt_t1 && lt_t2 && lt_t1 > lt_t2) { if (lt_t1 && lt_t2 && lt_t1 > lt_t2) {
log_dhcp6_client(client, "IA NA T1 %ds > T2 %ds", log_dhcp6_client(client, "IA NA T1 %ds > T2 %ds",
lt_t1, lt_t2); lt_t1, lt_t2);
r = -EINVAL; return -EINVAL;
goto error;
} }
break; break;
case SD_DHCP6_OPTION_IA_PD: case SD_DHCP6_OPTION_IA_PD:
if (len < sizeof(ia->ia_pd)) { if (len < sizeof(ia->ia_pd))
r = -ENOBUFS; return -ENOBUFS;
goto error;
}
iaaddr_offset = sizeof(ia->ia_pd); iaaddr_offset = sizeof(ia->ia_pd);
memcpy(&ia->ia_pd, iaoption->data, sizeof(ia->ia_pd)); memcpy(&ia->ia_pd, iaoption->data, sizeof(ia->ia_pd));
@ -390,17 +385,14 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
if (lt_t1 && lt_t2 && lt_t1 > lt_t2) { if (lt_t1 && lt_t2 && lt_t1 > lt_t2) {
log_dhcp6_client(client, "IA PD T1 %ds > T2 %ds", log_dhcp6_client(client, "IA PD T1 %ds > T2 %ds",
lt_t1, lt_t2); lt_t1, lt_t2);
r = -EINVAL; return -EINVAL;
goto error;
} }
break; break;
case SD_DHCP6_OPTION_IA_TA: case SD_DHCP6_OPTION_IA_TA:
if (len < DHCP6_OPTION_IA_TA_LEN) { if (len < DHCP6_OPTION_IA_TA_LEN)
r = -ENOBUFS; return -ENOBUFS;
goto error;
}
iaaddr_offset = DHCP6_OPTION_IA_TA_LEN; iaaddr_offset = DHCP6_OPTION_IA_TA_LEN;
memcpy(&ia->ia_ta.id, iaoption->data, sizeof(ia->ia_ta)); memcpy(&ia->ia_ta.id, iaoption->data, sizeof(ia->ia_ta));
@ -408,8 +400,7 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
break; break;
default: default:
r = -ENOMSG; return -ENOMSG;
goto error;
} }
ia->type = iatype; ia->type = iatype;
@ -418,10 +409,8 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
while (i < len) { while (i < len) {
DHCP6Option *option = (DHCP6Option *)&iaoption->data[i]; DHCP6Option *option = (DHCP6Option *)&iaoption->data[i];
if (len < i + sizeof(*option) || len < i + sizeof(*option) + be16toh(option->len)) { if (len < i + sizeof(*option) || len < i + sizeof(*option) + be16toh(option->len))
r = -ENOBUFS; return -ENOBUFS;
goto error;
}
opt = be16toh(option->code); opt = be16toh(option->code);
optlen = be16toh(option->len); optlen = be16toh(option->len);
@ -431,13 +420,12 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_TA)) { if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_NA, SD_DHCP6_OPTION_IA_TA)) {
log_dhcp6_client(client, "IA Address option not in IA NA or TA option"); log_dhcp6_client(client, "IA Address option not in IA NA or TA option");
r = -EINVAL; return -EINVAL;
goto error;
} }
r = dhcp6_option_parse_address(option, ia, &lt_valid); r = dhcp6_option_parse_address(option, ia, &lt_valid);
if (r < 0) if (r < 0)
goto error; return r;
if (lt_valid < lt_min) if (lt_valid < lt_min)
lt_min = lt_valid; lt_min = lt_valid;
@ -448,13 +436,12 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_PD)) { if (!IN_SET(ia->type, SD_DHCP6_OPTION_IA_PD)) {
log_dhcp6_client(client, "IA PD Prefix option not in IA PD option"); log_dhcp6_client(client, "IA PD Prefix option not in IA PD option");
r = -EINVAL; return -EINVAL;
goto error;
} }
r = dhcp6_option_parse_pdprefix(option, ia, &lt_valid); r = dhcp6_option_parse_pdprefix(option, ia, &lt_valid);
if (r < 0) if (r < 0)
goto error; return r;
if (lt_valid < lt_min) if (lt_valid < lt_min)
lt_min = lt_valid; lt_min = lt_valid;
@ -464,16 +451,13 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
case SD_DHCP6_OPTION_STATUS_CODE: case SD_DHCP6_OPTION_STATUS_CODE:
status = dhcp6_option_parse_status(option, optlen + sizeof(DHCP6Option)); status = dhcp6_option_parse_status(option, optlen + sizeof(DHCP6Option));
if (status < 0) { if (status < 0)
r = status; return status;
goto error;
}
if (status > 0) { if (status > 0) {
log_dhcp6_client(client, "IA status %d", log_dhcp6_client(client, "IA status %d",
status); status);
r = -EINVAL; return -EINVAL;
goto error;
} }
break; break;
@ -517,8 +501,7 @@ int dhcp6_option_parse_ia(DHCP6Option *iaoption, DHCP6IA *ia) {
break; break;
} }
error: return 0;
return r;
} }
int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen, int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,