@@ -1134,30 +1134,24 @@ static int client_parse_message(
11341134
11351135 switch (optcode ) {
11361136 case SD_DHCP6_OPTION_CLIENTID :
1137- if (clientid ) {
1138- log_dhcp6_client (client , "%s contains multiple clientids" ,
1139- dhcp6_message_type_to_string (message -> type ));
1140- return - EINVAL ;
1141- }
1137+ if (clientid )
1138+ return log_dhcp6_client_errno (client , SYNTHETIC_ERRNO (EINVAL ), "%s contains multiple clientids" ,
1139+ dhcp6_message_type_to_string (message -> type ));
11421140
11431141 if (optlen != client -> duid_len ||
1144- memcmp (& client -> duid , optval , optlen ) != 0 ) {
1145- log_dhcp6_client (client , "%s DUID does not match" ,
1146- dhcp6_message_type_to_string (message -> type ));
1142+ memcmp (& client -> duid , optval , optlen ) != 0 )
1143+ return log_dhcp6_client_errno (client , SYNTHETIC_ERRNO ( EINVAL ) , "%s DUID does not match" ,
1144+ dhcp6_message_type_to_string (message -> type ));
11471145
1148- return - EINVAL ;
1149- }
11501146 clientid = true;
11511147
11521148 break ;
11531149
11541150 case SD_DHCP6_OPTION_SERVERID :
11551151 r = dhcp6_lease_get_serverid (lease , NULL , NULL );
1156- if (r >= 0 ) {
1157- log_dhcp6_client (client , "%s contains multiple serverids" ,
1158- dhcp6_message_type_to_string (message -> type ));
1159- return - EINVAL ;
1160- }
1152+ if (r >= 0 )
1153+ return log_dhcp6_client_errno (client , SYNTHETIC_ERRNO (EINVAL ), "%s contains multiple serverids" ,
1154+ dhcp6_message_type_to_string (message -> type ));
11611155
11621156 r = dhcp6_lease_set_serverid (lease , optval , optlen );
11631157 if (r < 0 )
@@ -1180,20 +1174,16 @@ static int client_parse_message(
11801174 if (status < 0 )
11811175 return status ;
11821176
1183- if (status > 0 ) {
1184- log_dhcp6_client (client , "%s Status %s" ,
1185- dhcp6_message_type_to_string (message -> type ),
1186- dhcp6_message_status_to_string (status ));
1187-
1188- return - EINVAL ;
1189- }
1177+ if (status > 0 )
1178+ return log_dhcp6_client_errno (client , SYNTHETIC_ERRNO (EINVAL ), "%s Status %s" ,
1179+ dhcp6_message_type_to_string (message -> type ),
1180+ dhcp6_message_status_to_string (status ));
11901181
11911182 break ;
11921183
11931184 case SD_DHCP6_OPTION_IA_NA :
11941185 if (client -> state == DHCP6_STATE_INFORMATION_REQUEST ) {
1195- log_dhcp6_client (client , "Information request ignoring IA NA option" );
1196-
1186+ log_dhcp6_client (client , "Ignoring IA NA option in information requesting mode." );
11971187 break ;
11981188 }
11991189
@@ -1210,11 +1200,9 @@ static int client_parse_message(
12101200 if (r < 0 )
12111201 return r ;
12121202
1213- if (client -> ia_na .ia_na .id != iaid_lease ) {
1214- log_dhcp6_client (client , "%s has wrong IAID for IA NA" ,
1215- dhcp6_message_type_to_string (message -> type ));
1216- return - EINVAL ;
1217- }
1203+ if (client -> ia_na .ia_na .id != iaid_lease )
1204+ return log_dhcp6_client_errno (client , SYNTHETIC_ERRNO (EINVAL ), "%s has wrong IAID for IA NA" ,
1205+ dhcp6_message_type_to_string (message -> type ));
12181206
12191207 if (lease -> ia .addresses ) {
12201208 lt_t1 = MIN (lt_t1 , be32toh (lease -> ia .ia_na .lifetime_t1 ));
@@ -1225,8 +1213,7 @@ static int client_parse_message(
12251213
12261214 case SD_DHCP6_OPTION_IA_PD :
12271215 if (client -> state == DHCP6_STATE_INFORMATION_REQUEST ) {
1228- log_dhcp6_client (client , "Information request ignoring IA PD option" );
1229-
1216+ log_dhcp6_client (client , "Ignoring IA PD option in information requesting mode." );
12301217 break ;
12311218 }
12321219
@@ -1243,11 +1230,9 @@ static int client_parse_message(
12431230 if (r < 0 )
12441231 return r ;
12451232
1246- if (client -> ia_pd .ia_pd .id != iaid_lease ) {
1247- log_dhcp6_client (client , "%s has wrong IAID for IA PD" ,
1248- dhcp6_message_type_to_string (message -> type ));
1249- return - EINVAL ;
1250- }
1233+ if (client -> ia_pd .ia_pd .id != iaid_lease )
1234+ return log_dhcp6_client_errno (client , SYNTHETIC_ERRNO (EINVAL ), "%s has wrong IAID for IA PD" ,
1235+ dhcp6_message_type_to_string (message -> type ));
12511236
12521237 if (lease -> pd .addresses ) {
12531238 lt_t1 = MIN (lt_t1 , be32toh (lease -> pd .ia_pd .lifetime_t1 ));
@@ -1309,24 +1294,18 @@ static int client_parse_message(
13091294 pos += offsetof(DHCP6Option , data ) + optlen ;
13101295 }
13111296
1312- if (ia_na_status > 0 && ia_pd_status > 0 ) {
1313- log_dhcp6_client (client , "No IA_PD prefix or IA_NA address received. Ignoring." );
1314- return - EINVAL ;
1315- }
1297+ if (ia_na_status > 0 && ia_pd_status > 0 )
1298+ return log_dhcp6_client_errno (client , SYNTHETIC_ERRNO (EINVAL ), "No IA_PD prefix or IA_NA address received. Ignoring." );
13161299
1317- if (!clientid ) {
1318- log_dhcp6_client (client , "%s has incomplete options" ,
1319- dhcp6_message_type_to_string (message -> type ));
1320- return - EINVAL ;
1321- }
1300+ if (!clientid )
1301+ return log_dhcp6_client_errno (client , SYNTHETIC_ERRNO (EINVAL ), "%s has incomplete options" ,
1302+ dhcp6_message_type_to_string (message -> type ));
13221303
13231304 if (client -> state != DHCP6_STATE_INFORMATION_REQUEST ) {
13241305 r = dhcp6_lease_get_serverid (lease , NULL , NULL );
1325- if (r < 0 ) {
1326- log_dhcp6_client (client , "%s has no server id" ,
1327- dhcp6_message_type_to_string (message -> type ));
1328- return - EINVAL ;
1329- }
1306+ if (r < 0 )
1307+ return log_dhcp6_client_errno (client , r , "%s has no server id" ,
1308+ dhcp6_message_type_to_string (message -> type ));
13301309 }
13311310
13321311 if (lease -> ia .addresses ) {
0 commit comments